@@ -130,19 +130,24 @@ impl Game {
130
130
}
131
131
132
132
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
134
134
let remaining_teams: Vec < EndGameCondition > =
135
135
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 > > ( ) ;
137
139
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
146
151
}
147
152
148
153
pub fn current_phase ( & self ) -> & PhaseState {
0 commit comments