private void AttackAndVerify(IAttackRandomGen randomGen) { // Arrange var game = TestUtils.CreateStartedGameWithMapAndPlayers(); var mapTemplate = TestUtils.GetMapTemplate(); var origin = Helper.TestHelper.GetCountryWithEnemyConnection(game, game.CurrentPlayer, mapTemplate); var destination = Helper.TestHelper.GetConnectedEnemyCountry(game, game.CurrentPlayer, origin, mapTemplate); var player = game.CurrentPlayer; origin.Units = 4; game.PlayState = Enums.PlayState.Attack; // Act var originUnitCount = origin.Units; var originOwnerId = origin.PlayerId; var destinationOwnerId = destination.PlayerId; game.Attack(new AttackService(randomGen), new TestRandomGen(), mapTemplate, origin.CountryIdentifier, destination.CountryIdentifier, origin.Units - game.Options.MinUnitsPerCountry); game.EndTurn(); var historicTurnBefore = game.GameHistory.GetTurn(game.TurnCounter - 2); var historicTurn = game.GameHistory.GetTurn(game.TurnCounter - 1); // Assert Assert.AreEqual(2, historicTurn.Actions.Count()); var historicOrigin = historicTurnBefore.Game.Map.GetCountry(origin.CountryIdentifier); var historicDestination = historicTurnBefore.Game.Map.GetCountry(destination.CountryIdentifier); Assert.AreEqual(originUnitCount, historicOrigin.Units); Assert.AreEqual(originOwnerId, historicOrigin.PlayerId); Assert.AreEqual(destinationOwnerId, historicDestination.PlayerId); }
private void AttackAndVerify(IAttackRandomGen randomGen) { // Arrange var game = TestUtils.CreateStartedGameWithMapAndPlayers(); var mapTemplate = TestUtils.GetMapTemplate(); var origin = TestHelper.GetCountryWithEnemyConnection(game, game.CurrentPlayer, mapTemplate); var destination = TestHelper.GetConnectedEnemyCountry(game, game.CurrentPlayer, origin, mapTemplate); var player = game.CurrentPlayer; origin.Units = 4; game.PlayState = Enums.PlayState.Attack; // Act var originUnitCount = origin.Units; var originOwnerId = origin.PlayerId; var destinationOwnerId = destination.PlayerId; game.Attack(new AttackService(randomGen), new RandomGen(), mapTemplate, origin.CountryIdentifier, destination.CountryIdentifier, origin.Units - game.Options.MinUnitsPerCountry); game.EndTurn(); var historicTurnBefore = game.GameHistory.GetTurn(game.TurnCounter - 2); var historicTurn = game.GameHistory.GetTurn(game.TurnCounter - 1); // Assert Assert.AreEqual(2, historicTurn.Actions.Count()); var historicOrigin = historicTurnBefore.Game.Map.GetCountry(origin.CountryIdentifier); var historicDestination = historicTurnBefore.Game.Map.GetCountry(destination.CountryIdentifier); Assert.AreEqual(originUnitCount, historicOrigin.Units); Assert.AreEqual(originOwnerId, historicOrigin.PlayerId); Assert.AreEqual(destinationOwnerId, historicDestination.PlayerId); }
public AttackService(IAttackRandomGen randomGen) { this.randomGen = randomGen; }