Skip to content

Commit 365d651

Browse files
committed
make multiple amnes not instantly end
1 parent a7feb62 commit 365d651

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

server/src/game/mod.rs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,19 +130,24 @@ impl Game {
130130
}
131131

132132
pub fn game_is_over(&self) -> bool {
133-
//find list of all remaining teams
133+
//find list of all remaining teams, no duplicates, and remove none
134134
let remaining_teams: Vec<EndGameCondition> =
135135
PlayerReference::all_players(self).into_iter()
136-
.filter(|p|p.alive(self)).map(|p|p.end_game_condition(self)).collect();
136+
.filter(|p|p.alive(self) && p.end_game_condition(self) != EndGameCondition::None)
137+
.map(|p|p.end_game_condition(self))
138+
.collect::<std::collections::HashSet<EndGameCondition>>().into_iter().collect::<Vec<EndGameCondition>>();
137139

138-
//remove all duplicates from remaining_teams
139-
let remaining_teams = remaining_teams.into_iter()
140-
.collect::<std::collections::HashSet<EndGameCondition>>().into_iter().collect::<Vec<EndGameCondition>>();
141-
142-
//if there is only one team left, then the game is over
143-
remaining_teams.len() <= 1
144-
145-
//it doesnt matter if the final team is none, because this doesnt care who won, just that game is over
140+
//if there are no teams left and multiple amnesiacs alive then the game is not over
141+
if
142+
remaining_teams.len() == 0 &&
143+
PlayerReference::all_players(self).into_iter()
144+
.filter(|p|p.alive(self) && p.role_state(self).role() == role::Role::Amnesiac)
145+
.collect::<Vec<_>>().len() > 1
146+
{
147+
return false;
148+
}
149+
150+
remaining_teams.len() <= 1
146151
}
147152

148153
pub fn current_phase(&self) -> &PhaseState {

0 commit comments

Comments
 (0)