Sorare::Rewards

Installation

Add this line to your application's Gemfile:

gem 'sorare-rewards'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install sorare-rewards

Usage

First you need to load a game week

game_week = Sorare::Rewards::GameWeek.new(hash: 'QmbwCo1fuhRN1T2DyEQtETefsBH6yCj8h7VjMW5iGfT11Z', salt: 'dce0053984405687efcdf3d1a61ffa67')

Game Week's hash and salt can be retrieved using the GQL API, the salt is made public after the rewards have been distributed.

To compute rewards for a game week :

rewards = Sorare::Rewards::GameWeekRewards.new(game_week: game_week)

# Cards allocations :
rewards.card_allocations

# Cards :
rewards.cards

# Prize pools :
rewards.prize_pools

By default it uses the computed card allocations to pick the rewards. To override it :

card_allocations = {
  'global_all-star' => {
    'D1' => {
      'rare' => {
        'tier_0' => 1,
        ...
      }
    }
  }
}

rewards = Sorare::Rewards::GameWeekRewards.new(game_week: game_week, card_allocations: card_allocations)

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

License

The gem is available as open source under the terms of the MIT License.