示例#1
0
        public override bool[,] PossibleMovements()
        {
            bool[,] movements = new bool[ChessBoard.Lines, ChessBoard.Columns];
            Position[] positions = new Position[4];

            if (Color.Equals(Color.White))
            {
                positions[0] = (new Position(Position.Line - 1, Position.Column));
                positions[1] = Movements.Equals(0) ? (new Position(Position.Line - 2, Position.Column)) : null;
                positions[2] = (new Position(Position.Line - 1, Position.Column + 1));
                positions[3] = (new Position(Position.Line - 1, Position.Column - 1));
            }
            else
            {
                positions[0] = (new Position(Position.Line + 1, Position.Column));
                positions[1] = Movements.Equals(0) ? (new Position(Position.Line + 2, Position.Column)) : null;
                positions[2] = (new Position(Position.Line + 1, Position.Column + 1));
                positions[3] = (new Position(Position.Line + 1, Position.Column - 1));
            }

            for (var c = 0; c < positions.Length; c++)
            {
                var currentPosition = positions[c];

                if (currentPosition != null && ChessBoard.IsValidPosition(currentPosition))
                {
                    if (c < 2)
                    {
                        if (CanMove(currentPosition))
                        {
                            movements[currentPosition.Line, currentPosition.Column] = true;
                        }
                    }
                    else
                    {
                        if (ChessBoard.HasEnemy(currentPosition, ChessMatch.Adversary(Color)))
                        {
                            movements[currentPosition.Line, currentPosition.Column] = true;
                        }
                    }
                }
            }

            return(movements);
        }
示例#2
0
 public King(Color color, Board board, ChessMatch match) : base(color, board)
 {
     Match = match;
 }
示例#3
0
 public Peon(Board board, Color color, ChessMatch match) : base(board, color)
 {
     Match = match;
 }
示例#4
0
 public Pawn(Color color, Board board, ChessMatch match) : base(color, board)
 {
     chessMatch = match;
 }