public override void FromJson(JObject json) { var wId = json["white"].ToObject <int>(); var bId = json["black"].ToObject <int>(); if (wId != 0) { White = StartForm.GetPlayer(wId); } if (bId != 0) { Black = StartForm.GetPlayer(bId); } Waiting = json["wait"].ToObject <PlayerSide>(); if (json.ContainsKey("board")) { var board = json["board"]; var BOARD = StartForm.INSTANCE.GameForm.Board; foreach (var side in new PlayerSide[] { PlayerSide.White, PlayerSide.Black }) { var content = board[side.ToString()]; var PIECES = BOARD.Pieces[side]; foreach (JProperty pieceMoved in content.Children()) { var id = int.Parse(pieceMoved.Name.Substring("P#".Length)); var piece = PIECES.FirstOrDefault(x => x.Id == id); if (piece.Location != null) { piece.Location.PieceHere = null; } var info = pieceMoved.ToObject <string>().Split('/'); var location = info[0]; if (location == "null") { // piece was taken piece.Location = null; } else { piece.Location = BOARD.GetButtonAt(location); piece.Location.PieceHere = piece; } if (info.Length > 1) { if (Enum.TryParse <PieceType>(info[1], out var type)) { piece.Type = type; } } } } } }