From a55838983eb101e6f2d6dc3a4a03f5b0d4f36c04 Mon Sep 17 00:00:00 2001
From: Luke Shumaker <shumakl@purdue.edu>
Date: Wed, 23 Apr 2014 20:03:25 -0400
Subject: ignore vim swap files

---
 lib/scoring/.FibonacciPeerWithBlowout.rb.swp | Bin 12288 -> 0 bytes
 1 file changed, 0 insertions(+), 0 deletions(-)
 delete mode 100644 lib/scoring/.FibonacciPeerWithBlowout.rb.swp

(limited to 'lib/scoring')

diff --git a/lib/scoring/.FibonacciPeerWithBlowout.rb.swp b/lib/scoring/.FibonacciPeerWithBlowout.rb.swp
deleted file mode 100644
index 49504ab..0000000
Binary files a/lib/scoring/.FibonacciPeerWithBlowout.rb.swp and /dev/null differ
-- 
cgit v1.2.3-2-g168b


From ae97abc3f47a7209ef8367a5781ca72ada90ddec Mon Sep 17 00:00:00 2001
From: Luke Shumaker <shumakl@purdue.edu>
Date: Wed, 23 Apr 2014 20:05:30 -0400
Subject: clean up lib/scoring

---
 lib/scoring/fibonacci_peer_with_blowout.rb | 29 +++++++++++++++++------------
 lib/scoring/marginal_peer.rb               | 24 ++++++++++++------------
 lib/scoring/scoring_algorithm.rb           |  6 ------
 lib/scoring/winner_takes_all.rb            | 28 ++++++++++++++++------------
 4 files changed, 45 insertions(+), 42 deletions(-)
 delete mode 100644 lib/scoring/scoring_algorithm.rb

(limited to 'lib/scoring')

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
diff --git a/lib/scoring/marginal_peer.rb b/lib/scoring/marginal_peer.rb
index 0e1cfa8..13e1796 100644
--- a/lib/scoring/marginal_peer.rb
+++ b/lib/scoring/marginal_peer.rb
@@ -1,15 +1,15 @@
-require 'ScoringAlgorithm'
-
-class MarginalPeer < ScoringAlgorithm
-
-	def self.score(match, interface)
-		match.players.each do |player|
-			scores[player.user_name] = scoreUser(interface.getStatistic(match, player, rating))
+module Scoring
+	module MarginalPeer
+		def stats_needed
+			return [:rating]
 		end
-		scores
-	end
 
-	def self.score(rating)
-		rating
+		def score(match, interface)
+			scores = {}
+			match.players.each do |player|
+				scores[player.user_name] = interface.get_statistic(match, player, :rating)
+			end
+			scores
+		end
 	end
-end
\ No newline at end of file
+end
diff --git a/lib/scoring/scoring_algorithm.rb b/lib/scoring/scoring_algorithm.rb
deleted file mode 100644
index f2afa6f..0000000
--- a/lib/scoring/scoring_algorithm.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-module Scoring
-	class ScoringAlgorithm
-		def self.score(match, interface)
-		end
-	end
-end
diff --git a/lib/scoring/winner_takes_all.rb b/lib/scoring/winner_takes_all.rb
index ad2471b..517dfd6 100644
--- a/lib/scoring/winner_takes_all.rb
+++ b/lib/scoring/winner_takes_all.rb
@@ -1,16 +1,20 @@
-require 'ScoringAlgorithm'
-
-class WinnerTakesAll < ScoringAlgorithm
-
-	def self.score(match, interface)
-		match.players.each do |player|
-			scores[player.user_name] = scoreUser(match.win?(player))
+module Scoring
+	module WinnerTakesAll
+		def stats_needed
+			return []
 		end
-		scores
-	end
 
+		def score(match, interface)
+			scores = {}
+			match.players.each do |player|
+				scores[player.user_name] = score_user(match.win?(player))
+			end
+			scores
+		end
 
-	def self.score(win)
-		win.nil? ? 0.5 : win ? 1 : 0
+		private
+		def score_user(win)
+			win.nil? ? 0.5 : win ? 1 : 0
+		end
 	end
-end
\ No newline at end of file
+end
-- 
cgit v1.2.3-2-g168b