示例#1
0
        public void PerformsMove(Position origin, Position destiny)
        {
            Piece captPiece = RunMoviment(origin, destiny);

            if (OnCheck(CurrentPlayer))
            {
                UndoMoviment(origin, destiny, captPiece);
                throw new BoardException("You can't put yourself in check");
            }
            Piece p = ChessBoard.PiecePosition(destiny);

            //#jogada especial promocao
            if (p is Pawn)
            {
                if ((p.Color == Color.Branca && destiny.Line == 0) || (p.Color == Color.Preta && destiny.Line == 8))
                {
                    p = ChessBoard.RemovePiece(destiny);
                    FreePieces.Remove(p);
                    Piece queen = new Queen(ChessBoard, p.Color);
                    ChessBoard.InsertPiece(queen, destiny);
                    FreePieces.Add(queen);
                }
            }
            //

            if (OnCheck(adversary(CurrentPlayer)))
            {
                GameInCheck = true;
            }
            else
            {
                GameInCheck = false;
            }

            if (TestCheckMate(adversary(CurrentPlayer)))
            {
                Finished = true;
            }
            else
            {
                Shift++;
                ChangePlayer();
            }
            //#jogada especial EnPassant
            if (p is Pawn && (destiny.Line == origin.Line - 2 || destiny.Line == origin.Line + 2))
            {
                VulnerableForEnPassant = p;
            }
            else
            {
                VulnerableForEnPassant = null;
            }
        }
示例#2
0
 public void PutNewPiece(char column, int line, Piece piec)
 {
     ChessBoard.InsertPiece(piec, new ChessPosition(column, line).toPosition());
     FreePieces.Add(piec);
 }