From 6abc7f2247dc518eca45a0b85bdf2cb87f0e5bae Mon Sep 17 00:00:00 2001 From: Jonni Liljamo Date: Sun, 21 May 2023 23:58:12 +0300 Subject: [PATCH] feat(client): update RollForCurrency --- client/src/api/game/mod.rs | 4 ++-- client/src/game_status/parser.rs | 6 ++++-- client/src/plugins/game/ui/mod.rs | 2 +- client/src/util/action_to_log.rs | 6 ++++-- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/client/src/api/game/mod.rs b/client/src/api/game/mod.rs index 7d26c64..c970d3c 100644 --- a/client/src/api/game/mod.rs +++ b/client/src/api/game/mod.rs @@ -64,8 +64,8 @@ pub enum Command { state: PlayerState, }, RollForCurrency { - min: usize, - max: usize, + amount: usize, + sides: usize, }, } diff --git a/client/src/game_status/parser.rs b/client/src/game_status/parser.rs index cb65c3f..8c5438a 100644 --- a/client/src/game_status/parser.rs +++ b/client/src/game_status/parser.rs @@ -229,8 +229,10 @@ fn parse_action(action: &Action, game: &Game, game_status: &mut GameStatus) { Command::ChangePlayerState { state } => { target.state = *state; } - Command::RollForCurrency { min, max } => { - target.currency += Rng::with_seed(action.seed.parse::().unwrap()).usize(min..=max); + Command::RollForCurrency { amount, sides } => { + for _ in 0..*amount { + target.currency += Rng::with_seed(action.seed.parse::().unwrap()).usize(1..=*sides); + } } #[allow(unreachable_patterns)] _ => todo!(), diff --git a/client/src/plugins/game/ui/mod.rs b/client/src/plugins/game/ui/mod.rs index dfa16ac..529d6d0 100644 --- a/client/src/plugins/game/ui/mod.rs +++ b/client/src/plugins/game/ui/mod.rs @@ -422,7 +422,7 @@ fn hardcoded_init(game: &Game, create_action_ev_w: &mut EventWriter { + Command::RollForCurrency { amount, sides } => { LogEntry::from_sections(vec![ LogSection::bold(invoker_name), - LogSection::normal(" rolled for currency (log borked)"), + LogSection::normal(" rolled "), + LogSection::bold(&format!("{}d{}", amount, sides)), + LogSection::normal(" for currency"), ]) } #[allow(unreachable_patterns)] -- 2.44.1