Display timeout in game UI

This commit is contained in:
2022-10-17 08:21:42 +02:00
parent b4772aa88e
commit 9162c5eb24
3 changed files with 36 additions and 7 deletions

View File

@ -78,6 +78,7 @@ impl PrintableMap for PrintableCurrentGameMapStatus {
#[derive(Debug, serde::Serialize, serde::Deserialize, Clone, Default)]
pub struct CurrentGameStatus {
pub remaining_time_for_strike: Option<u64>,
pub rules: GameRules,
pub your_map: CurrentGameMapStatus,
pub opponent_map: CurrentGameMapStatus,

View File

@ -257,6 +257,9 @@ impl Game {
/// Get current game status for a specific player
fn get_game_status_for_player(&self, id: usize) -> CurrentGameStatus {
CurrentGameStatus {
remaining_time_for_strike: self.rules.strike_timeout.map(|v| {
((self.curr_strike_request_started + v) as i64 - time() as i64).max(0) as u64
}),
rules: self.rules.clone(),
your_map: self.player_map(id).current_map_status(false),
opponent_map: self