summaryrefslogtreecommitdiff
path: root/lib/scoring/fibonacci_peer_with_blowout.rb
diff options
context:
space:
mode:
authornfoy <nfoy@purdue.edu>2014-04-23 20:41:03 -0400
committernfoy <nfoy@purdue.edu>2014-04-23 20:41:03 -0400
commit9afd5a4f7a86eeaab3fa8a0c25609ac7977e0489 (patch)
tree8d47adc08a58a8936e2026f30852f877ee47cf64 /lib/scoring/fibonacci_peer_with_blowout.rb
parent422a7b39a06e2fe54415f2be08548021a981e8a8 (diff)
parent7ff82b901705475f97e277a9f3f31756bd3ce948 (diff)
Merge branch 'master' of https://github.com/LukeShu/leaguer
Diffstat (limited to 'lib/scoring/fibonacci_peer_with_blowout.rb')
-rw-r--r--lib/scoring/fibonacci_peer_with_blowout.rb29
1 files changed, 17 insertions, 12 deletions
diff --git a/lib/scoring/fibonacci_peer_with_blowout.rb b/lib/scoring/fibonacci_peer_with_blowout.rb
index 19ac9a7..8043fb7 100644
--- a/lib/scoring/fibonacci_peer_with_blowout.rb
+++ b/lib/scoring/fibonacci_peer_with_blowout.rb
@@ -1,16 +1,21 @@
-require 'ScoringAlgorithm'
-
-class FibonacciPeerWithBlowout < ScoringAlgorithm
+module Scoring
+ module FibonacciPeerWithBlowout
+ def stats_needed
+ return [:votes]
+ end
- def self.score(match, interface)
- match.players.each do |player|
- scores[player.user_name] = scoreUser(interface.getStatistic(match, player, :votes), match.win?(player), match.blowout)
+ def score(match, interface)
+ scores = {}
+ match.players.each do |player|
+ scores[player.user_name] = score_user(interface.get_statistic(match, player, :votes), match.win?(player), match.blowout)
+ end
+ scores
end
- scores
- end
- def self.scoreUser(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)
+ private
+ def 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 \ No newline at end of file
+end