From e040cdedc6288988f419df520e53949176fba4d1 Mon Sep 17 00:00:00 2001 From: timotree3 Date: Mon, 13 Jun 2022 09:56:31 -0400 Subject: [PATCH] Update json_ouput for latest site --- .gitignore | 1 + src/json_output.rs | 36 ++++++++++++++++++++---------------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 7d0d0d0..79e9249 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ target *.sw* +/replays/ \ No newline at end of file diff --git a/src/json_output.rs b/src/json_output.rs index 9f2551b..4beb72f 100644 --- a/src/json_output.rs +++ b/src/json_output.rs @@ -11,37 +11,39 @@ fn color_value(color: &Color) -> usize { fn card_to_json(card: &Card) -> serde_json::Value { json!({ "rank": card.value, - "suit": color_value(&card.color), + "suitIndex": color_value(&card.color), }) } pub fn action_clue(hint: &Hint) -> serde_json::Value { - json!({ - "type": 0, - "target": hint.player, - "clue": match hint.hinted { - Hinted::Value(value) => { json!({ - "type": 0, - "value": value, - }) } - Hinted::Color(color) => { json!({ - "type": 1, + match hint.hinted { + Hinted::Color(color) => { + json!({ + "type": 2, + "target": hint.player, "value": color_value(&color), - }) } + }) } - }) + Hinted::Value(value) => { + json!({ + "type": 3, + "target": hint.player, + "value": value, + }) + } + } } pub fn action_play((i, _card): &AnnotatedCard) -> serde_json::Value { json!({ - "type": 1, + "type": 0, "target": i, }) } pub fn action_discard((i, _card): &AnnotatedCard) -> serde_json::Value { json!({ - "type": 2, + "type": 1, "target": i, }) } @@ -52,7 +54,9 @@ pub fn json_format( players: &Vec, ) -> serde_json::Value { json!({ - "variant": "No Variant", + "options": { + "variant": "No Variant", + }, "players": players, "first_player": 0, "notes": players.iter().map(|_player| {json!([])}).collect::>(), // TODO add notes