sorare-rewards 1.3.0.beta0 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f21a3d6ed4a19177ff92d64b89a4f605f76de64f3f7d1cc077d9d59a5f241c7c
4
- data.tar.gz: cdfc9b29382f52800871f27533b1d5dcfa7795bc35c7f223d9a19f02287d245b
3
+ metadata.gz: f6d8d21c6c8da818dfecacdb8ff179dfa81e39d01f8470f1009b36afe45a06c2
4
+ data.tar.gz: 0303c1e4e365b4879712cab90da1553e60cc07b78d0810b2790720e31365be2a
5
5
  SHA512:
6
- metadata.gz: 3d4d20f37c3072805b4d6927936f959b7639ae0904fbd327e9aa709fd33d8c1360aa0d45d949402c250f57878bd06b19b8d1406d9a11999b62322c3d05276b8e
7
- data.tar.gz: 6deb5eb9c375f07b3f6c20107155019782dc3fab546de56bf7979fc131a927077575822b5111235cd16bcc842b851f74524848bf12c4436c2f3514e738f6ae8b
6
+ metadata.gz: 5facf11a38d2ec192177f46f4b13b2a3f4d63379b8d586266255f5dae906b7a0ed660d0cf3166b68399c1269dd271e0f63711569744587839ce63b52934416ee
7
+ data.tar.gz: de7c3eed4459e498e528c419ade463e1972082d251559ce75908152ca6869e9535f2334e86604fa51a79c1dbc2de09efebbe0e2eee4450b213e37a8c8da3df54
data/CHANGELOG.md CHANGED
@@ -1,11 +1,29 @@
1
+ ## [1.4.1] - 2021-12-14
2
+
3
+ ### Fixes
4
+
5
+ - Fix an issue where the `config` was null when accessed on a `GameWeek` with no loaded data
6
+
7
+ ## [1.4.0] - 2021-12-14
8
+
9
+ ### Added
10
+
11
+ - Added support for rarity based `rewards_ratio_per_cards_in_circulation`
12
+
1
13
  ## [1.3.0] - 2021-11-02
14
+
2
15
  ### Breaking
16
+
3
17
  - Removed rewards method from `GameWeek` (`card_rewards`, `cards_picked`, `reward_allocations`, `prize_pools`, `card_allocations`)
4
18
  - `Picker` has been renamed to `CardPicker`
19
+
5
20
  ### Added
21
+
6
22
  - Added a `GameWeekRewards` class that provides all rewards related methods
7
23
  - Added a way to pick cards with a custom `card_allocations`
8
24
 
9
25
  ## [1.2.0] - 2021-11-02
26
+
10
27
  ### Added
28
+
11
29
  - Enable cross leagues cooldown using `per_league` configuration flag
data/Gemfile.lock CHANGED
@@ -1,17 +1,16 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sorare-rewards (1.3.0.beta0)
4
+ sorare-rewards (1.4.2)
5
5
  activesupport (~> 6.1.4)
6
6
  interactor (~> 3.1.2)
7
7
  json (~> 2)
8
- net-http (~> 0.1.1)
9
8
  yaml (~> 0.2.0)
10
9
 
11
10
  GEM
12
11
  remote: https://rubygems.org/
13
12
  specs:
14
- activesupport (6.1.4.1)
13
+ activesupport (6.1.4.3)
15
14
  concurrent-ruby (~> 1.0, >= 1.0.2)
16
15
  i18n (>= 1.6, < 2)
17
16
  minitest (>= 5.1)
@@ -20,18 +19,11 @@ GEM
20
19
  ast (2.4.2)
21
20
  concurrent-ruby (1.1.9)
22
21
  diff-lcs (1.4.4)
23
- i18n (1.8.10)
22
+ i18n (1.8.11)
24
23
  concurrent-ruby (~> 1.0)
25
24
  interactor (3.1.2)
26
- io-wait (0.1.0)
27
25
  json (2.6.0)
28
- minitest (5.14.4)
29
- net-http (0.1.1)
30
- net-protocol
31
- uri
32
- net-protocol (0.1.2)
33
- io-wait
34
- timeout
26
+ minitest (5.15.0)
35
27
  ostruct (0.4.0)
