class EloBrain::Matches::Services::LaunchNewEloCalculation

Public Instance Methods

call(strategy:, nb_matches:, player_elo:, opponent_elo:) click to toggle source
# File lib/elo_brain/matches/services/launch_new_elo_calculation.rb, line 7
def call(strategy:, nb_matches:, player_elo:, opponent_elo:)
  coefficient = development_coefficient(nb_matches, player_elo)
  probability = win_probability(player_elo - opponent_elo)
  calculation_strategy(strategy).new_elo(
    elo: player_elo,
    development_coefficient: coefficient,
    win_probability: probability
  )
end

Private Instance Methods

calculation_strategy(strategy) click to toggle source
# File lib/elo_brain/matches/services/launch_new_elo_calculation.rb, line 19
def calculation_strategy(strategy)
  EloBrain::EloCalculations::Strategies.new.call(strategy: strategy)
end
development_coefficient(nb_matches, elo) click to toggle source
# File lib/elo_brain/matches/services/launch_new_elo_calculation.rb, line 23
def development_coefficient(nb_matches, elo)
  EloBrain::DevelopmentCoefficient::SituationCoefficient.new.call(nb_matches: nb_matches, elo: elo)
end
win_probability(difference_of_elo) click to toggle source
# File lib/elo_brain/matches/services/launch_new_elo_calculation.rb, line 27
def win_probability(difference_of_elo)
  EloBrain::WinProbability::ProbabilityCalculation.new.call(difference_of_elo: difference_of_elo)
end