From 0e568acb74aaf9b68d247af902a275ce079f659b Mon Sep 17 00:00:00 2001 From: Jack Papel Date: Sun, 17 Dec 2023 21:53:44 -0500 Subject: [PATCH] Rename 'still_ticking' and 'ongoing' to 'ticking' on frontend and backend --- client/src/game/gameManager.tsx | 2 +- client/src/game/gameState.d.tsx | 2 +- client/src/game/gameState.tsx | 2 +- client/src/game/messageListener.tsx | 2 +- server/src/game/mod.rs | 13 +++++++------ server/src/game/player/player_send_packet.rs | 2 +- 6 files changed, 12 insertions(+), 11 deletions(-) diff --git a/client/src/game/gameManager.tsx b/client/src/game/gameManager.tsx index e8660c76a..614b7a999 100644 --- a/client/src/game/gameManager.tsx +++ b/client/src/game/gameManager.tsx @@ -230,7 +230,7 @@ export function createGameManager(): GameManager { tick(timePassedMs) { if (gameManager.state.stateType === "game"){ - if (!gameManager.state.still_ticking) return; + if (!gameManager.state.ticking) return; const newTimeLeft = gameManager.state.timeLeftMs - timePassedMs; if (Math.floor(newTimeLeft / 1000) < Math.floor(gameManager.state.timeLeftMs / 1000)) { diff --git a/client/src/game/gameState.d.tsx b/client/src/game/gameState.d.tsx index 5e7e6ed56..6e46b8809 100644 --- a/client/src/game/gameState.d.tsx +++ b/client/src/game/gameState.d.tsx @@ -59,7 +59,7 @@ type GameState = { excludedRoles: RoleOutline[], phaseTimes: PhaseTimes - still_ticking: boolean + ticking: boolean } export default GameState; diff --git a/client/src/game/gameState.tsx b/client/src/game/gameState.tsx index 6e793e7c3..73f34745c 100644 --- a/client/src/game/gameState.tsx +++ b/client/src/game/gameState.tsx @@ -59,7 +59,7 @@ export function createGameState(): GameState { night: 37, }, - still_ticking: true, + ticking: true, } } diff --git a/client/src/game/messageListener.tsx b/client/src/game/messageListener.tsx index 0974c0d43..d38e941d6 100644 --- a/client/src/game/messageListener.tsx +++ b/client/src/game/messageListener.tsx @@ -255,7 +255,7 @@ export default function messageListener(packet: ToClientPacket){ break; case "gameOver": if(GAME_MANAGER.state.stateType === "game"){ - GAME_MANAGER.state.still_ticking = false; + GAME_MANAGER.state.ticking = false; switch(packet.reason) { case "ReachedMaxDay": // alert("Game Over: Reached the maximum day!"); diff --git a/server/src/game/mod.rs b/server/src/game/mod.rs index ac491edf1..bd5ca5c87 100644 --- a/server/src/game/mod.rs +++ b/server/src/game/mod.rs @@ -44,7 +44,8 @@ pub struct Game { phase_machine : PhaseStateMachine, - pub ongoing: bool + /// Whether the game is still updating phase times + pub ticking: bool } impl Game { @@ -83,7 +84,7 @@ impl Game { drop(roles); // Ensure we don't use the order of roles anywhere let mut game = Self{ - ongoing: true, + ticking: true, players: players.into_boxed_slice(), graves: Vec::new(), teams: Teams::default(), @@ -164,19 +165,19 @@ impl Game { player_ref.tick(self, time_passed) } - if !self.ongoing { return } + if !self.ticking { return } if self.game_is_over() { self.add_message_to_chat_group(ChatGroup::All, ChatMessage::GameOver); self.send_packet_to_all(ToClientPacket::GameOver{ reason: GameOverReason::Draw }); - self.ongoing = false; + self.ticking = false; return; } if self.phase_machine.day_number == u8::MAX { self.add_message_to_chat_group(ChatGroup::All, ChatMessage::GameOver); self.send_packet_to_all(ToClientPacket::GameOver{ reason: GameOverReason::ReachedMaxDay }); - self.ongoing = false; + self.ticking = false; return; } @@ -273,7 +274,7 @@ pub mod test { drop(roles); let mut game = Game{ - ongoing: true, + ticking: true, players: players.into_boxed_slice(), graves: Vec::new(), teams: Teams::default(), diff --git a/server/src/game/player/player_send_packet.rs b/server/src/game/player/player_send_packet.rs index acbdb1878..537a6c092 100644 --- a/server/src/game/player/player_send_packet.rs +++ b/server/src/game/player/player_send_packet.rs @@ -57,7 +57,7 @@ impl PlayerReference{ } ]); - if !game.ongoing { + if !game.ticking { self.send_packet(game, ToClientPacket::GameOver { reason: GameOverReason::Draw }) }