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