// Performs initial setup of the board //TODO: Test DaiShogi public static void SetUpBoard() { string board = ""; //Chess on a Really Big Board Setup switch (GameType) { case GameTypes.Chess: board = File.ReadAllText(Path.Combine( AppDomain.CurrentDomain.BaseDirectory, "vanilla-chess.json")); break; case GameTypes.CRRB: board = File.ReadAllText(Path.Combine( AppDomain.CurrentDomain.BaseDirectory, "chess-on-a-really-big-board.json")); break; case GameTypes.Shogi: board = File.ReadAllText(Path.Combine( AppDomain.CurrentDomain.BaseDirectory, "shogi.json")); break; case GameTypes.ChuShogi: throw new NotImplementedException(); board = File.ReadAllText(Path.Combine( AppDomain.CurrentDomain.BaseDirectory, "chu-shogi.json")); break; case GameTypes.DaiShogi: board = File.ReadAllText(Path.Combine( AppDomain.CurrentDomain.BaseDirectory, "dai-shogi.json")); break; case GameTypes.Testing: BoardSize = 16; _board[0, 1] = PieceFactory.GetPiece(PieceTypes.Pawn, Teams.White); break; default: throw new ArgumentOutOfRangeException(); } LoadBoard(board); //TODO: Chu Shogi }
static Board() { switch (GameType) { case GameTypes.Chess: BoardSize = 8; break; case GameTypes.CRRB: BoardSize = 16; break; case GameTypes.Shogi: BoardSize = 9; break; case GameTypes.ChuShogi: BoardSize = 12; break; case GameTypes.DaiShogi: BoardSize = 15; break; case GameTypes.Testing: BoardSize = 16; break; default: throw new ArgumentOutOfRangeException(); } _board = new Piece[BoardSize, BoardSize]; for (sbyte x = 0; x < BoardSize; x++) { for (sbyte y = 0; y < BoardSize; y++) { _board[x, y] = PieceFactory.GetPiece(PieceTypes.Undefined); } } }
//Todo Test public override IEnumerable <sbyte> Move(sbyte coords) { var currentX = GetX(coords); var currentY = GetY(coords); var team = Board._board[currentX, currentY].Team; var possibles = new HashSet <sbyte> { //camel GetCoords((sbyte)(currentX + 3), (sbyte)(currentY + 1)), GetCoords((sbyte)(currentX + 3), (sbyte)(currentY - 1)), GetCoords((sbyte)(currentX - 3), (sbyte)(currentY + 1)), GetCoords((sbyte)(currentX - 3), (sbyte)(currentY - 1)), GetCoords((sbyte)(currentX + 1), (sbyte)(currentY + 3)), GetCoords((sbyte)(currentX + 1), (sbyte)(currentY - 3)), GetCoords((sbyte)(currentX - 1), (sbyte)(currentY + 3)), GetCoords((sbyte)(currentX - 1), (sbyte)(currentY - 3)), //Zebra GetCoords((sbyte)(currentX + 3), (sbyte)(currentY + 2)), GetCoords((sbyte)(currentX + 3), (sbyte)(currentY - 2)), GetCoords((sbyte)(currentX - 3), (sbyte)(currentY + 2)), GetCoords((sbyte)(currentX - 3), (sbyte)(currentY - 2)), GetCoords((sbyte)(currentX + 2), (sbyte)(currentY + 3)), GetCoords((sbyte)(currentX + 2), (sbyte)(currentY - 3)), GetCoords((sbyte)(currentX - 2), (sbyte)(currentY + 3)), GetCoords((sbyte)(currentX - 2), (sbyte)(currentY - 3)) }; var moves = (HashSet <sbyte>)PieceFactory.GetPiece(PieceTypes.Knight, team) .Move(coords); foreach (var move in possibles) { if (!AttackingAllies(GetX(move), GetY(move), team) && WithinBounds(GetX(move), GetY(move))) { moves.Add(move); } } return(moves); }