Class: Sorare::Rewards::Cards::PickForDivisionAndRarity

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

Overview

PickForDivisionAndRarity picks the rewards for a given division and rarity A game week data And a reward allocations

{ 'tier_0' => 1, 'tier_1' => 2 }

Instance Method Summary collapse

Instance Method Details

#callObject



20
21
22
# File 'lib/sorare/rewards/interactors/cards/pick_for_division_and_rarity.rb', line 20

def call
  context.cards_picked = supply!
end

#supply!Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/sorare/rewards/interactors/cards/pick_for_division_and_rarity.rb', line 24

def supply!
  allocations.keys.index_with do |tier|
    picker = league.picker_of(rarity, tier, rarity_limit: rarity_limit, cooldown_limit: cooldown_limit)
    next [] unless picker

    PickForDivisionRarityAndQuality.call!(
      **context.to_h, allocations: allocations[tier], picker: picker
    ).cards_picked
  end
end