Class: Sorare::Rewards::Cards::PickForGameWeek

Inherits:
Object
  • Object
show all
Includes:
Interactor, WithPickerOptions
Defined in:
lib/sorare/rewards/interactors/cards/pick_for_game_week.rb

Overview

PickForGameWeek picks the rewards for a given game week Receive a Game Week object And a reward allocations

{
  'global-all_star' => {
    'D1' => {
      'rare' => { 'tier_0': 1, 'tier_1': 1 }
    }
  }
}

Instance Method Summary collapse

Instance Method Details

#callObject



26
27
28
# File 'lib/sorare/rewards/interactors/cards/pick_for_game_week.rb', line 26

def call
  context.cards_picked = pick!
end

#pick!Object



30
31
32
33
34
35
36
# File 'lib/sorare/rewards/interactors/cards/pick_for_game_week.rb', line 30

def pick!
  allocations.each_league_allocations.each_with_object({}) do |(league_name, league_allocations), picks|
    picks[league_name] = PickForLeague.call!(
      **context.to_h, league: game_week.league(league_name), allocations: league_allocations
    ).cards_picked
  end
end