blob: 21ffab17fb7cb2ba1bdf05965404d27ec75767b1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
module Scoring
module FibonacciPeerWithBlowout
def self.stats_needed
return [:votes]
end
def self.score(match)
scores = {}
match.players.each do |player|
scores[player] = self.score_user(match.statistics.where(user: player, name: :votes).first, match.win?(player), match.blowout)
end
scores
end
protected
def self.score_user(votes, win, blowout)
fibonacci = Hash.new { |h,k| h[k] = k < 2 ? k : h[k-1] + h[k-2] }
fibonacci[votes+3] + (win ? blowout ? 12 : 10 : blowout ? 5 : 7)
end
end
end
|