public void AITurnTimeoutShouldBeEnforced() { Globals.Config.ConcurrentTurnsEnabled = false; Globals.Config.AITurnTimeout = 5; SetupScenarioForTwoZombies(out var zombie1, out var zombie2); // It should be zombie1's turn. GameSystems.D20.Initiative.CurrentActor.Should().Be(zombie1); // To ensure the zombie doesn't attempt to move to the player *again* since it has time left, // we ensure there's no remaining movement. GameSystems.D20.Actions.CurrentSequence !.tbStatus.surplusMoveDistance = 0; // To trigger the greybar reset, we need to ensure that zombie1 can never complete it's move action // We do this by moving it back to its starting position on every frame. Poor Zombie. var startOfTurn = GameSystems.TimeEvent.AnimTime; var startPos = zombie1.GetLocationFull(); Game.RunUntil(() => { zombie1.Move(startPos); return(GameSystems.D20.Initiative.CurrentActor == zombie2); }, 10000); // The switch to the 2nd zombie should have happened after the timeout var timeoutAfter = (GameSystems.TimeEvent.AnimTime - startOfTurn).TotalSeconds; timeoutAfter.Should().BeApproximately(Globals.Config.AITurnTimeout, 0.1f); // The zombie should only have attempted one action, unsuccessfully ActionLog.Count(a => a.d20APerformer == zombie1).Should().Be(1); }