예제 #1
0
        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));
        }
예제 #2
0
        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()));
        }
예제 #3
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);
        }
예제 #4
0
        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))));
        }
예제 #5
0
 public void ExecuteAction(AGameTurn gameTurn)
 {
     if (_currentGame.CanBePlayed(gameTurn))
     {
         _currentGame.Play(gameTurn);
     }
     else
     {
         Debug.LogWarning("Can not play gameTurn " + gameTurn.GetType());
     }
 }
예제 #6
0
        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));
        }
예제 #7
0
        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));
        }