36
28
  parallel (1.21.0)
37
29
  parser (3.0.2.0)
@@ -69,13 +61,11 @@ GEM
69
61
  rubocop-rspec (2.5.0)
70
62
  rubocop (~> 1.19)
71
63
  ruby-progressbar (1.11.0)
72
- timeout (0.2.0)
73
64
  tzinfo (2.0.4)
74
65
  concurrent-ruby (~> 1.0)
75
66
  unicode-display_width (2.1.0)
76
- uri (0.11.0)
77
67
  yaml (0.2.0)
78
- zeitwerk (2.5.0)
68
+ zeitwerk (2.5.1)
79
69
 
80
70
  PLATFORMS
81
71
  ruby
@@ -90,4 +80,4 @@ DEPENDENCIES
90
80
  sorare-rewards!
91
81
 
92
82
  BUNDLED WITH
93
- 2.2.22
83
+ 2.2.30
data/README.md CHANGED
@@ -10,15 +10,14 @@ gem 'sorare-rewards'
10
10
 
11
11
  And then execute:
12
12
 
13
- $ bundle install
13
+ $ bundle install
14
14
 
15
15
  Or install it yourself as:
16
16
 
17
- $ gem install sorare-rewards
17
+ $ gem install sorare-rewards
18
18
 
19
19
  ## Usage
20
20
 
21
-
22
21
  First you need to load a game week
23
22
 
24
23
  ```ruby
@@ -27,7 +26,6 @@ game_week = Sorare::Rewards::GameWeek.new(hash: 'QmbwCo1fuhRN1T2DyEQtETefsBH6yCj
27
26
 
28
27
  Game Week's `hash` and `salt` can be retrieved using the GQL API, the salt is made public after the rewards have been distributed.
29
28
 
30
-
31
29
  To compute rewards for a game week :
32
30
 
33
31
  ```ruby
@@ -67,7 +65,6 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
67
65
 
