summaryrefslogtreecommitdiff
path: root/lib/scoring/fibonacci_peer_with_blowout.rb
diff options
context:
space:
mode:
authorLuke Shumaker <shumakl@purdue.edu>2014-04-26 21:12:00 -0400
committerLuke Shumaker <shumakl@purdue.edu>2014-04-26 21:12:00 -0400
commitedb9e6a59459b42acb8dc751044d51c70e81429c (patch)
tree7db7b1b74a7f249a5d29dfb9ce023e03b182dedd /lib/scoring/fibonacci_peer_with_blowout.rb
parentedcca83c6c251a79afcd83760cf20ebaf00b3b32 (diff)
clean up lib/scoring (a bit)
Diffstat (limited to 'lib/scoring/fibonacci_peer_with_blowout.rb')
-rw-r--r--lib/scoring/fibonacci_peer_with_blowout.rb11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/scoring/fibonacci_peer_with_blowout.rb b/lib/scoring/fibonacci_peer_with_blowout.rb
index 8043fb7..21ffab1 100644
--- a/lib/scoring/fibonacci_peer_with_blowout.rb
+++ b/lib/scoring/fibonacci_peer_with_blowout.rb
@@ -1,19 +1,20 @@
module Scoring
module FibonacciPeerWithBlowout
- def stats_needed
+ def self.stats_needed
return [:votes]
end
- def score(match, interface)
+ def self.score(match)
scores = {}
match.players.each do |player|
- scores[player.user_name] = score_user(interface.get_statistic(match, player, :votes), match.win?(player), match.blowout)
+ scores[player] = self.score_user(match.statistics.where(user: player, name: :votes).first, match.win?(player), match.blowout)
end
scores
end
- private
- def score_user(votes, win, blowout)
+ 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