public void CombatShouldWorkWithTwoOpponentsAndSequentialTurns() { Globals.Config.ConcurrentTurnsEnabled = false; SetupScenarioForTwoZombies(out var zombie1, out var zombie2); // The zombies should not perform simultaneously GameSystems.D20.Actions.isSimultPerformer(zombie1).Should().BeFalse(); GameSystems.D20.Actions.isSimultPerformer(zombie2).Should().BeFalse(); // It should be zombie1's turn, run the game until it's zombie2's turn and check what zombie1 did GameSystems.D20.Initiative.CurrentActor.Should().Be(zombie1); Game.RunUntil(() => GameSystems.D20.Initiative.CurrentActor == zombie2, 10000); CompletedActions.Should() .HaveCount(1) .And.Contain(action => action.d20APerformer == zombie1 && action.d20ATarget == _player && action.d20ActType == D20ActionType.MOVE); ActionLog.Clear(); // Now it's zombie2's turn, run until it's the player's turn and check what zombie2 did Game.RunUntil(() => GameSystems.D20.Initiative.CurrentActor == _player, 10000); CompletedActions.Should() .HaveCount(1) .And.Contain(action => action.d20APerformer == zombie2 && action.d20ATarget == _player && action.d20ActType == D20ActionType.MOVE); // Since both zombies just moved, there should be no combat entries CombatLog.Should().BeEmpty(); }
private void SetupScenarioForTwoZombies(out GameObject zombie1, out GameObject zombie2) { // Initially, the logs should be empty. CombatLog.Should().BeEmpty(); ActionLog.Should().BeEmpty(); zombie1 = GameSystems.MapObject.CreateObject(TestProtos.Zombie, new locXY(500, 483)); GameSystems.Critter.GenerateHp(zombie1); zombie2 = GameSystems.MapObject.CreateObject(TestProtos.Zombie, new locXY(500, 484)); GameSystems.Critter.GenerateHp(zombie2); // Ensure a specific turn order SetInitiative(_player, 20); SetInitiative(zombie1, 10); SetInitiative(zombie2, 0); Game.RunUntil(() => GameSystems.Combat.IsCombatActive()); GameSystems.Combat.IsCombatActive().Should().BeTrue(); GameSystems.D20.Initiative.CurrentActor.Should().Be(_player); GameSystems.D20.Initiative.Should().Equal( _player, zombie1, zombie2 ); // Without advancing time, no combat history entries should exist CombatLog.Should().BeEmpty(); ActionLog.Should().BeEmpty(); // End turn for the player GameSystems.Combat.AdvanceTurn(_player); GameSystems.Combat.IsCombatActive().Should().BeTrue(); }