Skip to content
Merged
1 change: 1 addition & 0 deletions .idea/.idea.Zero-K/.idea/projectSettingsUpdater.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 13 additions & 8 deletions Fixer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -431,17 +431,22 @@ private static void TestPwMatchMaker()
{
var server = new global::ZkLobbyServer.ZkLobbyServer("", new PlanetwarsEventCreator());
var mm = server.PlanetWarsMatchMaker;
mm.ChallengeTime = DateTime.Now;
mm.AttackerSideCounter = 1;
//mm.ResetAttackOptions();
mm.GenerateLobbyCommand();
mm.Challenge = mm.AttackOptions[3];
mm.Challenge.OwnerFactionID = 2;
mm.Challenge.PlanetID = 4375;
mm.GetDefendingFactions(mm.Challenge);
mm.GenerateLobbyCommand();

//mm.Challenge =
// simulate defend phase with a formed squad
if (mm.AttackOptions.Count > 3)
{
var opt = mm.AttackOptions[3];
opt.OwnerFactionID = 2;
opt.PlanetID = 4375;
mm.FormedSquads.Add(opt);
mm.Phase = PwPhase.DefendCollect;
mm.PhaseStartTime = DateTime.UtcNow;
mm.GetDefendingFactions(opt);
mm.GenerateLobbyCommand();
}

Global.Server.PlanetWarsMatchMaker.GenerateLobbyCommand();
}

Expand Down
4 changes: 2 additions & 2 deletions Shared/PlasmaShared/GlobalConst.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ static void SetMode(ModeType newMode)
public const int PostVoteHideThreshold = -6;
public const bool OnlyAdminsSeePostVoters = false;
public const int PlanetWarsMinutesToAttackIfNoOption = 2;
public const int PlanetWarsMinutesToAttack = 20;
public const int PlanetWarsMinutesToAccept = 5;
public const int PlanetWarsMinutesToAttack = 5;
public const int PlanetWarsMinutesToAccept = 10;
public const int PlanetWarsDropshipsStayForMinutes = 2*60;
public const int PlanetWarsMaxTeamsize = 4;
public const double PlanetWarsDefenderWinKillCcMultiplier = 0.2;
Expand Down
8 changes: 7 additions & 1 deletion Shared/PlasmaShared/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -537,12 +537,18 @@ public static Thread SafeThread(Action action)


public static U Get<T, U>(this IDictionary<T, U> dict, T key)
where U : class
{
U val = default(U);
if (key != null) dict.TryGetValue(key, out val);
return val;
}

public static U GetOrDefault<T, U>(this IDictionary<T, U> dict, T key, U defaultValue)
{
U val = defaultValue;
if (key != null) dict.TryGetValue(key, out val);
return val;
}


public static List<T> Shuffle<T>(this IEnumerable<T> source)
Expand Down
4 changes: 2 additions & 2 deletions Zero-K.info/Views/Planetwars/PwMatchMaker.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
}
else
{
PwMatchCommand.VoteOption opt = pw.Options.First();
text = string.Format("{0} attacks planet {2}, {1} defends", pw.AttackerFaction, string.Join(",", pw.DefenderFactions), opt.PlanetName);
var planetNames = string.Join(", ", pw.Options.Select(o => o.PlanetName));
text = string.Format("{0} attacks {2}, {1} defends", pw.AttackerFaction, string.Join(",", pw.DefenderFactions), planetNames);
}

bool canClick = (pw.Mode == PwMatchCommand.ModeType.Attack && pw.AttackerFaction == Global.Account.Faction.Shortcut) || (pw.Mode == PwMatchCommand.ModeType.Defend && pw.DefenderFactions.Contains(Global.Account.Faction.Shortcut));
Expand Down
25 changes: 14 additions & 11 deletions ZeroKLobby/Notifications/PwBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,23 +82,26 @@ void UpdateGui()
}
else if (pw.Mode == PwMatchCommand.ModeType.Defend)
{
PwMatchCommand.VoteOption opt = pw.Options.First();
headerLabel.Text = string.Format("{0} attacks planet {2}, {1} defends",
headerLabel.Text = string.Format("{0} attacks, {1} defends",
pw.AttackerFaction,
string.Join(",", pw.DefenderFactions),
opt.PlanetName);
string.Join(",", pw.DefenderFactions));

foreach (Button c in pnl.Controls.OfType<Button>().ToList()) pnl.Controls.Remove(c);

var but = new Button { Text = string.Format("{0} [{1}/{2}]", opt.PlanetName, opt.Count, opt.Needed), AutoSize = true };
Program.ToolTip.SetMap(but, opt.Map);

if (pw.DefenderFactions.Contains(tas.MyUser.Faction)) // NOTE this is for cases where nightwatch self faction info is delayed
foreach (PwMatchCommand.VoteOption opt in pw.Options)
{
AddButtonClick(opt, but);
Program.Downloader.GetResource(DownloadType.MAP, opt.Map);

var but = new Button { Text = string.Format("{0} [{1}/{2}]", opt.PlanetName, opt.Count, opt.Needed), AutoSize = true };
Program.ToolTip.SetMap(but, opt.Map);

if (pw.DefenderFactions.Contains(tas.MyUser.Faction))
{
AddButtonClick(opt, but);
}
else but.Enabled = false;
pnl.Controls.Add(but);
}
else but.Enabled = false;
pnl.Controls.Add(but);
}

Program.NotifySection.AddBar(this);
Expand Down
2 changes: 1 addition & 1 deletion ZkData/Ef/WHR/RatingSystems.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static void Init()
{
int battles = 0;
data.Database.CommandTimeout = 240;
for (int month = 5*12; month > 0; month--)
for (int month = 10*12; month > 0; month--)
{
DateTime minStartTime = DateTime.Now.AddMonths(-month);
DateTime maxStartTime = DateTime.Now.AddMonths(-month + 1);
Expand Down
2 changes: 1 addition & 1 deletion ZkLobbyServer/SpringieInterface/BattleResultHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ private static void ProcessPlanetWars(SpringBattleContext result, ZkLobbyServer.
if (winNum > 1) winNum = null;
}

PlanetWarsTurnHandler.EndTurn(result.LobbyStartContext.Map,
PlanetWarsTurnHandler.ProcessBattleResult(result.LobbyStartContext.Map,
result.OutputExtras,
db,
winNum,
Expand Down
Loading
Loading