static string ParsePieceMovement(string movement) { string output = ""; BoardLogic.ChessCoordinates cc1 = BoardLogic.Coordinates(movement.Substring(0, 2)); BoardLogic.ChessCoordinates cc2 = BoardLogic.Coordinates(movement.Substring(3)); BoardLogic.ColumnCoordinates col1 = GetColumnFromChar(cc1.Column); BoardLogic.ColumnCoordinates col2 = GetColumnFromChar(cc2.Column); if (Program.board[cc1.Row - 1, col1.GetHashCode()].Piece != null) { if (Program.board[cc1.Row - 1, col1.GetHashCode()].Piece.ValidMovement(cc1, cc2)) { Program.board[cc2.Row - 1, col2.GetHashCode()].Piece = Program.board[cc1.Row - 1, col1.GetHashCode()].Piece; Program.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); }
public static char GetCharFromColumn(BoardLogic.ColumnCoordinates column) { switch (column) { case BoardLogic.ColumnCoordinates.A: return('a'); case BoardLogic.ColumnCoordinates.B: return('b'); case BoardLogic.ColumnCoordinates.C: return('c'); case BoardLogic.ColumnCoordinates.D: return('d'); case BoardLogic.ColumnCoordinates.E: return('e'); case BoardLogic.ColumnCoordinates.F: return('f'); case BoardLogic.ColumnCoordinates.G: return('g'); case BoardLogic.ColumnCoordinates.H: return('h'); } return('a'); }
static void InitialPlacement(string piece, string color, BoardLogic.ChessCoordinates coordinates) { BoardLogic.ColumnCoordinates column = GetColumnFromChar(coordinates.Column); switch (piece) { case "Q": Program.board[(coordinates.Row - 1), (column.GetHashCode())].Piece = new Models.Queen(); break; case "K": Program.board[(coordinates.Row - 1), (column.GetHashCode())].Piece = new Models.King(); break; case "B": Program.board[(coordinates.Row - 1), (column.GetHashCode())].Piece = new Models.Bishop(); break; case "N": Program.board[(coordinates.Row - 1), (column.GetHashCode())].Piece = new Models.Knight(); break; case "R": Program.board[(coordinates.Row - 1), (column.GetHashCode())].Piece = new Models.Rook(); break; case "P": Program.board[(coordinates.Row - 1), (column.GetHashCode())].Piece = new Models.Pawn(); break; } Program.board[(coordinates.Row - 1), (column.GetHashCode())].Piece.IsLight = (color == "White") ? true : false; }