From 38c6cb2552c1d78fea4f77760cff93a90731ed5a Mon Sep 17 00:00:00 2001 From: Jonathan Bernard Date: Mon, 23 Aug 2010 20:33:24 -0500 Subject: [PATCH] Updated WeightedChooser, players who just sat are chosen last. --- src/com/jdbernard/teammaker/WeightedChooser.groovy | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/com/jdbernard/teammaker/WeightedChooser.groovy b/src/com/jdbernard/teammaker/WeightedChooser.groovy index 5b80149..eafd5b4 100644 --- a/src/com/jdbernard/teammaker/WeightedChooser.groovy +++ b/src/com/jdbernard/teammaker/WeightedChooser.groovy @@ -45,6 +45,12 @@ public class WeightedChooser extends PlayerChooser { } protected int getThreshold(def players) { - return (players.max { it.gamesSat }).gamesSat - hardLimit + int highest = (players.max { it.gamesSat }).gamesSat + + // everyone has 0 games sat, no threshold + if (highest == 0) return 0; + + // if any players have sat at least one game, exclude those that haven't + return Math.max(highest - hardLimit, 1) } }