SubmittedMoveResponse MakeMoveAndDropCommon(SubmittedMoveResponse response, string moveStr) { response.Check = Current.Game.IsInCheck(Current.Game.WhoseTurn) ? Current.Game.WhoseTurn.ToString().ToLowerInvariant() : null; Checks.Add(response.Check); string fen = Current.Game.GetFen(); response.FEN = fen; FENs.Add(fen); Dictionary <string, int> pocket = Current.Game.GenerateJsonPocket(); response.Pocket = pocket; Pockets.Add(pocket); if (Current.Game.IsWinner(ChessUtilities.GetOpponentOf(Current.Game.WhoseTurn))) { PuzzleFinished(response, true); return(response); } if (!PossibleVariations.Any(x => CompareMoves(x.First(), moveStr) == 0)) { PuzzleFinished(response, false); return(response); } PossibleVariations = PossibleVariations.Where(x => CompareMoves(x.First(), moveStr) == 0).Select(x => x.Skip(1)); if (PossibleVariations.Any(x => x.Count() == 0)) { PuzzleFinished(response, true); return(response); } string moveToPlay = PossibleVariations.First().First(); if (!moveToPlay.Contains("@")) { string[] parts = moveToPlay.Split('-', '='); Current.Game.MakeMove(new Move(parts[0], parts[1], Current.Game.WhoseTurn, parts.Length == 2 ? null : new char?(parts[2][0])), true); } else { string[] parts = moveToPlay.Split('@'); CrazyhouseChessGame zhCurrent = Current.Game as CrazyhouseChessGame; Piece toDrop = zhCurrent.MapPgnCharToPiece(parts[0] == "" ? 'P' : parts[0][0], zhCurrent.WhoseTurn); Drop drop = new Drop(toDrop, new Position(parts[1]), zhCurrent.WhoseTurn); zhCurrent.ApplyDrop(drop, true); } response.Play = moveToPlay; Moves.Add(moveToPlay); response.FenAfterPlay = Current.Game.GetFen(); FENs.Add(response.FenAfterPlay); response.CheckAfterAutoMove = Current.Game.IsInCheck(Current.Game.WhoseTurn) ? Current.Game.WhoseTurn.ToString().ToLowerInvariant() : null; Checks.Add(response.CheckAfterAutoMove); response.Moves = Current.Game.GetValidMoves(Current.Game.WhoseTurn); response.Correct = 0; response.PocketAfterAutoMove = Current.Game.GenerateJsonPocket(); Pockets.Add(response.PocketAfterAutoMove); PossibleVariations = PossibleVariations.Select(x => x.Skip(1)); if (PossibleVariations.Any(x => !x.Any())) { PuzzleFinished(response, true); } return(response); }