finish logs

This commit is contained in:
ntr
2019-06-01 14:01:48 +10:00
parent 574f260a30
commit c921e790c9
3 changed files with 9 additions and 16 deletions
+3 -4
View File
@@ -805,11 +805,10 @@ pub fn game_update(tx: &mut Transaction, game: &Game) -> Result<(), Error> {
result.iter().next().ok_or(format_err!("game {:?} could not be written", game))?;
if game.finished() {
info!("game finished state={:?}", game);
if let Some(i) = game.instance {
match i == Uuid::nil() {
true => global_game_finished(tx, &game)?,
false => instance_game_finished(tx, &game, i)?,
}
instance_game_finished(tx, &game, i)?;
}
}
+6 -1
View File
@@ -312,7 +312,8 @@ impl Instance {
fn finish_condition(&self) -> bool {
match self.format {
// bo5 standard
Format::Standard => self.players.iter().any(|p| p.score.wins > 2),
// OR condition is for forfeitures
Format::Standard => self.players.iter().any(|p| p.score.wins > 2) || self.rounds.len() == 5,
// everybody plays each other once
Format::RoundRobin => self.rounds.len() == self.players.len() - 1,
@@ -546,6 +547,10 @@ pub fn instance_update(tx: &mut Transaction, instance: Instance) -> Result<Insta
// info!("{:?} wrote instance", instance.id);
if instance.finished() {
info!("instance finished state={:?}", instance);
}
return Ok(instance);
}