class Sorare::Rewards::Cards::PickForDivisionRarityAndQuality
PickForDivisionRarityAndQuality
picks the rewards for a given division, rarity, and quality Receive a picker A game week data And a reward allocations
15
Constants
- MISSING_CARDS
Public Instance Methods
call()
click to toggle source
# File lib/sorare/rewards/interactors/cards/pick_for_division_rarity_and_quality.rb, line 21 def call context.cards_picked = [] pick! check_length! unless force reorder! end
check_length!()
click to toggle source
# File lib/sorare/rewards/interactors/cards/pick_for_division_rarity_and_quality.rb, line 46 def check_length! return if cards_picked.length == allocations context.fail!(error: MISSING_CARDS) end
pick!()
click to toggle source
# File lib/sorare/rewards/interactors/cards/pick_for_division_rarity_and_quality.rb, line 29 def pick! pick_if_available! while cards_picked.length != allocations && picker.length.positive? end
pick_if_available!()
click to toggle source
# File lib/sorare/rewards/interactors/cards/pick_for_division_rarity_and_quality.rb, line 33 def pick_if_available! player = picker.pick return if picker.player_counter[player] > game_week.player(player).pickable_supply(league, rarity) cards_picked.push(player) end
reorder!()
click to toggle source
# File lib/sorare/rewards/interactors/cards/pick_for_division_rarity_and_quality.rb, line 40 def reorder! cards_picked.sort! do |a, b| game_week.player(a).rank(league, rarity) <=> game_week.player(b).rank(league, rarity) end end