summaryrefslogtreecommitdiff
path: root/lib/scoring/winner_takes_all.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/scoring/winner_takes_all.rb')
-rw-r--r--lib/scoring/winner_takes_all.rb20
1 files changed, 20 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..57ddae6
--- /dev/null
+++ b/lib/scoring/winner_takes_all.rb
@@ -0,0 +1,20 @@
+module Scoring
+ module WinnerTakesAll
+ def self.stats_needed
+ return ["win"]
+ end
+
+ def self.score(match, interface)
+ scores = {}
+ match.players.each do |player|
+ scores[player.user_name] = score_user(player.statistics.where(:match => match, :name => "win").value)
+ end
+ scores
+ end
+
+ private
+ def self.score_user(win)
+ win.nil? ? 0.5 : win ? 1 : 0
+ end
+ end
+end