M client/src/api/game/mod.rs => client/src/api/game/mod.rs +8 -2
@@ 10,7 10,7 @@ use bevy::reflect::{Reflect, FromReflect};
use serde::{Deserialize, Serialize};
use serde_repr::Deserialize_repr;
-use crate::game_status::{Card, PlayerState};
+use crate::{game_status::{Card, PlayerState}, seed_gen};
use super::user::User;
@@ 83,7 83,13 @@ pub struct Action {
}
impl Action {
- pub fn new(game_id: &str, invoker: &str, target: &str, command: &Command, seed: u64) -> Self {
+ pub fn new(game_id: &str, invoker: &str, target: &str, command: &Command, seed: Option<u64>) -> Self {
+ let seed = if seed.is_none() {
+ seed_gen!()
+ } else {
+ seed.unwrap()
+ };
+
Self {
id: "".to_string(),
created_at: chrono::Utc::now(),
M client/src/game_status/parser.rs => client/src/game_status/parser.rs +1 -1
@@ 89,7 89,7 @@ pub fn parse(game: &Game) -> Result<GameStatus, ()> {
macro_rules! current_seed {
($action:ident) => {
- $action.seed.parse::<u64>().unwrap()
+ Some($action.seed.parse::<u64>().unwrap())
};
}
M client/src/plugins/game/hand/mod.rs => client/src/plugins/game/hand/mod.rs +2 -2
@@ 14,7 14,7 @@ use crate::{
api::game::{Action, Command},
game_status::PlayerState,
plugins::GameActionCreateCallEvent,
- seed_gen, Global,
+ Global,
};
use super::{
@@ 153,7 153,7 @@ fn handle_clicked_hand_card(
&global.user.as_ref().unwrap().id,
&global.user.as_ref().unwrap().id,
&Command::PlayCard { index: card_kind.0 },
- seed_gen!(),
+ None,
),
});
}
M client/src/plugins/game/supply/mod.rs => client/src/plugins/game/supply/mod.rs +2 -2
@@ 14,7 14,7 @@ use crate::{
api::game::{Action, Command},
game_status::PlayerState,
plugins::GameActionCreateCallEvent,
- seed_gen, Global,
+ Global,
};
use super::{
@@ 179,7 179,7 @@ fn handle_clicked_supply_pile(
index: card_kind.0,
for_cost: card.card.cost,
},
- seed_gen!(),
+ None,
),
});
}
M client/src/plugins/game/ui/mod.rs => client/src/plugins/game/ui/mod.rs +6 -6
@@ 13,7 13,7 @@ use crate::{
api::game::{Action, Command, Game},
game_status::{Card, CardAction, PlayerState},
plugins::GameActionCreateCallEvent,
- seed_gen, AppState, Global,
+ AppState, Global,
};
use super::{GameData, RefreshGameEvent};
@@ 428,7 428,7 @@ fn hardcoded_init(game: &Game, create_action_ev_w: &mut EventWriter<GameActionCr
},
amount: 10,
},
- seed_gen!(),
+ None,
),
});
create_action_ev_w.send(GameActionCreateCallEvent {
@@ 448,7 448,7 @@ fn hardcoded_init(game: &Game, create_action_ev_w: &mut EventWriter<GameActionCr
},
amount: 10,
},
- seed_gen!(),
+ None,
),
});
create_action_ev_w.send(GameActionCreateCallEvent {
@@ 466,7 466,7 @@ fn hardcoded_init(game: &Game, create_action_ev_w: &mut EventWriter<GameActionCr
},
amount: 10,
},
- seed_gen!(),
+ None,
),
});
create_action_ev_w.send(GameActionCreateCallEvent {
@@ 484,7 484,7 @@ fn hardcoded_init(game: &Game, create_action_ev_w: &mut EventWriter<GameActionCr
},
amount: 10,
},
- seed_gen!(),
+ None,
),
});
@@ 495,7 495,7 @@ fn hardcoded_init(game: &Game, create_action_ev_w: &mut EventWriter<GameActionCr
&game.host_id,
&game.host_id,
&Command::StartTurn {},
- seed_gen!(),
+ None,
),
});
}
M client/src/plugins/game/ui/state_button.rs => client/src/plugins/game/ui/state_button.rs +3 -3
@@ 12,7 12,7 @@ use crate::{
api::game::{Action, Command},
game_status::PlayerState,
plugins::{GameActionCreateCallEvent, GameData},
- seed_gen, AppState, Global,
+ AppState, Global,
};
pub struct StateButtonPlugin;
@@ 157,7 157,7 @@ fn interact_state_button(
&Command::ChangePlayerState {
state: PlayerState::BuyPhase,
},
- seed_gen!(),
+ None,
),
});
}
@@ 181,7 181,7 @@ fn interact_state_button(
&user.id,
next_player.0,
&Command::EndTurn {},
- seed_gen!(),
+ None,
),
});
}