From 615c3cdc32255c91d9bad1b0abd0dc26782cb731 Mon Sep 17 00:00:00 2001 From: skye Date: Thu, 4 May 2023 13:49:01 +0300 Subject: [PATCH] feat(client): handle action seed as string --- client/src/api/game/create_action.rs | 4 ++-- client/src/api/game/mod.rs | 5 +++-- client/src/game_status/parser.rs | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/client/src/api/game/create_action.rs b/client/src/api/game/create_action.rs index 1d0591b..2f2361f 100644 --- a/client/src/api/game/create_action.rs +++ b/client/src/api/game/create_action.rs @@ -20,7 +20,7 @@ struct CreateActionPost { invoker: String, target: String, command: String, - seed: u64, + seed: String, } pub fn create_action( @@ -32,7 +32,7 @@ pub fn create_action( invoker: action.invoker.to_string(), target: action.target.to_string(), command: serde_json::to_string(&action.command).unwrap(), - seed: action.seed, + seed: action.seed.to_string(), }); Ok(res.json().unwrap()) diff --git a/client/src/api/game/mod.rs b/client/src/api/game/mod.rs index 2f30e25..6cad5a5 100644 --- a/client/src/api/game/mod.rs +++ b/client/src/api/game/mod.rs @@ -51,7 +51,8 @@ pub struct Action { pub invoker: String, pub target: String, pub command: Command, - pub seed: u64, + /// it's actually u64, but we handle it as a string to make psql happy + pub seed: String, } impl Action { @@ -70,7 +71,7 @@ impl Action { invoker: invoker.to_string(), target: target.to_string(), command: command.clone(), - seed, + seed: seed.to_string(), } } } diff --git a/client/src/game_status/parser.rs b/client/src/game_status/parser.rs index 4c6db74..12d4712 100644 --- a/client/src/game_status/parser.rs +++ b/client/src/game_status/parser.rs @@ -65,7 +65,7 @@ pub fn parse(game: &Game) -> Result { Command::Draw { amount } => { for _ in 0..*amount { if target.deck.is_empty() { - shuffle_discard_to_deck(target, action.seed); + shuffle_discard_to_deck(target, action.seed.parse::().unwrap()); } target.hand.push(target.deck.pop() -- 2.44.1