Skip to content

Commit 2d505cd

Browse files
authored
Merge pull request #3029 from ZeroK-RTS/turnSwap
Turn swap PW
2 parents 513c791 + ff63236 commit 2d505cd

8 files changed

Lines changed: 743 additions & 371 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)

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)