//Начать партию(начальные условия в json строке) public void StartGame(string fen = @"{ 'PiecePosition': 'rnbqkbnr/1ppppppP/8/pP1P1P1P/2B5/3B4/8/RNBQK2R','InGameColor':'white','Castling': 'KQkq','EnPassant': 'a6','HalfMoveClock': 0,'MoveNumber': 1 }", string playerColor = "none") { Color color = Color.none; if (playerColor == "white" || playerColor == "White") { color = Color.white; } else if (playerColor == "black" || playerColor == "Black") { color = Color.black; } game.StartGame(fen, color); player1 = game.player1; player2 = game.player2; desk = game.desk; moves = game.moves; }
//Начать партию internal void StartGame(string fen, Color playerColor) { notation = JsonConvert.DeserializeObject <ForsythEdwardsNotation>(fen); inGameColor = notation.InGameColor; moveNumber = notation.MoveNumber; desk = new Desk(notation); moves = new Moves(desk); if (playerColor == Color.none) { Color[] colors = new Color[2] { Color.white, Color.black }; playerColor = colors[rnd.Next(0, 2)]; } player1 = new Gamer(playerColor, moves, desk); player2 = new Bot(playerColor.FlipColor(), moves, desk); moves.InitMoves(); }