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 AddKingToBoardRow(IPlayer player, IBoard board, int chessRow, char chessCol)
 {
     var figureInstance = new King(player.Color);
         player.AddFigure(figureInstance);
         var position = new Position(chessRow, chessCol);
         board.AddFigure(figureInstance, position);
 }
コード例 #3
0
        private bool CheckKingToOptions(Position to)
        {
            var chessColor = ChessColor.White;
            var king = new King(chessColor);

            try
            {
                this.CheckIfToPositionIsEmpty(king, to);
            }
            catch (Exception)
            {
                return false;
                throw;
            }

            return true;
        }