Class: Sorare::Rewards::GameWeekRewards

Inherits:
Object
  • Object
show all
Defined in:
lib/sorare/rewards/game_week_rewards.rb

Overview

GameWeekRewards stores rewards related data for a specified GameWeek, salt, And a card allocations hash

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

Constant Summary collapse

MISSING_PARAMETER =
'%s parameter required'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(game_week:, salt: nil, card_allocations: nil, rarity_limit: true, cooldown_limit: true) ⇒ GameWeekRewards

Returns a new instance of GameWeekRewards.



19
20
21
22
23
24
25
# File 'lib/sorare/rewards/game_week_rewards.rb', line 19

def initialize(game_week:, salt: nil, card_allocations: nil, rarity_limit: true, cooldown_limit: true)
  @game_week = game_week
  @salt = salt || game_week.salt
  @card_allocations = card_allocations || computed_card_allocations
  @rarity_limit = rarity_limit
  @cooldown_limit = cooldown_limit
end

Instance Attribute Details

#card_allocationsObject (readonly)

Returns the value of attribute card_allocations.



15
16
17
# File 'lib/sorare/rewards/game_week_rewards.rb', line 15

def card_allocations
  @card_allocations
end

#cooldown_limitObject (readonly)

Returns the value of attribute cooldown_limit.



15
16
17
# File 'lib/sorare/rewards/game_week_rewards.rb', line 15

def cooldown_limit
  @cooldown_limit
end

#game_weekObject (readonly)

Returns the value of attribute game_week.



15
16
17
# File 'lib/sorare/rewards/game_week_rewards.rb', line 15

def game_week
  @game_week
end

#rarity_limitObject (readonly)

Returns the value of attribute rarity_limit.



15
16
17
# File 'lib/sorare/rewards/game_week_rewards.rb', line 15

def rarity_limit
  @rarity_limit
end

#saltObject (readonly)

Returns the value of attribute salt.



15
16
17
# File 'lib/sorare/rewards/game_week_rewards.rb', line 15

def salt
  @salt
end

Instance Method Details

#cardsObject



27
28
29
30
31
32
33
34
35
# File 'lib/sorare/rewards/game_week_rewards.rb', line 27

def cards
  @cards ||= Sorare::Rewards::Pick.call!(
    salt: salt,
    game_week: game_week,
    card_allocations: card_allocations,
    rarity_limit: rarity_limit,
    cooldown_limit: cooldown_limit
  ).cards_picked
end

#computed_card_allocationsObject



47
48
49
# File 'lib/sorare/rewards/game_week_rewards.rb', line 47

def computed_card_allocations
  Transposer.transpose_allocations(reward_allocations.card_allocations)
end

#prize_poolsObject



37
38
39
# File 'lib/sorare/rewards/game_week_rewards.rb', line 37

def prize_pools
  @prize_pools ||= reward_allocations.prize_pools
end

#reward_allocationsObject



41
42
43
44
45
# File 'lib/sorare/rewards/game_week_rewards.rb', line 41

def reward_allocations
  validate!(:salt)

  @reward_allocations ||= Sorare::Rewards::Build.call!(game_week: game_week, salt: salt)
end