class Sorare::Rewards::League

League stores the reward config for a league

Attributes

config[R]
game_week[R]
name[R]
supply[R]

Public Class Methods

new(name:, config:, supply:, game_week:) click to toggle source
# File lib/sorare/rewards/league.rb, line 13
def initialize(name:, config:, supply:, game_week:)
  @name = name
  @config = config
  @supply = supply
  @game_week = game_week
end

Public Instance Methods

cards_in_circulation_limit(rarity) click to toggle source
# File lib/sorare/rewards/league.rb, line 26
def cards_in_circulation_limit(rarity)
  return unless cards_in_circulation&.dig(rarity) && game_week.config.rewards_ratio_per_cards_in_circulation

  (cards_in_circulation[rarity] * game_week.config.rewards_ratio_per_cards_in_circulation).floor
end
each_division_prize_pools() { |index| ... } click to toggle source
# File lib/sorare/rewards/league.rb, line 32
def each_division_prize_pools
  prize_pools.each_with_index do |prize_pool, index|
    return to_enum(:each_division_prize_pools) unless block_given?

    yield(index + 1, prize_pool)
  end
end
each_rarity_supply() { |rarity, supply| ... } click to toggle source
# File lib/sorare/rewards/league.rb, line 40
def each_rarity_supply
  supply.each_key do |rarity|
    return to_enum(:each_rarity_supply) unless block_given?

    yield(rarity, supply[rarity])
  end
end
each_rarity_tier_supply() { |rarity, transformed_tier, qualified_supply| ... } click to toggle source
# File lib/sorare/rewards/league.rb, line 48
def each_rarity_tier_supply
  each_rarity_supply do |rarity, rarity_supply|
    qualified_supply = Tiers::QualifyPlayers.call!(sorted_supply: rarity_supply).players
    qualified_supply.each_key.map do |tier|
      return to_enum(:each_rarity_tier_supply) unless block_given?

      transformed_tier = Sorare::Rewards.configuration.transform_tier.call(tier)
      yield(rarity, transformed_tier, qualified_supply[tier])
    end
  end
end