class EloBrain::Matches::Match

Public Class Methods

from(player1:, player2:) click to toggle source
# File lib/elo_brain/matches/match.rb, line 9
def self.from(player1:, player2:)
  new(
    player1: player1,
    player2: player2
  )
end
from_contract(contract:) click to toggle source
# File lib/elo_brain/matches/match.rb, line 16
def self.from_contract(contract:)
  new(
    player1: contract[:player1],
    player2: contract[:player2]
  )
end

Public Instance Methods

calculate_new_elos() click to toggle source
# File lib/elo_brain/matches/match.rb, line 23
def calculate_new_elos
  {
    player1_new_elo: EloBrain::Matches::Services::LaunchNewEloCalculation.new.call(
      strategy: player1.situation,
      nb_matches: player1.nb_matches,
      player_elo: player1.elo,
      opponent_elo: player2.elo
    ),
    player2_new_elo: EloBrain::Matches::Services::LaunchNewEloCalculation.new.call(
      strategy: player2.situation,
      nb_matches: player2.nb_matches,
      player_elo: player2.elo,
      opponent_elo: player1.elo
    ),
  }
end