Skip to content

Commit

Permalink
Assert that events in turn, except possibly the last one, are not tim…
Browse files Browse the repository at this point in the history
…e advancement
  • Loading branch information
Konrad Jamrozik committed Jul 6, 2024
1 parent 9fc01eb commit 11fcfdc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/game-lib/Events/GameEventType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions src/game-lib/State/GameSessionTurn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit 11fcfdc

Please sign in to comment.