summaryrefslogtreecommitdiff
path: root/lib/scoring/winner_takes_all.rb
blob: 57ddae6392249fa01f0e7d57f862099c0cc6713a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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