summaryrefslogtreecommitdiff
path: root/lib/scoring/winner_takes_all.rb
blob: 9c83fb91fe3cb5a74bda70ad5ef4b0468e375276 (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 WinnerTakesAll
		def self.stats_needed
			#return ["win"]
			["win", "numDeaths", "turretsKilled", "championsKilled", "minionsKilled", "assists"]
		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.value)
			end
			scores
		end

		private
		def self.score_user(win)
			win.nil? ? 0.5 : win ? 1 : 0
		end
	end
end