public static void Test_ShiftFromPlayerActions_MultipleTimesSameTurn() { var player = new Player(PlayerActionFactory.CreateSingleActionList(new PlayerActionType?[] { PlayerActionType.Alpha, PlayerActionType.Bravo, PlayerActionType.Charlie, PlayerActionType.ChangeDeck, PlayerActionType.HeroicA }), 0, PlayerColor.Blue); player.Actions.ElementAt(0).FirstActionSegment.SegmentStatus = PlayerActionStatus.Performed; player.Actions.ElementAt(1).FirstActionSegment.SegmentStatus = PlayerActionStatus.Performing; player.ShiftFromPlayerActions(2); player.ShiftFromPlayerActions(2); var expectedActions = PlayerActionFactory.CreateSingleActionList(new PlayerActionType?[] { PlayerActionType.Alpha, PlayerActionType.Bravo, null, PlayerActionType.Charlie, PlayerActionType.ChangeDeck }).ToList(); expectedActions[0].FirstActionSegment.SegmentStatus = PlayerActionStatus.Performed; expectedActions[1].FirstActionSegment.SegmentStatus = PlayerActionStatus.Performing; AssertActionAreEqual(expectedActions.ToList(), player.Actions.ToList()); }
public static void RedSlimeTwoYCrossesXYY2Z_ProgenyACrossesY2Z_ProgenyBCrossesNoBreakpoints_TwoRedDamageTwoWhiteDamageHasDisabledBattleBots_Survived() { var players = new List <Player> { new Player(PlayerActionFactory.CreateSingleActionList(new PlayerActionType?[] { PlayerActionType.MoveBlue, PlayerActionType.Charlie, null, PlayerActionType.ChangeDeck, null, null, null, null, null, PlayerActionType.BattleBots }), 0, PlayerColor.Red), new Player(PlayerActionFactory.CreateSingleActionList(ComputerMaintenanceActions), 1, PlayerColor.Green) }; const TrackConfiguration internalTrack = TrackConfiguration.Track7; const int timeAppears = 4; const int blueDamage = 0; const int whiteDamage = 2; const int redDamage = 2; const bool isDefeated = false; const bool isSurvived = true; const bool battleBotsDisabled = true; SlimeBHelper(isDefeated, isSurvived, internalTrack, timeAppears, players, blueDamage, redDamage, whiteDamage, battleBotsDisabled); }
public static void RedSlimeNoYCrossesX_NoDamageHasDisabledBattleBots_Defeated() { var players = new List <Player> { new Player(PlayerActionFactory.CreateDoubleActionList(new PlayerActionType?[] { PlayerActionType.MoveBlue, PlayerActionType.Charlie, PlayerActionType.MoveRed, PlayerActionType.MoveRed, PlayerActionType.ChangeDeck, null, null, null, PlayerActionType.BattleBots, null, PlayerActionType.BattleBots, null }), 0, PlayerColor.Blue, PlayerSpecialization.EnergyTechnician), new Player(PlayerActionFactory.CreateSingleActionList(ComputerMaintenanceActions), 1, PlayerColor.Green) }; const TrackConfiguration internalTrack = TrackConfiguration.Track1; const int timeAppears = 3; const int blueDamage = 0; const int whiteDamage = 0; const int redDamage = 0; const bool isDefeated = true; const bool isSurvived = false; const bool battleBotsDisabled = true; SlimeBHelper(isDefeated, isSurvived, internalTrack, timeAppears, players, blueDamage, redDamage, whiteDamage, battleBotsDisabled); }
public static void RedSlimeTwoYCrossesXYY2_ProgenyACrossesY2_ProgenyBCrossesZ_TwoBlueDamageHasDisabledBattleBots_Survived() { var redPlayerActions = PlayerActionFactory.CreateDoubleActionList(new PlayerActionType?[] { PlayerActionType.MoveRed, PlayerActionType.ChangeDeck, PlayerActionType.Charlie, null, null, null, PlayerActionType.BattleBots, null, null, null, null, null, null, null, null, null, null, null, PlayerActionType.BattleBots, null }).ToList(); redPlayerActions.Add(new PlayerAction(PlayerActionType.MoveBlue, PlayerActionType.BattleBots, PlayerActionType.AdvancedSpecialization)); var players = new List <Player> { new Player(redPlayerActions, 0, PlayerColor.Red, PlayerSpecialization.SpecialOps), new Player(PlayerActionFactory.CreateSingleActionList(ComputerMaintenanceActions), 1, PlayerColor.Green) }; const TrackConfiguration internalTrack = TrackConfiguration.Track7; const int timeAppears = 4; const int blueDamage = 2; const int whiteDamage = 0; const int redDamage = 0; const bool isDefeated = false; const bool isSurvived = true; const bool battleBotsDisabled = false; SlimeBHelper(isDefeated, isSurvived, internalTrack, timeAppears, players, blueDamage, redDamage, whiteDamage, battleBotsDisabled); }
private static IList <Player> ParsePlayers(IList <string> chunk) { if (chunk.Count == 1) { throw new InvalidOperationException("Need at least one player"); } var players = new List <Player>(); var playerTokens = new Queue <string>(chunk.Skip(1)); if (playerTokens.Count % 3 != 0) { throw new InvalidOperationException("Invalid players."); } while (playerTokens.Any()) { var idToken = ParseToken(playerTokens.Dequeue()); if (idToken == null || idToken.Item1 != "player-index") { throw new InvalidOperationException("Error on player #" + players.Count + 1); } var index = TryParseInt(idToken.Item2); if (index == null) { throw new InvalidOperationException("Error on player #" + players.Count + 1); } var actionsToken = ParseToken(playerTokens.Dequeue()); if (actionsToken == null || actionsToken.Item1 != "actions") { throw new InvalidOperationException("Error on player #" + players.Count + 1); } var actions = ParsePlayerActions(actionsToken.Item2); if (actions == null) { throw new InvalidOperationException("Error on player #" + players.Count + 1); } var colorToken = ParseToken(playerTokens.Dequeue()); if (colorToken == null || colorToken.Item1 != "player-color") { throw new InvalidOperationException("Error on player # " + players.Count + 1); } var color = TryParseEnum <PlayerColor>(colorToken.Item2); if (color == null) { throw new InvalidOperationException("Error on player # " + players.Count + 1); } var player = new Player(PlayerActionFactory.CreateSingleActionList(actions), index.Value, color.Value); players.Add(player); //TODO: Add specializations and teleport player/destination } return(players); }
public static void RedSlimeOneYCrossesXYZ_ProgenyACrossesZ_TwoRedDamageTwoWhiteDamageHasDisabledBattleBots_Survived() { var players = new List <Player> { new Player(PlayerActionFactory.CreateSingleActionList(ComputerMaintenanceActions), 0, PlayerColor.Green) }; const TrackConfiguration internalTrack = TrackConfiguration.Track4; const int timeAppears = 3; const int blueDamage = 0; const int whiteDamage = 2; const int redDamage = 2; const bool isDefeated = false; const bool isSurvived = true; const bool battleBotsDisabled = true; SlimeBHelper(isDefeated, isSurvived, internalTrack, timeAppears, players, blueDamage, redDamage, whiteDamage, battleBotsDisabled); }
public static void Test_ShiftAfterPlayerActions_LastBlank() { var player = new Player(PlayerActionFactory.CreateSingleActionList(new PlayerActionType?[] { PlayerActionType.Alpha, PlayerActionType.Bravo, PlayerActionType.Charlie, PlayerActionType.ChangeDeck, null }), 0, PlayerColor.Blue); player.ShiftAfterPlayerActions(2); var expectedActions = PlayerActionFactory.CreateSingleActionList(new PlayerActionType?[] { PlayerActionType.Alpha, PlayerActionType.Bravo, null, PlayerActionType.Charlie, PlayerActionType.ChangeDeck }); AssertActionAreEqual(expectedActions.ToList(), player.Actions.ToList()); }
public static void Test_ShiftAndRepeatPreviousActionAfterPlayerActions_NoBlanks() { var player = new Player(PlayerActionFactory.CreateSingleActionList(new PlayerActionType?[] { PlayerActionType.Alpha, PlayerActionType.Bravo, PlayerActionType.BattleBots, PlayerActionType.Charlie, PlayerActionType.ChangeDeck }), 0, PlayerColor.Blue); player.ShiftAndRepeatPreviousActionAfterPlayerActions(3); var expectedActions = PlayerActionFactory.CreateSingleActionList(new PlayerActionType?[] { PlayerActionType.Alpha, PlayerActionType.Bravo, PlayerActionType.Bravo, PlayerActionType.BattleBots, PlayerActionType.Charlie }); AssertActionAreEqual(expectedActions.ToList(), player.Actions.ToList()); }
public static void Test_ShiftAndRepeatPreviousActionAfterPlayerActions_MultipleTimesConsecutiveTurns() { var player = new Player(PlayerActionFactory.CreateSingleActionList(new PlayerActionType?[] { PlayerActionType.Alpha, PlayerActionType.Bravo, PlayerActionType.Charlie, PlayerActionType.ChangeDeck, PlayerActionType.HeroicA }), 0, PlayerColor.Blue); player.ShiftAndRepeatPreviousActionAfterPlayerActions(3); player.ShiftAndRepeatPreviousActionAfterPlayerActions(4); var expectedActions = PlayerActionFactory.CreateSingleActionList(new PlayerActionType?[] { PlayerActionType.Alpha, PlayerActionType.Bravo, PlayerActionType.Bravo, PlayerActionType.Bravo, PlayerActionType.Charlie }); AssertActionAreEqual(expectedActions.ToList(), player.Actions.ToList()); }
public static void EzraCampaign1Mission3() { var players = new List <Player> { new Player(PlayerActionFactory.CreateSingleActionList(new PlayerActionType?[] { PlayerActionType.MoveBlue, null, PlayerActionType.BasicSpecialization, PlayerActionType.Alpha, PlayerActionType.Alpha, PlayerActionType.MoveRed, null, PlayerActionType.ChangeDeck, null, null, null, PlayerActionType.Charlie }), 0, PlayerColor.Blue, PlayerSpecialization.EnergyTechnician), new Player(PlayerActionFactory.CreateSingleActionList(new PlayerActionType?[] { null, PlayerActionType.MoveBlue, PlayerActionType.ChangeDeck, PlayerActionType.Alpha, PlayerActionType.Alpha, PlayerActionType.MoveRed, PlayerActionType.MoveRed, PlayerActionType.Alpha, PlayerActionType.MoveBlue, null, null, PlayerActionType.Charlie }), 1, PlayerColor.Green, PlayerSpecialization.PulseGunner), new Player(PlayerActionFactory.CreateSingleActionList(new PlayerActionType?[] { null, null, PlayerActionType.AdvancedSpecialization, PlayerActionType.MoveRed, PlayerActionType.BasicSpecialization, null, PlayerActionType.Alpha, PlayerActionType.Alpha, PlayerActionType.MoveBlue, PlayerActionType.ChangeDeck, null, PlayerActionType.Charlie }), 2, PlayerColor.Purple, PlayerSpecialization.Mechanic), new Player(PlayerActionFactory.CreateSingleActionList(new PlayerActionType?[] { PlayerActionType.Charlie, null, PlayerActionType.Alpha, PlayerActionType.BasicSpecialization, PlayerActionType.Alpha, PlayerActionType.Alpha, PlayerActionType.Alpha, PlayerActionType.Charlie, PlayerActionType.ChangeDeck, null, null, PlayerActionType.AdvancedSpecialization }), 3, PlayerColor.Red, PlayerSpecialization.DataAnalyst) }; var externalTracksByZone = new Dictionary <ZoneLocation, TrackConfiguration> { { ZoneLocation.Blue, TrackConfiguration.Track6 }, { ZoneLocation.Red, TrackConfiguration.Track2 }, { ZoneLocation.White, TrackConfiguration.Track5 }, }; const TrackConfiguration internalTrack = TrackConfiguration.Track3; var spacecraftCarrier = new SpacecraftCarrier(); spacecraftCarrier.SetInitialPlacement(4, ZoneLocation.Blue); var manOfWar = new ManOfWar(); manOfWar.SetInitialPlacement(5, ZoneLocation.White); var frigate = new Frigate(); frigate.SetInitialPlacement(7, ZoneLocation.Red); var externalThreats = new ExternalThreat[] { spacecraftCarrier, manOfWar, frigate }; var centralLaserJam = new CentralLaserJam(); centralLaserJam.SetInitialPlacement(3); var internalThreats = new InternalThreat[] { centralLaserJam }; var bonusThreats = new Threat[0]; var game = new Game(players, internalThreats, externalThreats, bonusThreats, externalTracksByZone, internalTrack, null); game.StartGame(); for (var currentTurn = 0; currentTurn < game.NumberOfTurns + 1; currentTurn++) { game.PerformTurn(); } Assert.AreEqual(GameStatus.Won, game.GameStatus); Assert.AreEqual(0, game.SittingDuck.BlueZone.TotalDamage); Assert.AreEqual(0, game.SittingDuck.RedZone.TotalDamage); Assert.AreEqual(0, game.SittingDuck.WhiteZone.TotalDamage); Assert.AreEqual(4, game.ThreatController.DefeatedThreats.Count()); Assert.AreEqual(0, game.ThreatController.SurvivedThreats.Count()); Assert.AreEqual(28 + 1 + 9, game.TotalPoints); Assert.AreEqual(0, players.Count(player => player.IsKnockedOut)); Assert.AreEqual(0, game.SittingDuck.Zones.ElementAt(0).CurrentDamageTokens.Count); Assert.AreEqual(0, game.SittingDuck.Zones.ElementAt(1).CurrentDamageTokens.Count); Assert.AreEqual(0, game.SittingDuck.Zones.ElementAt(2).CurrentDamageTokens.Count); }
public static void EzraCampaign1Mission2() { var players = new List <Player> { new Player(PlayerActionFactory.CreateSingleActionList(new PlayerActionType?[] { null, PlayerActionType.MoveBlue, PlayerActionType.BasicSpecialization, null, PlayerActionType.AdvancedSpecialization, PlayerActionType.ChangeDeck, PlayerActionType.Alpha, PlayerActionType.Alpha, null, null, null, null }), 0, PlayerColor.Blue, PlayerSpecialization.EnergyTechnician), new Player(PlayerActionFactory.CreateSingleActionList(new PlayerActionType?[] { PlayerActionType.MoveRed, PlayerActionType.BasicSpecialization, null, null, PlayerActionType.Alpha, PlayerActionType.Alpha, PlayerActionType.MoveBlue, PlayerActionType.BasicSpecialization, null, null, null, null }), 1, PlayerColor.Green, PlayerSpecialization.PulseGunner), new Player(PlayerActionFactory.CreateSingleActionList(new PlayerActionType?[] { PlayerActionType.MoveRed, PlayerActionType.ChangeDeck, PlayerActionType.Bravo, PlayerActionType.Alpha, PlayerActionType.Alpha, PlayerActionType.Alpha, null, null, null, null, null, null }), 2, PlayerColor.Purple), new Player(PlayerActionFactory.CreateSingleActionList(new PlayerActionType?[] { PlayerActionType.Charlie, null, null, PlayerActionType.BasicSpecialization, PlayerActionType.MoveBlue, PlayerActionType.Alpha, PlayerActionType.Alpha, PlayerActionType.MoveRed, PlayerActionType.BasicSpecialization, null, null, null }), 3, PlayerColor.Red, PlayerSpecialization.DataAnalyst) }; var externalTracksByZone = new Dictionary <ZoneLocation, TrackConfiguration> { { ZoneLocation.Blue, TrackConfiguration.Track1 }, { ZoneLocation.Red, TrackConfiguration.Track2 }, { ZoneLocation.White, TrackConfiguration.Track7 }, }; const TrackConfiguration internalTrack = TrackConfiguration.Track4; var dimensionSpider = new DimensionSpider(); dimensionSpider.SetInitialPlacement(6, ZoneLocation.Blue); var cryoshieldFrigate = new CryoshieldFrigate(); cryoshieldFrigate.SetInitialPlacement(4, ZoneLocation.Red); var energyCloud = new EnergyCloud(); energyCloud.SetInitialPlacement(1, ZoneLocation.Red); var externalThreats = new ExternalThreat[] { dimensionSpider, cryoshieldFrigate, energyCloud }; var battleBotUprising = new BattleBotUprising(); battleBotUprising.SetInitialPlacement(5); var internalThreats = new InternalThreat[] { battleBotUprising }; var bonusThreats = new Threat[0]; var game = new Game(players, internalThreats, externalThreats, bonusThreats, externalTracksByZone, internalTrack, null); game.StartGame(); for (var currentTurn = 0; currentTurn < game.NumberOfTurns + 1; currentTurn++) { game.PerformTurn(); } Assert.AreEqual(GameStatus.Won, game.GameStatus); Assert.AreEqual(0, game.SittingDuck.BlueZone.TotalDamage); Assert.AreEqual(0, game.SittingDuck.RedZone.TotalDamage); Assert.AreEqual(0, game.SittingDuck.WhiteZone.TotalDamage); Assert.AreEqual(3, game.ThreatController.DefeatedThreats.Count()); Assert.AreEqual(1, game.ThreatController.SurvivedThreats.Count()); Assert.AreEqual(20 + 4 + 2, game.TotalPoints); Assert.AreEqual(2, players.Count(player => player.IsKnockedOut)); Assert.AreEqual(0, game.SittingDuck.Zones.ElementAt(0).CurrentDamageTokens.Count); Assert.AreEqual(0, game.SittingDuck.Zones.ElementAt(1).CurrentDamageTokens.Count); Assert.AreEqual(0, game.SittingDuck.Zones.ElementAt(2).CurrentDamageTokens.Count); }
private static IList <Player> GetPlayers() { var players = new List <Player> { new Player(PlayerActionFactory.CreateSingleActionList(new PlayerActionType?[] { null, PlayerActionType.ChangeDeck, PlayerActionType.Bravo, PlayerActionType.ChangeDeck, PlayerActionType.Alpha, PlayerActionType.Alpha, PlayerActionType.Alpha, PlayerActionType.Alpha, PlayerActionType.Alpha, PlayerActionType.Alpha }), 0, PlayerColor.Blue), new Player(PlayerActionFactory.CreateSingleActionList(new PlayerActionType?[] { PlayerActionType.MoveRed, PlayerActionType.ChangeDeck, PlayerActionType.Charlie, PlayerActionType.ChangeDeck, null, PlayerActionType.Charlie, PlayerActionType.BattleBots, PlayerActionType.Charlie, PlayerActionType.BattleBots, PlayerActionType.Alpha }), 1, PlayerColor.Green), new Player(PlayerActionFactory.CreateSingleActionList(new PlayerActionType?[] { null, PlayerActionType.Charlie, null, null, PlayerActionType.Charlie, PlayerActionType.ChangeDeck, PlayerActionType.Charlie }), 2, PlayerColor.Purple), new Player(PlayerActionFactory.CreateSingleActionList(new PlayerActionType?[] { PlayerActionType.ChangeDeck, null, null, null, null, null, PlayerActionType.Charlie }), 3, PlayerColor.Red), new Player(PlayerActionFactory.CreateSingleActionList(new PlayerActionType?[] { null, PlayerActionType.ChangeDeck, null, null, null, null, PlayerActionType.Charlie }), 4, PlayerColor.Yellow), new Player(PlayerActionFactory.CreateSingleActionList(new PlayerActionType?[] { PlayerActionType.TeleportBlueLower, PlayerActionType.TeleportRedUpper, PlayerActionType.TeleportWhiteLower, PlayerActionType.TeleportWhiteUpper }), 5, PlayerColor.Blue) }; return(players); }