game finished find round

This commit is contained in:
ntr 2019-09-09 16:46:26 +10:00
parent 198711b3b2
commit faf54dc3ae

View File

@ -384,14 +384,14 @@ impl Instance {
fn game_finished(&mut self, game: &Game) -> Result<&mut Instance, Error> {
{
let current_round = self.rounds
.last_mut()
.expect("instance does not have any rounds");
.iter_mut()
.filter(|r| r.game_id.is_some())
.find(|r| r.game_id.unwrap() == game.id);
if current_round.game_id.unwrap() != game.id {
return Err(err_msg("instance does not have a round for this game"));
}
current_round.finished = true;
match current_round {
Some(c) => c.finished = true,
None => return Err(err_msg("instance does not have a round for this game")),
};
}
// if you don't win, you lose