From 49a7a70c12a34314d776ea936c0d9d89fcf4679c Mon Sep 17 00:00:00 2001 From: Jonni Liljamo Date: Wed, 24 May 2023 10:10:16 +0300 Subject: [PATCH] feat(client): show what the user rolled in log --- client/src/game_status/parser.rs | 9 ++++++--- client/src/util/action_to_log.rs | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/client/src/game_status/parser.rs b/client/src/game_status/parser.rs index 185af8c..4d46678 100644 --- a/client/src/game_status/parser.rs +++ b/client/src/game_status/parser.rs @@ -16,7 +16,7 @@ use crate::{ util::action_to_log, }; -use super::{GameStatus, PlayerState, PlayerStatus}; +use super::{GameStatus, PlayerState, PlayerStatus, LogSection, LogEntry}; /// funny unsafe wrapper fn get_invoker_target_next<'a>( @@ -254,8 +254,11 @@ fn parse_action(action: &Action, game: &Game, game_status: &mut GameStatus) { } Command::RollForCurrency { amount, sides } => { for _ in 0..*amount { - target.currency += - Rng::with_seed(action.seed.parse::().unwrap()).usize(1..=*sides); + let result = Rng::with_seed(action.seed.parse::().unwrap()).usize(1..=*sides); + target.currency += result; + game_status.log.push(LogEntry::from_sections([ + LogSection::bold(&format!(" {}", result.to_string())), + ])); } } Command::GivePlays { amount } => { diff --git a/client/src/util/action_to_log.rs b/client/src/util/action_to_log.rs index 4bcc8d9..7d66783 100644 --- a/client/src/util/action_to_log.rs +++ b/client/src/util/action_to_log.rs @@ -92,7 +92,7 @@ pub fn action_to_log(action: &Action, game_status: &GameStatus) -> LogEntry { LogSection::bold(invoker_name), LogSection::normal(" rolled "), LogSection::bold(&format!("{}d{}", amount, sides)), - LogSection::normal(" for currency"), + LogSection::normal(" for currency:"), ]), #[allow(unreachable_patterns)] _ => LogEntry { -- 2.44.1