lib/icu_ratings/tournament.rb in icu_ratings-1.5.0 vs lib/icu_ratings/tournament.rb in icu_ratings-1.5.1
- old
+ new
@@ -84,11 +84,11 @@
# Add a new player to the tournament. Returns the instance of ICU::RatedPlayer created.
# See ICU::RatedPlayer for details.
def add_player(num, args={})
raise "player with number #{num} already exists" if @player[num]
args[:kfactor] = ICU::RatedPlayer.kfactor(args[:kfactor].merge({ :start => start, :rating => args[:rating] })) if args[:kfactor].is_a?(Hash)
- @player[num] = ICU::RatedPlayer.new(num, args)
+ @player[num] = ICU::RatedPlayer.factory(num, args)
end
# Add a new result to the tournament. Two instances of ICU::RatedResult are
# created. One is added to the first player and the other to the second player.
# The method returns _nil_. See ICU::RatedResult for details.
@@ -124,11 +124,11 @@
update_bonuses = true
threshold = 0.1
end
# Phase 1.
- players.each { |p| p.init }
+ players.each { |p| p.reset }
@iterations1 = performance_ratings(max_iterations[0], threshold)
players.each { |p| p.rate! }
# Phase 2.
if !no_bonuses && calculate_bonuses > 0
@@ -180,9 +180,9 @@
count
end
# Calculate bonuses for all players and return the number who got one.
def calculate_bonuses
- @player.values.inject(0) { |t,p| t + (p.calculate_bonus ? 1 : 0) }
+ @player.values.select{ |p| p.respond_to?(:bonus) }.inject(0) { |t,p| t + (p.calculate_bonus ? 1 : 0) }
end
end
end