Fix toJson
This commit is contained in:
@@ -42,9 +42,9 @@ fun Game.toJson() = Json.Object(
|
|||||||
|
|
||||||
fun Game.Companion.fromJson(json: Json.Object) = Game(
|
fun Game.Companion.fromJson(json: Json.Object) = Game(
|
||||||
id = json.getID("id") ?: throw Error("missing game id"),
|
id = json.getID("id") ?: throw Error("missing game id"),
|
||||||
white = json.getID("white") ?: throw Error("missing white player"),
|
white = json.getID("w") ?: throw Error("missing white player"),
|
||||||
black = json.getID("black") ?: throw Error("missing black player"),
|
black = json.getID("b") ?: throw Error("missing black player"),
|
||||||
handicap = json.getInt("handicap") ?: 0,
|
handicap = json.getInt("h") ?: 0,
|
||||||
result = json.getChar("result")?.let { Game.Result.fromSymbol(it) } ?: UNKNOWN,
|
result = json.getChar("r")?.let { Game.Result.fromSymbol(it) } ?: UNKNOWN,
|
||||||
drawnUpDown = json.getInt("drawnUpDown") ?: 0
|
drawnUpDown = json.getInt("dd") ?: 0
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user