Class: Sorare::Rewards::Supply::ComputeForGameWeek

Inherits:
Object
  • Object
show all
Includes:
Interactor
Defined in:
lib/sorare/rewards/interactors/supply/compute_for_game_week.rb

Overview

ComputeForGameWeek computes the rewardable supply of a game week based on the overall supply

Instance Method Summary collapse

Instance Method Details

#callObject



16
17
18
# File 'lib/sorare/rewards/interactors/supply/compute_for_game_week.rb', line 16

def call
  context.game_week_supply = game_week_supply!
end

#game_week_supply!Object



20
21
22
23
24
# File 'lib/sorare/rewards/interactors/supply/compute_for_game_week.rb', line 20

def game_week_supply!
  game_week.each_league.each_with_object(Hash.new({})) do |league, game_week_supply|
    game_week_supply[league.name] = league_supply!(league)
  end
end

#league_supply!(league) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/sorare/rewards/interactors/supply/compute_for_game_week.rb', line 26

def league_supply!(league)
  league.each_rarity_supply.each_with_object({}) do |(rarity, supply), league_supply|
    league_supply[rarity] = ComputeForRarity.call!(
      league: league, rarity: rarity, supply: supply, randomizer: randomizer
    ).rarity_supply
  end
end

#randomizerObject



34
35
36
# File 'lib/sorare/rewards/interactors/supply/compute_for_game_week.rb', line 34

def randomizer
  @randomizer ||= Sorare::Rewards::Random.new(game_week.public_seed, game_week.salt)
end