diff --git a/crates/game-service/src/home_mode.rs b/crates/game-service/src/home_mode.rs index e64f6f7..8a09333 100644 --- a/crates/game-service/src/home_mode.rs +++ b/crates/game-service/src/home_mode.rs @@ -52,6 +52,12 @@ impl HomeMode { pub fn stop_home_logic(&mut self) { self.home_logic_stopped = true; } + pub fn resume_home_logic(&mut self) { + self.home_logic_stopped = false; + } + pub fn is_home_logic_stopped(&self) -> bool { + self.home_logic_stopped + } pub fn shop_cycle(&self) -> ShopCycle { ShopCycle::at(self.logic.current_timestamp()) } diff --git a/crates/game-service/src/service.rs b/crates/game-service/src/service.rs index 7d3bf76..5ebba46 100644 --- a/crates/game-service/src/service.rs +++ b/crates/game-service/src/service.rs @@ -203,7 +203,11 @@ impl GameApi for GameService { ShopCycle, Vec, ) = { - let home = session.lock().await; + let mut home = session.lock().await; + if kind == HomeRequestKind::GoHome && home.is_home_logic_stopped() { + tracing::info!(%account, "client came back from the battle, resuming home logic"); + home.resume_home_logic(); + } ( home.own_home_data(self.config.random_seed), home.logic().checksum(), @@ -281,10 +285,24 @@ impl GameApi for GameService { .get_or_open(account, &profile, unix_seconds() as i32) .await; let roller = self.roller(account).await?; - let result = { + let (result, in_battle) = { let mut home = session.lock().await; - home.end_client_turn(&turn, &roller, &self.shop) + let in_battle = home.is_home_logic_stopped(); + (home.end_client_turn(&turn, &roller, &self.shop), in_battle) }; + if in_battle { + tracing::info!( + %account, + tick = turn.tick, + checksum = turn.checksum, + commands = ?turn + .commands + .iter() + .map(|command| command.command_type()) + .collect::>(), + "battle turn" + ); + } tracing::debug!( %account, tick = turn.tick,