Beispiel #1
0
        static void InitialPlacement(string piece, string color, ChessCoordinates coordinates)
        {
            ColumnCoordinates column = GetColumnFromChar(coordinates.Column);

            switch (piece)
            {
            case "Q":
                board[(coordinates.Row - 1), (column.GetHashCode())].Piece = new Queen();
                break;

            case "K":
                board[(coordinates.Row - 1), (column.GetHashCode())].Piece = new King();
                break;

            case "B":
                board[(coordinates.Row - 1), (column.GetHashCode())].Piece = new Bishop();
                break;

            case "N":
                board[(coordinates.Row - 1), (column.GetHashCode())].Piece = new Knight();
                break;

            case "R":
                board[(coordinates.Row - 1), (column.GetHashCode())].Piece = new Rook();
                break;

            case "P":
                board[(coordinates.Row - 1), (column.GetHashCode())].Piece = new Pawn();
                break;
            }
            board[(coordinates.Row - 1), (column.GetHashCode())].Piece.IsLight = (color == "White") ? true : false;
            Console.WriteLine("Yeet" + board[(coordinates.Row - 1), (column.GetHashCode())]);
        }
Beispiel #2
0
        static string ParsePieceMovement(string movement)
        {
            string output = "";

            ChessCoordinates cc1 = Coordinates(movement.Substring(0, 2));

            ChessCoordinates cc2 = Coordinates(movement.Substring(3));

            ColumnCoordinates col1 = GetColumnFromChar(cc1.Column);

            ColumnCoordinates col2 = GetColumnFromChar(cc2.Column);

            if (board[cc1.Row - 1, col1.GetHashCode()].Piece != null)
            {
                if (board[cc1.Row - 1, col1.GetHashCode()].Piece.ValidMovement(cc1, cc2))
                {
                    board[cc2.Row - 1, col2.GetHashCode()].Piece = board[cc1.Row - 1, col1.GetHashCode()].Piece;
                    board[cc1.Row - 1, col1.GetHashCode()].Piece = null;
                    output = $"The piece at {cc1.ToString()} has moved to {cc2.ToString()}.";
                }
                else
                {
                    output = "F**k you it didn't work";
                }
            }
            else
            {
                output = $"I'm not seeing a piece at {cc1.ToString()}";
            }


            return(output);
        }
Beispiel #3
0
        public static char GetCharFromColumn(ColumnCoordinates column)
        {
            switch (column)
            {
            case ColumnCoordinates.A:
                return('a');

            case ColumnCoordinates.B:
                return('b');

            case ColumnCoordinates.C:
                return('c');

            case ColumnCoordinates.D:
                return('d');

            case ColumnCoordinates.E:
                return('e');

            case ColumnCoordinates.F:
                return('f');

            case ColumnCoordinates.G:
                return('g');

            case ColumnCoordinates.H:
                return('h');
            }
            return('a');
        }