blob: 5fc188a4c94c69d8736bbf5c79976e7a48f4275b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
module Scoring
module WinnerTakesAll
def self.stats_needed
return ["win"]
end
def self.score(match)
scores = {}
match.users.each do |user|
stats = Statistic.where(user: user, match: match)
scores[user] = score_user(stats.where(name: "win").first)
end
scores
end
private
def self.score_user(win)
win.nil? ? 0.5 : win ? 1 : 0
end
end
end
|