diff options
Diffstat (limited to 'lib/scoring/winner_takes_all.rb')
-rw-r--r-- | lib/scoring/winner_takes_all.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/scoring/winner_takes_all.rb b/lib/scoring/winner_takes_all.rb new file mode 100644 index 0000000..6cffb28 --- /dev/null +++ b/lib/scoring/winner_takes_all.rb @@ -0,0 +1,16 @@ +module Scoring + module WinnerTakesAll + def self.stats_needed(match) + return ["win"] + end + + def self.score(match) + scores = {} + match.users.each do |user| + stats = Statistic.where(user: user, match: match) + scores[user] = stats.where(name: "win").first.value ? 1 : 0 + end + scores + end + end +end |