From 11fcfdc69a466705290819da3c87f87c45a7873c Mon Sep 17 00:00:00 2001 From: Konrad Jamrozik Date: Fri, 5 Jul 2024 20:16:13 -0700 Subject: [PATCH] Assert that events in turn, except possibly the last one, are not time advancement --- src/game-lib/Events/GameEventType.cs | 2 ++ src/game-lib/State/GameSessionTurn.cs | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/game-lib/Events/GameEventType.cs b/src/game-lib/Events/GameEventType.cs index 67708d8b..46126adb 100644 --- a/src/game-lib/Events/GameEventType.cs +++ b/src/game-lib/Events/GameEventType.cs @@ -25,6 +25,8 @@ public class GameEventType public static bool IsValidPlayerActionEvent(string type) => PlayerActionName.IsValid(type); + public bool IsNotTimeAdvancement => ToString() != nameof(AdvanceTimePlayerAction); + public GameEventType(string type) { Contract.Assert(IsValidWorldEventType(type) || IsValidPlayerActionEvent(type)); diff --git a/src/game-lib/State/GameSessionTurn.cs b/src/game-lib/State/GameSessionTurn.cs index 932c7ea3..8832a9a5 100644 --- a/src/game-lib/State/GameSessionTurn.cs +++ b/src/game-lib/State/GameSessionTurn.cs @@ -55,9 +55,9 @@ public void AssertInvariants() "Number of events in turn must match the number of updates between the game states."); Contract.Assert(EventsUntilStartState.Last().Type.ToString() == GameEventType.ReportEvent); + Contract.Assert(EventsInTurn.SkipLast(1).All(@event => @event.Type.IsNotTimeAdvancement)); IdGen.AssertConsecutiveIds(GameEvents.ToList()); - // kja all events in turn except the last one must be not AdvanceTime player action - // Contract.Assert(EventsInTurn.SkipLast(1).All(@event => @event.Type == "a")) + StartState.AssertInvariants(); EndState.AssertInvariants(); }