From cb49552927e49d83bc338d57497a3295e591f32a Mon Sep 17 00:00:00 2001 From: ntr Date: Wed, 29 May 2019 16:52:53 +1000 Subject: [PATCH] fix round robin --- server/src/instance.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/server/src/instance.rs b/server/src/instance.rs index 34675d5d..bf298039 100644 --- a/server/src/instance.rs +++ b/server/src/instance.rs @@ -287,7 +287,7 @@ impl Instance { } fn next_round(&mut self) -> &mut Instance { - if self.win_condition() { + if self.finish_condition() { return self.finish(); } @@ -309,10 +309,13 @@ impl Instance { self } - fn win_condition(&self) -> bool { + fn finish_condition(&self) -> bool { match self.format { + // bo5 standard Format::Standard => self.players.iter().any(|p| p.score.wins > 2), - Format::RoundRobin => self.rounds.len() == self.players.len() / 2, + + // everybody plays each other once + Format::RoundRobin => self.rounds.len() == self.players.len() - 1, } } @@ -775,7 +778,7 @@ mod tests { assert_eq!(instance.phase, InstancePhase::Finished); assert_eq!(instance.rounds[0].len(), 8); - assert_eq!(instance.rounds.len(), 8); + assert_eq!(instance.rounds.len(), 15); } #[test]