public void AddFigureToBoard(IPlayer firstPlayser, IPlayer secondPlayer, IBoard board, string fen) { var splitedFen = fen.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries); var index = 0; for (int row = splitedFen.Length - 1; row >= 0; row--) { var currentRow = this.MakeRow(splitedFen[row]); for (int col = 0; col < currentRow.Length; col++) { if (currentRow[col] == Pown) { var pawn = new Pawn(secondPlayer.Color); secondPlayer.AddFigure(pawn); var position = new Position(index + 1, (char)(col + 'a')); board.AddFigure(pawn, position); } else if (currentRow[col] == King) { var figureInstance = new King(firstPlayser.Color); firstPlayser.AddFigure(figureInstance); var position = new Position(index + 1, (char)(col + 'a')); board.AddFigure(figureInstance, position); } } index++; } }
private void AddPawnsToBoardRow(IPlayer player, IBoard board, int chessRow) { for (int i = 0; i < GlobalConstants.StandartGameTotalBoardCols - 2; i += 2) { var pawn = new Pawn(player.Color); player.AddFigure(pawn); var position = new Position(chessRow, (char)(i + 'a')); board.AddFigure(pawn, position); } // TODO: Remove //// For testing only //var pawn = new Pawn(player.Color); //player.AddFigure(pawn); //var position = new Position(8, (char)(0 + 'a')); //board.AddFigure(pawn, position); //pawn = new Pawn(player.Color); //player.AddFigure(pawn); //position = new Position(8, (char)(2 + 'a')); //board.AddFigure(pawn, position); //pawn = new Pawn(player.Color); //player.AddFigure(pawn); //position = new Position(8, (char)(4 + 'a')); //board.AddFigure(pawn, position); //pawn = new Pawn(player.Color); //player.AddFigure(pawn); //position = new Position(6, (char)(4 + 'a')); //board.AddFigure(pawn, position); }
private void AddPawnsToBoardRow(IPlayer player, IBoard board, int chessRow) { for (int i = 0; i < GlobalConstants.StandartGameTotalBoardCols; i++) { var pawn = new Pawn(player.Color); player.AddFigure(pawn); var position = new Position(chessRow, (char)(i + 'a')); board.AddFigure(pawn, position); } }