68
66
  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](https://rubygems.org).
69
67
 
70
-
71
68
  ## License
72
69
 
73
70
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'json'
4
- require 'net/http'
5
4
  require 'active_support/core_ext/module/delegation'
6
5
 
7
6
  module Sorare
@@ -11,7 +10,7 @@ module Sorare
11
10
  attr_reader :salt
12
11
 
13
12
  def initialize(data: nil, hash: nil, salt: nil)
14
- @uri = URI("#{Sorare::Rewards.configuration.gateway}#{hash}")
13
+ @uri = URI.parse("#{Sorare::Rewards.configuration.gateway}#{hash}")
15
14
  @data = data
16
15
  @salt = salt
17
16
  end
@@ -23,11 +22,11 @@ module Sorare
23
22
  end
24
23
 
25
24
  def data
26
- @data ||= JSON.parse(::Net::HTTP.get(@uri))
25
+ @data ||= JSON.parse(@uri.open)
27
26
  end
28
27
 
29
28
  def config
30
- @config ||= GameWeekConfig.new(@data['config'])
29
+ @config ||= GameWeekConfig.new(data['config'])
31
30
  end
32
31
 
33
32
  def supply_for(league, rarity: nil, player: nil)
@@ -19,6 +19,7 @@ module Sorare
19
19
 
20
20
  delegate :league, :allocations, :pickers, to: :context
21
21
  delegate :game_week, to: :league
22
+ delegate :public_seed, :salt, to: :game_week
22
23
 
23
24
  def call
24
25
  context.pickers = {}
@@ -48,7 +49,7 @@ module Sorare
48
49
  end
49
50
 
50
51
  def initialize_tier_picker(players, rarity, tier)
51
- pickers[rarity][tier] = CardPicker.new(game_week.public_seed, game_week.salt)
52
+ pickers[rarity][tier] = CardPicker.new(public_seed, salt)
52
53
 
53
54
  players.each do |slug, _|
54
55
  pickers[rarity][tier].add_player(slug, player_supply(rarity, slug))
@@ -24,9 +24,17 @@ module Sorare
24
24
  end
25
25
 
26
26
  def cards_in_circulation_limit(rarity)
27
- return unless cards_in_circulation&.dig(rarity) && game_week.config.rewards_ratio_per_cards_in_circulation
27
+ return unless cards_in_circulation&.dig(rarity) && rewards_ratio_per_cards_in_circulation_for_rarity(rarity)
28
28
 
29
- (cards_in_circulation[rarity] * game_week.config.rewards_ratio_per_cards_in_circulation).floor
29
+ (cards_in_circulation[rarity] * rewards_ratio_per_cards_in_circulation_for_rarity(rarity)).floor
30
+ end
31
+
32
+ def rewards_ratio_per_cards_in_circulation_for_rarity(rarity)
33
+ if game_week.config.rewards_ratio_per_cards_in_circulation.is_a?(Hash)
34
+ return game_week.config.rewards_ratio_per_cards_in_circulation[rarity]
35
+ end
36
+
37
+ game_week.config.rewards_ratio_per_cards_in_circulation
30
38
  end
31
39
 
32
40
  def each_division_prize_pools
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sorare
4
4
  module Rewards
5
- VERSION = '1.3.0.beta0'
5
+ VERSION = '1.4.2'
6
6
  end
7
7
  end
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'json'
4
- require 'net/http'
5
4
  require 'digest'
6
5
 
7
6
  Dir["#{File.dirname(__FILE__)}/rewards/**/*.rb"].sort.each do |file|
@@ -2,7 +2,6 @@
2
2
 
3
3
  require_relative 'lib/sorare/rewards/version'
4
4
 
5
- # rubocop:disable Metrics/BlockLength
6
5
  Gem::Specification.new do |spec|
7
6
  spec.name = 'sorare-rewards'
8
7
  spec.version = Sorare::Rewards::VERSION
@@ -33,7 +32,6 @@ Gem::Specification.new do |spec|
33
32
  spec.add_dependency 'activesupport', '~> 6.1.4'
34
33
  spec.add_dependency 'interactor', '~> 3.1.2'
35
34
  spec.add_dependency 'json', '~> 2'
36
- spec.add_dependency 'net-http', '~> 0.1.1'
37
35
  spec.add_dependency 'yaml', '~> 0.2.0'
38
36
  spec.add_development_dependency 'ostruct', '~> 0.4.0'
39
37
  spec.add_development_dependency 'rspec', '~> 3.10'
@@ -41,4 +39,3 @@ Gem::Specification.new do |spec|
41
39
  spec.add_development_dependency 'rubocop-rake', '~> 0.6.0'
42
40
  spec.add_development_dependency 'rubocop-rspec', '~> 2.5.0'
43
41
  end
44
- # rubocop:enable Metrics/BlockLength
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sorare-rewards
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0.beta0
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - pierre
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-11-16 00:00:00.000000000 Z
11
+ date: 2021-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -52,20 +52,6 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '2'
55
- - !ruby/object:Gem::Dependency
56
- name: net-http
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: 0.1.1
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: 0.1.1
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: yaml
71
57
  requirement: !ruby/object:Gem::Requirement
@@ -150,7 +136,7 @@ dependencies:
150
136
  - - "~>"
151
137
  - !ruby/object:Gem::Version
152
138
  version: 2.5.0
153
- description:
139
+ description:
154
140
  email:
155
141
  - pierre@sorare.com
156
142
  executables: []
@@ -211,7 +197,7 @@ licenses:
211
197
  metadata:
212
198
  homepage_uri: https://gitlab.com/sorare/sorare-rewards
213
199
  source_code_uri: https://gitlab.com/sorare/sorare-rewards
214
- post_install_message:
200
+ post_install_message:
215
201
  rdoc_options: []
216
202
  require_paths:
217
203
  - lib
@@ -222,12 +208,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
222
208
  version: 2.7.1
223
209
  required_rubygems_version: !ruby/object:Gem::Requirement
224
210
  requirements:
225
- - - ">"
211
+ - - ">="
226
212
  - !ruby/object:Gem::Version
227
- version: 1.3.1
213
+ version: '0'
228
214
  requirements: []
229
- rubygems_version: 3.2.22
230
- signing_key:
215
+ rubygems_version: 3.3.3
216
+ signing_key:
231
217
  specification_version: 4
232
218
  summary: '["Sorare", "reward", "allocation", "algorithm"]'
233
219
  test_files: []