sorare-rewards 1.3.0 → 1.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -0
- data/CHANGELOG.md +18 -0
- data/Gemfile.lock +17 -16
- data/README.md +2 -5
- data/lib/sorare/rewards/game_week.rb +4 -4
- data/lib/sorare/rewards/league.rb +10 -2
- data/lib/sorare/rewards/version.rb +1 -1
- data/lib/sorare/rewards.rb +0 -1
- data/sorare-rewards.gemspec +3 -5
- metadata +22 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8641fffa2c82df83b2e775393fbc68ae16d99857695061d1a8b8af33017c4971
|
4
|
+
data.tar.gz: dc828084b6b07733bb8725e3d62d302ab3601c260c5ed7fbaf81039167df4a07
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce2bd4d025e0d1efcf6bf8bbefa6e9ff992d751cedaed1a582e07ebe380a6eae2cc4148ebc49be595a5345e8bda235096e287f0cb549a5f9b01f237c86b3d496
|
7
|
+
data.tar.gz: 6a9d835f7cd4c8237676c5b47e7ee6e122162ae1606062a9521754cca70d392941ff0a94413ba69c8e5bbd5dff29fe703dcc009290c766a3422b757e2d81319f
|
data/.rubocop.yml
CHANGED
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,41 +1,39 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
sorare-rewards (1.3
|
4
|
+
sorare-rewards (1.4.3)
|
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.
|
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)
|
18
17
|
tzinfo (~> 2.0)
|
19
18
|
zeitwerk (~> 2.3)
|
19
|
+
addressable (2.8.0)
|
20
|
+
public_suffix (>= 2.0.2, < 5.0)
|
20
21
|
ast (2.4.2)
|
21
22
|
concurrent-ruby (1.1.9)
|
23
|
+
crack (0.4.5)
|
24
|
+
rexml
|
22
25
|
diff-lcs (1.4.4)
|
23
|
-
|
26
|
+
hashdiff (1.0.1)
|
27
|
+
i18n (1.8.11)
|
24
28
|
concurrent-ruby (~> 1.0)
|
25
29
|
interactor (3.1.2)
|
26
|
-
io-wait (0.1.0)
|
27
30
|
json (2.6.0)
|
28
|
-
minitest (5.
|
29
|
-
net-http (0.1.1)
|
30
|
-
net-protocol
|
31
|
-
uri
|
32
|
-
net-protocol (0.1.2)
|
33
|
-
io-wait
|
34
|
-
timeout
|
31
|
+
minitest (5.15.0)
|
35
32
|
ostruct (0.4.0)
|
36
33
|
parallel (1.21.0)
|
37
34
|
parser (3.0.2.0)
|
38
35
|
ast (~> 2.4.1)
|
36
|
+
public_suffix (4.0.6)
|
39
37
|
rainbow (3.0.0)
|
40
38
|
rake (12.3.3)
|
41
39
|
regexp_parser (2.1.1)
|
@@ -69,13 +67,15 @@ GEM
|
|
69
67
|
rubocop-rspec (2.5.0)
|
70
68
|
rubocop (~> 1.19)
|
71
69
|
ruby-progressbar (1.11.0)
|
72
|
-
timeout (0.2.0)
|
73
70
|
tzinfo (2.0.4)
|
74
71
|
concurrent-ruby (~> 1.0)
|
75
72
|
unicode-display_width (2.1.0)
|
76
|
-
|
73
|
+
webmock (3.14.0)
|
74
|
+
addressable (>= 2.8.0)
|
75
|
+
crack (>= 0.3.2)
|
76
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
77
77
|
yaml (0.2.0)
|
78
|
-
zeitwerk (2.5.
|
78
|
+
zeitwerk (2.5.1)
|
79
79
|
|
80
80
|
PLATFORMS
|
81
81
|
ruby
|
@@ -88,6 +88,7 @@ DEPENDENCIES
|
|
88
88
|
rubocop-rake (~> 0.6.0)
|
89
89
|
rubocop-rspec (~> 2.5.0)
|
90
90
|
sorare-rewards!
|
91
|
+
webmock (~> 3.14.0)
|
91
92
|
|
92
93
|
BUNDLED WITH
|
93
|
-
2.2.
|
94
|
+
2.2.30
|
data/README.md
CHANGED
@@ -10,15 +10,14 @@ gem 'sorare-rewards'
|
|
10
10
|
|
11
11
|
And then execute:
|
12
12
|
|
13
|
-
|
13
|
+
$ bundle install
|
14
14
|
|
15
15
|
Or install it yourself as:
|
16
16
|
|
17
|
-
|
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,8 +1,8 @@
|
|
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'
|
5
|
+
require 'open-uri'
|
6
6
|
|
7
7
|
module Sorare
|
8
8
|
module Rewards
|
@@ -11,7 +11,7 @@ module Sorare
|
|
11
11
|
attr_reader :salt
|
12
12
|
|
13
13
|
def initialize(data: nil, hash: nil, salt: nil)
|
14
|
-
@uri = URI("#{Sorare::Rewards.configuration.gateway}#{hash}")
|
14
|
+
@uri = URI.parse("#{Sorare::Rewards.configuration.gateway}#{hash}")
|
15
15
|
@data = data
|
16
16
|
@salt = salt
|
17
17
|
end
|
@@ -23,11 +23,11 @@ module Sorare
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def data
|
26
|
-
@data ||= JSON.parse(
|
26
|
+
@data ||= JSON.parse(@uri.open.read)
|
27
27
|
end
|
28
28
|
|
29
29
|
def config
|
30
|
-
@config ||= GameWeekConfig.new(
|
30
|
+
@config ||= GameWeekConfig.new(data['config'])
|
31
31
|
end
|
32
32
|
|
33
33
|
def supply_for(league, rarity: nil, player: nil)
|
@@ -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) &&
|
27
|
+
return unless cards_in_circulation&.dig(rarity) && rewards_ratio_per_cards_in_circulation_for_rarity(rarity)
|
28
28
|
|
29
|
-
(cards_in_circulation[rarity] *
|
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
|
data/lib/sorare/rewards.rb
CHANGED
data/sorare-rewards.gemspec
CHANGED
@@ -2,12 +2,11 @@
|
|
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
|
9
|
-
spec.authors = ['
|
10
|
-
spec.email = ['
|
8
|
+
spec.authors = ['Sorare team']
|
9
|
+
spec.email = ['hello@sorare.com']
|
11
10
|
|
12
11
|
spec.summary = %w[Sorare reward allocation algorithm]
|
13
12
|
# spec.description = %q{TODO: Write a longer description or delete this line.}
|
@@ -33,12 +32,11 @@ 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'
|
40
38
|
spec.add_development_dependency 'rubocop', '~> 1.22.1'
|
41
39
|
spec.add_development_dependency 'rubocop-rake', '~> 0.6.0'
|
42
40
|
spec.add_development_dependency 'rubocop-rspec', '~> 2.5.0'
|
41
|
+
spec.add_development_dependency 'webmock', '~> 3.14.0'
|
43
42
|
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
|
4
|
+
version: 1.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
8
|
-
autorequire:
|
7
|
+
- Sorare team
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-03 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,9 +136,23 @@ dependencies:
|
|
150
136
|
- - "~>"
|
151
137
|
- !ruby/object:Gem::Version
|
152
138
|
version: 2.5.0
|
153
|
-
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: webmock
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 3.14.0
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 3.14.0
|
153
|
+
description:
|
154
154
|
email:
|
155
|
-
-
|
155
|
+
- hello@sorare.com
|
156
156
|
executables: []
|
157
157
|
extensions: []
|
158
158
|
extra_rdoc_files: []
|
@@ -211,7 +211,7 @@ licenses:
|
|
211
211
|
metadata:
|
212
212
|
homepage_uri: https://gitlab.com/sorare/sorare-rewards
|
213
213
|
source_code_uri: https://gitlab.com/sorare/sorare-rewards
|
214
|
-
post_install_message:
|
214
|
+
post_install_message:
|
215
215
|
rdoc_options: []
|
216
216
|
require_paths:
|
217
217
|
- lib
|
@@ -227,7 +227,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
227
227
|
version: '0'
|
228
228
|
requirements: []
|
229
229
|
rubygems_version: 3.2.22
|
230
|
-
signing_key:
|
230
|
+
signing_key:
|
231
231
|
specification_version: 4
|
232
232
|
summary: '["Sorare", "reward", "allocation", "algorithm"]'
|
233
233
|
test_files: []
|