Skip to content

Commit c8b258d

Browse files
committed
politician doesnt shut down entire server
1 parent 2103799 commit c8b258d

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

server/src/game/phase.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,11 @@ impl PhaseState {
124124
ChatMessageVariant::PhaseChange {
125125
phase: game.current_phase().clone(),
126126
//need this if statement because the day number should be increased for obituary phase
127-
day_number: if game.current_phase().phase() != PhaseType::Obituary {game.phase_machine.day_number} else {game.phase_machine.day_number+1}
127+
day_number: if game.current_phase().phase() != PhaseType::Obituary {
128+
game.phase_machine.day_number
129+
} else {
130+
game.phase_machine.day_number.saturating_add(1)
131+
}
128132
}
129133
);
130134

@@ -147,7 +151,7 @@ impl PhaseState {
147151

148152
events.into_iter().for_each(|f| f.invoke(game));
149153

150-
game.phase_machine.day_number += 1;
154+
game.phase_machine.day_number = game.phase_machine.day_number.saturating_add(1);
151155
},
152156
PhaseState::Nomination { trials_left, nomination_time_remaining } => {
153157
game.phase_machine.set_time_remaining(nomination_time_remaining);

server/src/game/role/politician.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use std::time::Duration;
2-
31
use serde::Serialize;
42

53
use crate::game::attack_power::DefensePower;
@@ -104,14 +102,15 @@ impl RoleStateImpl for Politician {
104102

105103
if self.state.countdown_started() && actor_ref.alive(game) {
106104
//for skipping phases
107-
match phase {
108-
PhaseType::Briefing | PhaseType::Nomination | PhaseType::Testimony |
109-
PhaseType::Judgement | PhaseType::FinalWords | PhaseType::Recess => {}
105+
// this litterally causes the entire server to crash
106+
// match phase {
107+
// PhaseType::Briefing | PhaseType::Nomination | PhaseType::Testimony |
108+
// PhaseType::Judgement | PhaseType::FinalWords | PhaseType::Recess => {}
110109

111-
PhaseType::Obituary | PhaseType::Discussion | PhaseType::Dusk | PhaseType::Night => {
112-
game.phase_machine.time_remaining = Duration::from_secs(0);
113-
}
114-
}
110+
// PhaseType::Obituary | PhaseType::Discussion | PhaseType::Dusk | PhaseType::Night => {
111+
// game.phase_machine.time_remaining = Duration::from_secs(0);
112+
// }
113+
// }
115114

116115
match phase {
117116
PhaseType::Nomination => {
@@ -125,6 +124,7 @@ impl RoleStateImpl for Politician {
125124
},
126125
_ => {}
127126
}
127+
128128
}
129129
}
130130

@@ -192,9 +192,10 @@ impl Politician {
192192
fn start_countdown(&mut self, game: &mut Game){
193193
game.add_message_to_chat_group(ChatGroup::All, ChatMessageVariant::PoliticianCountdownStarted);
194194

195-
if game.current_phase().phase() != PhaseType::Nomination {
196-
game.phase_machine.time_remaining = Duration::from_secs(0);
197-
}
195+
// causes the entire server to crash
196+
// if game.current_phase().phase() != PhaseType::Nomination {
197+
// game.phase_machine.time_remaining = Duration::from_secs(0);
198+
// }
198199
self.state = PoliticianState::CountdownStarted;
199200
}
200201

0 commit comments

Comments
 (0)