Skip to content

Commit

Permalink
Rename 'still_ticking' and 'ongoing' to 'ticking' on frontend and bac…
Browse files Browse the repository at this point in the history
…kend
  • Loading branch information
Jack-Papel committed Dec 18, 2023
1 parent bf54b28 commit 0e568ac
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion client/src/game/gameManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion client/src/game/gameState.d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ type GameState = {
excludedRoles: RoleOutline[],
phaseTimes: PhaseTimes

still_ticking: boolean
ticking: boolean
}
export default GameState;

Expand Down
2 changes: 1 addition & 1 deletion client/src/game/gameState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export function createGameState(): GameState {
night: 37,
},

still_ticking: true,
ticking: true,
}
}

Expand Down
2 changes: 1 addition & 1 deletion client/src/game/messageListener.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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!");
Expand Down
13 changes: 7 additions & 6 deletions server/src/game/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion server/src/game/player/player_send_packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl PlayerReference{
}
]);

if !game.ongoing {
if !game.ticking {
self.send_packet(game, ToClientPacket::GameOver { reason: GameOverReason::Draw })
}

Expand Down

1 comment on commit 0e568ac

@vercel
Copy link

@vercel vercel bot commented on 0e568ac Dec 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

mafia-game – ./

mafia-game-itssammym.vercel.app
mafia-game.vercel.app
mafia-game-git-00x-main-itssammym.vercel.app

Please sign in to comment.