From 8e212372351f7127a2e616c5b1ded3313dee70bb Mon Sep 17 00:00:00 2001 From: skye Date: Thu, 4 May 2023 10:58:12 +0300 Subject: [PATCH] feat(client): add seed to action api call, new fn --- client/src/api/game/create_action.rs | 2 ++ client/src/api/game/mod.rs | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/client/src/api/game/create_action.rs b/client/src/api/game/create_action.rs index c11173e..90686f0 100644 --- a/client/src/api/game/create_action.rs +++ b/client/src/api/game/create_action.rs @@ -20,6 +20,7 @@ struct CreateActionPost { invoker: String, target: String, command: Command, + seed: u64, } pub fn create_action( @@ -31,6 +32,7 @@ pub fn create_action( invoker: action.invoker.to_string(), target: action.target.to_string(), command: action.command.clone(), + seed: action.seed, }); Ok(res.json().unwrap()) diff --git a/client/src/api/game/mod.rs b/client/src/api/game/mod.rs index e14f9c5..2f30e25 100644 --- a/client/src/api/game/mod.rs +++ b/client/src/api/game/mod.rs @@ -54,6 +54,27 @@ pub struct Action { pub seed: u64, } +impl Action { + pub fn new( + game_id: &str, + invoker: &str, + target: &str, + command: &Command, + seed: u64 + ) -> Self { + Self { + id: "".to_string(), + created_at: "".to_string(), + updated_at: "".to_string(), + game_id: game_id.to_string(), + invoker: invoker.to_string(), + target: target.to_string(), + command: command.clone(), + seed, + } + } +} + #[derive(Debug, Deserialize_repr, Clone, PartialEq)] #[repr(u8)] pub enum GameState { -- 2.44.1