Esempio n. 1
0
        public void TestMovePieceStrategyTwoDice()
        {
            var player = this.app.GetGameFactory().CreatePlayer("Player 1");
            var enemy = this.app.GetGameFactory().CreatePlayer("Player 2");
            var dice = new[] { new DefaultDie(false, 4), new DefaultDie(true, 3), new DefaultDie(false, 2), new DefaultDie(false, 1) };
            var turn = new DefaultTurn(player, dice);
            var context = new DefaultGameRuleStrategyContext();
            var board = this.CreateDefaultBoard();
            board.Lanes[20].Add(new DefaultPiece(player));
            board.Lanes[21].Add(new DefaultPiece(enemy));
            var strategy = new MovePieceStrategy();

            var moves = this.CallGetStrategyValidMoves(strategy, board, turn, context);
            context.IsDone.Should().BeFalse("the strategy should never short-circuit");
            moves.Count.Should().Be(2, "there should be two available moves");
            moves[0].Die.Should().BeSameAs(dice[2], "die with value 2 is unused");
            moves[0].Lane.Should().BeSameAs(board.Lanes[20], "there is only one piece for this player");
            moves[0].LaneIndex.Should().Be(20, "the player's only piece is on that lane");
            moves[1].Die.Should().BeSameAs(dice[3], "die with value 1 is unused and the target has only 1 enemy piece");
            moves[1].Lane.Should().BeSameAs(board.Lanes[20], "there is only one piece for this player");
            moves[1].LaneIndex.Should().Be(20, "the player's only piece is on that lane");

            var piece = board.Lanes[20][0];
            var enemyPiece = board.Lanes[21][0];
            strategy.MovePiece(player, board, moves[1]);
            board.Bar.Should().ContainSingle("the enemy piece should have been moved to the bar");
            board.Bar[0].Should().BeSameAs(enemyPiece, "the enemy piece should be the same as the removed one");
            board.Lanes[21].Should().ContainSingle("the piece should have been moved to this lane");
            board.Lanes[21][0].Should().BeSameAs(piece, "the moved piece should be the same as the selected one");
        }
Esempio n. 2
0
        public void TestMovePieceStrategyZeroDice()
        {
            var player = this.app.GetGameFactory().CreatePlayer("Player 1");
            var enemy = this.app.GetGameFactory().CreatePlayer("Player 2");
            var dice = new[] { new DefaultDie(true, 2), new DefaultDie(false, 1) };
            var turn = new DefaultTurn(player, dice);
            var context = new DefaultGameRuleStrategyContext();
            var board = this.CreateDefaultBoard();
            board.Lanes[0].Add(new DefaultPiece(player));
            board.Lanes[0].Add(new DefaultPiece(player));
            board.Lanes[1].Add(new DefaultPiece(enemy));
            board.Lanes[1].Add(new DefaultPiece(enemy));
            var strategy = new MovePieceStrategy();

            var moves = this.CallGetStrategyValidMoves(strategy, board, turn, context);
            context.IsDone.Should().BeFalse("the strategy should never short-circuit");
            moves.Should().BeEmpty("there should be no moves available");
        }
Esempio n. 3
0
        public void TestMovePieceStrategyOneDie()
        {
            var player = this.app.GetGameFactory().CreatePlayer("Player 1");
            var enemy = this.app.GetGameFactory().CreatePlayer("Player 2");
            var dice = new[] { new DefaultDie(false, 2), new DefaultDie(false, 1) };
            var turn = new DefaultTurn(player, dice);
            var context = new DefaultGameRuleStrategyContext();
            var board = this.CreateDefaultBoard();
            board.Lanes[0].Add(new DefaultPiece(player));
            board.Lanes[0].Add(new DefaultPiece(player));
            board.Lanes[1].Add(new DefaultPiece(enemy));
            board.Lanes[1].Add(new DefaultPiece(enemy));
            var strategy = new MovePieceStrategy();

            var moves = this.CallGetStrategyValidMoves(strategy, board, turn, context);
            context.IsDone.Should().BeFalse("the strategy should never short-circuit");
            moves.Should().ContainSingle("there should be one available move because only one dice is unused");
            moves[0].Die.Should().BeSameAs(dice[0], "only die with value 2 is usable");
            moves[0].Lane.Should().BeSameAs(board.Lanes[0], "there is only one piece for this player");
            moves[0].LaneIndex.Should().Be(0, "the player's only piece is on that lane");

            var piece = board.Lanes[0][1];
            strategy.MovePiece(player, board, moves[0]);
            board.Lanes[0].Should().ContainSingle("the other piece should not have been moved");
            board.Lanes[2].Should().ContainSingle("the piece should have been moved to this lane");
            board.Lanes[2][0].Should().BeSameAs(piece, "the moved piece should be the same as the selected one");
        }