Update json_ouput for latest site

This commit is contained in:
timotree3 2022-06-13 09:56:31 -04:00
parent a1bfa76b77
commit e040cdedc6
2 changed files with 21 additions and 16 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
target target
*.sw* *.sw*
/replays/

View file

@ -11,37 +11,39 @@ fn color_value(color: &Color) -> usize {
fn card_to_json(card: &Card) -> serde_json::Value { fn card_to_json(card: &Card) -> serde_json::Value {
json!({ json!({
"rank": card.value, "rank": card.value,
"suit": color_value(&card.color), "suitIndex": color_value(&card.color),
}) })
} }
pub fn action_clue(hint: &Hint) -> serde_json::Value { pub fn action_clue(hint: &Hint) -> serde_json::Value {
match hint.hinted {
Hinted::Color(color) => {
json!({ json!({
"type": 0, "type": 2,
"target": hint.player, "target": hint.player,
"clue": match hint.hinted {
Hinted::Value(value) => { json!({
"type": 0,
"value": value,
}) }
Hinted::Color(color) => { json!({
"type": 1,
"value": color_value(&color), "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 { pub fn action_play((i, _card): &AnnotatedCard) -> serde_json::Value {
json!({ json!({
"type": 1, "type": 0,
"target": i, "target": i,
}) })
} }
pub fn action_discard((i, _card): &AnnotatedCard) -> serde_json::Value { pub fn action_discard((i, _card): &AnnotatedCard) -> serde_json::Value {
json!({ json!({
"type": 2, "type": 1,
"target": i, "target": i,
}) })
} }
@ -52,7 +54,9 @@ pub fn json_format(
players: &Vec<String>, players: &Vec<String>,
) -> serde_json::Value { ) -> serde_json::Value {
json!({ json!({
"options": {
"variant": "No Variant", "variant": "No Variant",
},
"players": players, "players": players,
"first_player": 0, "first_player": 0,
"notes": players.iter().map(|_player| {json!([])}).collect::<Vec<_>>(), // TODO add notes "notes": players.iter().map(|_player| {json!([])}).collect::<Vec<_>>(), // TODO add notes