Class: Sorare::Rewards::CardPicker
- Inherits:
-
FlatPicker
- Object
- FlatPicker
- Sorare::Rewards::CardPicker
- Defined in:
- lib/sorare/rewards/card_picker.rb
Overview
CardPicker allows to randomly pick card rewards for a league
Instance Attribute Summary collapse
-
#league ⇒ Object
readonly
Returns the value of attribute league.
-
#limits ⇒ Object
readonly
Returns the value of attribute limits.
-
#quality ⇒ Object
readonly
Returns the value of attribute quality.
-
#rarity ⇒ Object
readonly
Returns the value of attribute rarity.
Attributes inherited from FlatPicker
Instance Method Summary collapse
-
#initialize(league, rarity, quality, rarity_limit: true, cooldown_limit: true) ⇒ CardPicker
constructor
A new instance of CardPicker.
- #pick ⇒ Object
- #valid_pick?(player) ⇒ Boolean
Methods inherited from FlatPicker
Constructor Details
#initialize(league, rarity, quality, rarity_limit: true, cooldown_limit: true) ⇒ CardPicker
Returns a new instance of CardPicker.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/sorare/rewards/card_picker.rb', line 11 def initialize(league, rarity, quality, rarity_limit: true, cooldown_limit: true) super(league.public_seed, league.salt) @league = league @rarity = rarity @quality = quality @limits = %i[overall].tap do |l| l << :cooldowned if cooldown_limit l << :limited if rarity_limit end load_picker end |
Instance Attribute Details
#league ⇒ Object (readonly)
Returns the value of attribute league.
9 10 11 |
# File 'lib/sorare/rewards/card_picker.rb', line 9 def league @league end |
#limits ⇒ Object (readonly)
Returns the value of attribute limits.
9 10 11 |
# File 'lib/sorare/rewards/card_picker.rb', line 9 def limits @limits end |
#quality ⇒ Object (readonly)
Returns the value of attribute quality.
9 10 11 |
# File 'lib/sorare/rewards/card_picker.rb', line 9 def quality @quality end |
#rarity ⇒ Object (readonly)
Returns the value of attribute rarity.
9 10 11 |
# File 'lib/sorare/rewards/card_picker.rb', line 9 def rarity @rarity end |
Instance Method Details
#pick ⇒ Object
24 25 26 27 28 29 |
# File 'lib/sorare/rewards/card_picker.rb', line 24 def pick player = super return player if valid_pick?(player) pick end |
#valid_pick?(player) ⇒ Boolean
31 32 33 34 |
# File 'lib/sorare/rewards/card_picker.rb', line 31 def valid_pick?(player) current_player_limit = limits.map { |l| supply_for(player).send(l) }.min picked_count(player) <= current_player_limit end |