Exemplo n.º 1
0
        public void OpponentPiecesTakenTest()
        {
            var pieceColour = PieceColour.White;
            var pieceRank   = PieceRank.Minion;
            int x           = 2;
            int y           = 0;

            var startGamePiece    = new GamePiece(pieceColour, pieceRank, x, y);
            var endGamePiece      = new GamePiece(pieceColour, pieceRank, x + 2, y + 2);
            var blockingGamePiece = new GamePiece(PieceColour.Black, pieceRank, x + 1, y + 1);
            var gameState         = GameStateFactory.SeveralPieceGameState(startGamePiece, blockingGamePiece);


            var move = new GameMove(startGamePiece, endGamePiece, new[] { blockingGamePiece }, gameState);

            var metrics = move.CalculateGameMoveMetrics(PieceColour.White);

            Assert.AreEqual(1, metrics.OpponentPiecesTaken);
        }
Exemplo n.º 2
0
        public void SinglePieceWhiteKingOnLastRowAfterDoubleJumpCheckMoveObjects()
        {
            var pieceColour = PieceColour.White;
            var pieceRank   = PieceRank.King;
            int x           = 3;
            int y           = 7;

            var gamePiece          = new GamePiece(pieceColour, pieceRank, x, y);
            var blockingGamePiece1 = new GamePiece(PieceColour.Black, pieceRank, 4, 6);
            var blockingGamePiece2 = new GamePiece(PieceColour.Black, pieceRank, 6, 6);
            var gameState          = GameStateFactory.SeveralPieceGameState(gamePiece, blockingGamePiece1, blockingGamePiece2);

            var moves = gameState.CalculateAvailableMoves().Where(m => m.StartGamePiece.PieceColour == PieceColour.White).ToList();

            var expectedPiece = new GamePiece(PieceColour.White, PieceRank.King, 7, 7);

            Assert.AreEqual(2, moves.First().TakenGamePieces.Count);
            Assert.AreEqual(gamePiece, moves.First().StartGamePiece);
            Assert.AreEqual(expectedPiece, moves.First().EndGamePiece);
        }
Exemplo n.º 3
0
        public void SinglePieceWhiteTakePerformMove()
        {
            var pieceColour = PieceColour.White;
            var pieceRank   = PieceRank.Minion;
            int x           = 2;
            int y           = 0;

            var gamePiece         = new GamePiece(pieceColour, pieceRank, x, y);
            var blockingGamePiece = new GamePiece(PieceColour.Black, pieceRank, x + 1, y + 1);
            var gameState         = GameStateFactory.SeveralPieceGameState(gamePiece, blockingGamePiece);

            var moves = gameState.CalculateAvailableMoves().Where(m => m.StartGamePiece.PieceColour == PieceColour.White).ToList();

            var afterState = moves.First().PerformMove();

            Assert.AreEqual(1, afterState.GamePieceList.Count);

            Assert.AreEqual(x + 2, afterState.GamePieceList[0].Xcoord);
            Assert.AreEqual(y + 2, afterState.GamePieceList[0].Ycoord);
        }
Exemplo n.º 4
0
        public void SinglePieceWhiteBlockedGameMove()
        {
            var pieceColour = PieceColour.White;
            var pieceRank   = PieceRank.Minion;
            int x           = 2;
            int y           = 0;

            var gamePiece         = new GamePiece(pieceColour, pieceRank, x, y);
            var blockingGamePiece = new GamePiece(pieceColour, pieceRank, x + 1, y + 1);
            var gameState         = GameStateFactory.SeveralPieceGameState(gamePiece, blockingGamePiece);

            var moves = gameState.CalculateAvailableMoves();

            var piece1 = moves[0].EndGamePiece;

            Assert.AreEqual(3, moves.Count);

            Assert.AreEqual(x - 1, piece1.Xcoord);
            Assert.AreEqual(y + 1, piece1.Ycoord);
        }
Exemplo n.º 5
0
        public void SinglePieceWhiteTakeStraightCrookedGameMove()
        {
            var pieceColour = PieceColour.White;
            var pieceRank   = PieceRank.Minion;
            int x           = 2;
            int y           = 0;

            var gamePiece          = new GamePiece(pieceColour, pieceRank, x, y);
            var blockingGamePiece1 = new GamePiece(PieceColour.Black, pieceRank, x + 1, y + 1);
            var blockingGamePiece2 = new GamePiece(PieceColour.Black, pieceRank, x + 1, y + 3);
            var gameState          = GameStateFactory.SeveralPieceGameState(gamePiece, blockingGamePiece1, blockingGamePiece2);

            var moves = gameState.CalculateAvailableMoves().Where(m => m.StartGamePiece.PieceColour == PieceColour.White).ToList();

            var piece1 = moves[0].EndGamePiece;

            Assert.AreEqual(1, moves.Count);

            Assert.AreEqual(x, piece1.Xcoord);
            Assert.AreEqual(y + 4, piece1.Ycoord);
        }
Exemplo n.º 6
0
        public void SinglePieceWhiteKingOnLastRowAfterJump()
        {
            var pieceColour = PieceColour.White;
            var pieceRank   = PieceRank.Minion;
            int x           = 0;
            int y           = 5;

            var gamePiece         = new GamePiece(pieceColour, pieceRank, x, y);
            var blockingGamePiece = new GamePiece(PieceColour.Black, pieceRank, 1, 6);
            var gameState         = GameStateFactory.SeveralPieceGameState(gamePiece, blockingGamePiece);

            var moves = gameState.CalculateAvailableMoves().Where(m => m.StartGamePiece.PieceColour == PieceColour.White).ToList();

            var afterState = moves.First().PerformMove();

            var expectedPiece = new GamePiece(PieceColour.White, PieceRank.King, 2, 7);

            Assert.AreEqual(1, afterState.GamePieceList.Count);

            Assert.AreEqual(expectedPiece, afterState.GamePieceList[0]);
        }