Skip to content

Commit 408390f

Browse files
authored
Merge pull request #3031 from ZeroK-RTS/master whr back to 10 years + PW turn logic
2 parents 2beb0fb + 0dbf529 commit 408390f

11 files changed

Lines changed: 825 additions & 385 deletions

File tree

.idea/.idea.Zero-K/.idea/projectSettingsUpdater.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Fixer/Program.cs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -431,17 +431,22 @@ private static void TestPwMatchMaker()
431431
{
432432
var server = new global::ZkLobbyServer.ZkLobbyServer("", new PlanetwarsEventCreator());
433433
var mm = server.PlanetWarsMatchMaker;
434-
mm.ChallengeTime = DateTime.Now;
435434
mm.AttackerSideCounter = 1;
436-
//mm.ResetAttackOptions();
437-
mm.GenerateLobbyCommand();
438-
mm.Challenge = mm.AttackOptions[3];
439-
mm.Challenge.OwnerFactionID = 2;
440-
mm.Challenge.PlanetID = 4375;
441-
mm.GetDefendingFactions(mm.Challenge);
442435
mm.GenerateLobbyCommand();
443436

444-
//mm.Challenge =
437+
// simulate defend phase with a formed squad
438+
if (mm.AttackOptions.Count > 3)
439+
{
440+
var opt = mm.AttackOptions[3];
441+
opt.OwnerFactionID = 2;
442+
opt.PlanetID = 4375;
443+
mm.FormedSquads.Add(opt);
444+
mm.Phase = PwPhase.DefendCollect;
445+
mm.PhaseStartTime = DateTime.UtcNow;
446+
mm.GetDefendingFactions(opt);
447+
mm.GenerateLobbyCommand();
448+
}
449+
445450
Global.Server.PlanetWarsMatchMaker.GenerateLobbyCommand();
446451
}
447452

Shared/PlasmaShared/GlobalConst.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@ static void SetMode(ModeType newMode)
210210
public const int PostVoteHideThreshold = -6;
211211
public const bool OnlyAdminsSeePostVoters = false;
212212
public const int PlanetWarsMinutesToAttackIfNoOption = 2;
213-
public const int PlanetWarsMinutesToAttack = 20;
214-
public const int PlanetWarsMinutesToAccept = 5;
213+
public const int PlanetWarsMinutesToAttack = 5;
214+
public const int PlanetWarsMinutesToAccept = 10;
215215
public const int PlanetWarsDropshipsStayForMinutes = 2*60;
216216
public const int PlanetWarsMaxTeamsize = 4;
217217
public const double PlanetWarsDefenderWinKillCcMultiplier = 0.2;

Shared/PlasmaShared/Utils.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,12 +537,18 @@ public static Thread SafeThread(Action action)
537537

538538

539539
public static U Get<T, U>(this IDictionary<T, U> dict, T key)
540-
where U : class
541540
{
542541
U val = default(U);
543542
if (key != null) dict.TryGetValue(key, out val);
544543
return val;
545544
}
545+
546+
public static U GetOrDefault<T, U>(this IDictionary<T, U> dict, T key, U defaultValue)
547+
{
548+
U val = defaultValue;
549+
if (key != null) dict.TryGetValue(key, out val);
550+
return val;
551+
}
546552

547553

548554
public static List<T> Shuffle<T>(this IEnumerable<T> source)

Zero-K.info/Views/Planetwars/PwMatchMaker.cshtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
}
1414
else
1515
{
16-
PwMatchCommand.VoteOption opt = pw.Options.First();
17-
text = string.Format("{0} attacks planet {2}, {1} defends", pw.AttackerFaction, string.Join(",", pw.DefenderFactions), opt.PlanetName);
16+
var planetNames = string.Join(", ", pw.Options.Select(o => o.PlanetName));
17+
text = string.Format("{0} attacks {2}, {1} defends", pw.AttackerFaction, string.Join(",", pw.DefenderFactions), planetNames);
1818
}
1919

2020
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));

ZeroKLobby/Notifications/PwBar.cs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,23 +82,26 @@ void UpdateGui()
8282
}
8383
else if (pw.Mode == PwMatchCommand.ModeType.Defend)
8484
{
85-
PwMatchCommand.VoteOption opt = pw.Options.First();
86-
headerLabel.Text = string.Format("{0} attacks planet {2}, {1} defends",
85+
headerLabel.Text = string.Format("{0} attacks, {1} defends",
8786
pw.AttackerFaction,
88-
string.Join(",", pw.DefenderFactions),
89-
opt.PlanetName);
87+
string.Join(",", pw.DefenderFactions));
9088

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

93-
var but = new Button { Text = string.Format("{0} [{1}/{2}]", opt.PlanetName, opt.Count, opt.Needed), AutoSize = true };
94-
Program.ToolTip.SetMap(but, opt.Map);
95-
96-
if (pw.DefenderFactions.Contains(tas.MyUser.Faction)) // NOTE this is for cases where nightwatch self faction info is delayed
91+
foreach (PwMatchCommand.VoteOption opt in pw.Options)
9792
{
98-
AddButtonClick(opt, but);
93+
Program.Downloader.GetResource(DownloadType.MAP, opt.Map);
94+
95+
var but = new Button { Text = string.Format("{0} [{1}/{2}]", opt.PlanetName, opt.Count, opt.Needed), AutoSize = true };
96+
Program.ToolTip.SetMap(but, opt.Map);
97+
98+
if (pw.DefenderFactions.Contains(tas.MyUser.Faction))
99+
{
100+
AddButtonClick(opt, but);
101+
}
102+
else but.Enabled = false;
103+
pnl.Controls.Add(but);
99104
}
100-
else but.Enabled = false;
101-
pnl.Controls.Add(but);
102105
}
103106

104107
Program.NotifySection.AddBar(this);

ZkData/Ef/WHR/RatingSystems.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public static void Init()
3737
{
3838
int battles = 0;
3939
data.Database.CommandTimeout = 240;
40-
for (int month = 5*12; month > 0; month--)
40+
for (int month = 10*12; month > 0; month--)
4141
{
4242
DateTime minStartTime = DateTime.Now.AddMonths(-month);
4343
DateTime maxStartTime = DateTime.Now.AddMonths(-month + 1);

ZkLobbyServer/SpringieInterface/BattleResultHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ private static void ProcessPlanetWars(SpringBattleContext result, ZkLobbyServer.
184184
if (winNum > 1) winNum = null;
185185
}
186186

187-
PlanetWarsTurnHandler.EndTurn(result.LobbyStartContext.Map,
187+
PlanetWarsTurnHandler.ProcessBattleResult(result.LobbyStartContext.Map,
188188
result.OutputExtras,
189189
db,
190190
winNum,

0 commit comments

Comments
 (0)