public void PlayAction_Rule() { var diceGame = new DiceGame(DiceGameSettings.CreateDefaultGameSettings()); var enemy = diceGame.CurrentBoard.Players.Find(p => p.PlayerStats.ID != diceGame.CurrentBoard.CurrentPlayer.PlayerStats.ID); var player = diceGame.CurrentBoard.CurrentPlayer; player.PlayerStats.ChangeAmmo(1, this); var board = diceGame.CurrentBoard; board.SetDices(new List <Dice> { new Dice(0, 3, diceGame.DiceGameSettings.DiceSettings), new Dice(1, 3, diceGame.DiceGameSettings.DiceSettings), new Dice(2, 3, diceGame.DiceGameSettings.DiceSettings), new Dice(3, 5, diceGame.DiceGameSettings.DiceSettings), }); board.GetDice(0).AddModifier(DiceModifier.Selected); board.GetDice(1).AddModifier(DiceModifier.Selected); board.GetDice(2).AddModifier(DiceModifier.Selected); diceGame.Play(new PlayAction(enemy.PlayerStats.ID)); var usedDices = board.GetUsedDices(); Assert.IsTrue(usedDices.Count == 3); Assert.IsTrue(usedDices[0].HasModifier(DiceModifier.Used)); Assert.IsTrue(usedDices[1].HasModifier(DiceModifier.Used)); Assert.IsTrue(usedDices[2].HasModifier(DiceModifier.Used)); Assert.IsTrue(player.PlayerStats.Ammo == 0); Assert.IsTrue(enemy.PlayerStats.Health == player.PlayerStats.MaxHealth - 3); }
public void PlayAction_AmmoChange_Both() { var diceGame = new DiceGame(DiceGameSettings.CreateDefaultGameSettings()); var player = diceGame.CurrentBoard.GetPlayer(0); var enemy = diceGame.CurrentBoard.GetPlayer(1); enemy.PlayerStats.ChangeAmmo(1, this); diceGame.CurrentBoard.SetDices(new List <Dice> { new Dice(0, 1, diceGame.DiceGameSettings.DiceSettings), new Dice(1, 1, diceGame.DiceGameSettings.DiceSettings), new Dice(2, 2, diceGame.DiceGameSettings.DiceSettings), new Dice(3, 4, diceGame.DiceGameSettings.DiceSettings), new Dice(4, 4, diceGame.DiceGameSettings.DiceSettings), new Dice(5, 6, diceGame.DiceGameSettings.DiceSettings) }); var playAction = new PlayAction(0); var selectAction1 = new SelectAction(new Dice(3)); var selectAction2 = new SelectAction(new Dice(4)); diceGame.Play(selectAction1); diceGame.Play(selectAction2); diceGame.Play(playAction); Assert.IsTrue(player.PlayerStats.Ammo == 1); Assert.IsTrue(enemy.PlayerStats.Ammo == 0); }
public void PlayAction_SelfTarget() { var diceGame = new DiceGame(DiceGameSettings.CreateDefaultGameSettings()); var player = diceGame.CurrentBoard.CurrentPlayer; var enemy = diceGame.CurrentBoard.EnemyPlayers[0]; enemy.PlayerStats.ChangeAmmo(1, this); diceGame.CurrentBoard.SetDices(new List <Dice> { new Dice(0, 1), new Dice(1, 1), new Dice(2, 2), new Dice(3, 3), new Dice(4, 4), new Dice(5, 5), }); var playAction = new PlayAction(player.PlayerStats.ID); var selectAction = new SelectAction(new Dice(3)); Assert.IsFalse(diceGame.CanBePlayed(playAction)); diceGame.Play(selectAction); diceGame.Play(playAction); Assert.IsTrue(player.PlayerStats.Health == player.PlayerStats.MaxHealth - 1); }
public void SaveAction_SavedDices() { var diceGame = new DiceGame(DiceGameSettings.CreateDefaultGameSettings()); diceGame.CurrentBoard.SetDices(new List <Dice> { new Dice(0, 4), new Dice(1, 4), new Dice(2, 4), new Dice(3, 4), new Dice(4, 4), }); var player = diceGame.CurrentBoard.Players.Find(p => p.PlayerStats.ID != diceGame.CurrentBoard.CurrentPlayer.PlayerStats.ID); var playAction = new SaveAction(); var selectAction = new SelectAction(new Dice(1)); diceGame.Play(selectAction); diceGame.Play(playAction); Assert.IsTrue(diceGame.CurrentBoard.Dices.Any(d => d.HasModifier(DiceModifier.Saved))); Assert.IsTrue(diceGame.CurrentBoard.Dices.Any(d => !d.HasModifier(DiceModifier.CanBeRerolled))); diceGame.Play(new RerollTurn()); }
public void SaveAction_InvalidSaveNumbers() { var diceGame = new DiceGame(DiceGameSettings.CreateDefaultGameSettings()); diceGame.CurrentBoard.SetDices(new List <Dice> { new Dice(0, 1), new Dice(1, 2), new Dice(2, 3), new Dice(3, 4), new Dice(4, 5), }); var player = diceGame.CurrentBoard.Players.Find(p => p.PlayerStats.ID != diceGame.CurrentBoard.CurrentPlayer.PlayerStats.ID); var saveAction = new SaveAction(); var selectAction1 = new SelectAction(new Dice(1)); var unselectAction = new UnselectAction(new Dice(1)); var selectAction5 = new SelectAction(new Dice(4)); diceGame.Play(selectAction1); Assert.IsFalse(diceGame.CanBePlayed(saveAction)); diceGame.Play(selectAction5); Assert.IsTrue(diceGame.CanBePlayed(saveAction)); diceGame.Play(unselectAction); Assert.IsTrue(diceGame.CanBePlayed(saveAction)); }
public void PlayAction_Rule() { var diceGame = new DiceGame(DiceGameSettings.CreateDefaultGameSettings()); var enemy = diceGame.CurrentBoard.Players.Find(p => p.PlayerStats.ID != diceGame.CurrentBoard.CurrentPlayer.PlayerStats.ID); var player = diceGame.CurrentBoard.CurrentPlayer; Assert.IsTrue(diceGame.CanBePlayed(new RerollTurn())); diceGame.Play(new RerollTurn()); Assert.IsTrue(diceGame.CanBePlayed(new RerollTurn())); diceGame.Play(new RerollTurn()); Assert.IsFalse(diceGame.CanBePlayed(new RerollTurn())); diceGame.Play(new EndRound()); Assert.IsTrue(diceGame.CanBePlayed(new RerollTurn())); }
public void Move_SelectionPossible() { var diceGame = new DiceGame(DiceGameSettings.CreateDefaultGameSettings()); var enemy = diceGame.CurrentBoard.Players.Find(p => p.PlayerStats.ID != diceGame.CurrentBoard.CurrentPlayer.PlayerStats.ID); var player = diceGame.CurrentBoard.CurrentPlayer; diceGame.CurrentBoard.SetDices(new List <Dice> { new Dice(0, 1, diceGame.DiceGameSettings.DiceSettings), new Dice(1, 1, diceGame.DiceGameSettings.DiceSettings), new Dice(2, 1, diceGame.DiceGameSettings.DiceSettings), new Dice(3, 1, diceGame.DiceGameSettings.DiceSettings), new Dice(4, 1, diceGame.DiceGameSettings.DiceSettings), new Dice(5, 1, diceGame.DiceGameSettings.DiceSettings) }); Assert.IsTrue(diceGame.CanBePlayed(new RerollTurn())); diceGame.Play(new RerollTurn()); diceGame.CurrentBoard.SetDices(new List <Dice> { new Dice(0, 1, diceGame.DiceGameSettings.DiceSettings), new Dice(1, 1, diceGame.DiceGameSettings.DiceSettings), new Dice(2, 1, diceGame.DiceGameSettings.DiceSettings), new Dice(3, 1, diceGame.DiceGameSettings.DiceSettings), new Dice(4, 1, diceGame.DiceGameSettings.DiceSettings), new Dice(5, 1, diceGame.DiceGameSettings.DiceSettings) }); Assert.IsTrue(diceGame.CanBePlayed(new RerollTurn())); diceGame.Play(new RerollTurn()); diceGame.CurrentBoard.SetDices(new List <Dice> { new Dice(0, 1, diceGame.DiceGameSettings.DiceSettings), new Dice(1, 1, diceGame.DiceGameSettings.DiceSettings), new Dice(2, 1, diceGame.DiceGameSettings.DiceSettings), new Dice(3, 1, diceGame.DiceGameSettings.DiceSettings), new Dice(4, 1, diceGame.DiceGameSettings.DiceSettings), new Dice(5, 1, diceGame.DiceGameSettings.DiceSettings) }); Assert.IsTrue(diceGame.CanBePlayed(new SelectAction(new Dice(0)))); }
public void PlayAction_Valid() { var diceGame = new DiceGame(DiceGameSettings.CreateDefaultGameSettings()); diceGame.CurrentBoard.SetDices(new List <Dice> { new Dice(0, 1, diceGame.DiceGameSettings.DiceSettings), new Dice(1, 1, diceGame.DiceGameSettings.DiceSettings), new Dice(2, 2, diceGame.DiceGameSettings.DiceSettings), new Dice(3, 3, diceGame.DiceGameSettings.DiceSettings), new Dice(4, 4, diceGame.DiceGameSettings.DiceSettings), new Dice(5, 6, diceGame.DiceGameSettings.DiceSettings) }); var playAction = new PlayAction(0); var selectAction = new SelectAction(new Dice(1)); diceGame.Play(selectAction); Assert.IsTrue(diceGame.CurrentBoard.Players.TrueForAll(p => p.PlayerStats.Health < p.PlayerStats.MaxHealth)); }
public void Dice_Board() { var diceGame = new DiceGame(DiceGameSettings.CreateDefaultGameSettings()); diceGame.CurrentBoard.SetDices(new List <Dice> { new Dice(0, 4), new Dice(1, 4), new Dice(2, 4), new Dice(3, 4), new Dice(4, 4), new Dice(5, 4), }); var selectAction = new SelectAction(new Dice(1)); Assert.IsTrue(diceGame.CanBePlayed(selectAction)); diceGame.Play(selectAction); Assert.IsFalse(diceGame.CanBePlayed(selectAction)); }
public void PlayAction_Valid() { var diceGame = new DiceGame(DiceGameSettings.CreateDefaultGameSettings()); diceGame.CurrentBoard.SetDices(new List <Dice> { new Dice(0, 1), new Dice(1, 1), new Dice(2, 2), new Dice(3, 3), new Dice(4, 4), new Dice(5, 5), }); var playAction = new PlayAction(0); var selectAction = new SelectAction(new Dice(1)); Assert.IsFalse(diceGame.CanBePlayed(playAction)); diceGame.Play(selectAction); Assert.IsTrue(diceGame.CanBePlayed(playAction)); }
private void Awake() { GameManager.Instance.InitGame(new DiceGame(DiceGameSettings.CreateDefaultGameSettings())); }