sorare-rewards 1.0.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +6 -2
- data/lib/sorare/rewards/allocation_configuration.yml +32 -0
- data/lib/sorare/rewards/game_week_config.rb +1 -1
- data/lib/sorare/rewards/interactors/allocations/compute_for_league.rb +8 -6
- data/lib/sorare/rewards/interactors/allocations/compute_for_quality.rb +1 -1
- data/lib/sorare/rewards/interactors/allocations/compute_for_rarity.rb +7 -1
- data/lib/sorare/rewards/interactors/cards/pick_for_division_rarity_and_quality.rb +1 -1
- data/lib/sorare/rewards/interactors/supply/compute_for_rarity.rb +11 -10
- data/lib/sorare/rewards/league.rb +7 -1
- data/lib/sorare/rewards/player.rb +13 -4
- data/lib/sorare/rewards/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6897c498226e4f66e5b2a8aa93cd8b46478cc5d48d445950313224fae955922
|
4
|
+
data.tar.gz: 6a317d2b7767bb86bba95b485516923c1f4fe04780507d068b8d5ebd4a34a836
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0000887adec07808ab805e1045b196cd413015dd4e99a0b7df65fcf08a6cdf1f7cadd34c976a8da21cbbe72b583f5166e970a624645f02e64c5a77dbc1b119b
|
7
|
+
data.tar.gz: 72f565145aade90fc49552c1940da0e6f93f9e4f80dc179fb90ff9c20ed2c287ab241e5755bab1f750b3e9a8f4a61425b262729cf0e326465be201a35dfdfccc
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
sorare-rewards (1.
|
4
|
+
sorare-rewards (1.1.1)
|
5
5
|
activesupport (~> 6.1)
|
6
6
|
interactor (~> 3.0)
|
7
7
|
json (~> 2)
|
@@ -23,12 +23,15 @@ GEM
|
|
23
23
|
i18n (1.8.10)
|
24
24
|
concurrent-ruby (~> 1.0)
|
25
25
|
interactor (3.1.2)
|
26
|
+
io-wait (0.1.0)
|
26
27
|
json (2.5.1)
|
27
28
|
minitest (5.14.4)
|
28
29
|
net-http (0.1.1)
|
29
30
|
net-protocol
|
30
31
|
uri
|
31
|
-
net-protocol (0.1.
|
32
|
+
net-protocol (0.1.1)
|
33
|
+
io-wait
|
34
|
+
timeout
|
32
35
|
ostruct (0.2.0)
|
33
36
|
parallel (1.20.1)
|
34
37
|
parser (3.0.1.0)
|
@@ -67,6 +70,7 @@ GEM
|
|
67
70
|
rubocop (~> 1.0)
|
68
71
|
rubocop-ast (>= 1.1.0)
|
69
72
|
ruby-progressbar (1.11.0)
|
73
|
+
timeout (0.1.1)
|
70
74
|
tzinfo (2.0.4)
|
71
75
|
concurrent-ruby (~> 1.0)
|
72
76
|
unicode-display_width (2.0.0)
|
@@ -1,3 +1,29 @@
|
|
1
|
+
limited: &limited
|
2
|
+
tier_0:
|
3
|
+
- pct: 0
|
4
|
+
- pct: 0
|
5
|
+
- pct: 0
|
6
|
+
- pct: 0
|
7
|
+
- pct: 0.33
|
8
|
+
tier_1:
|
9
|
+
- pct: 0
|
10
|
+
- pct: 0
|
11
|
+
- pct: 0
|
12
|
+
- pct: 0
|
13
|
+
- pct: 0.33
|
14
|
+
tier_2:
|
15
|
+
- pct: 0
|
16
|
+
- pct: 0
|
17
|
+
- pct: 0
|
18
|
+
- pct: 0
|
19
|
+
- pct: 0.8
|
20
|
+
tier_3:
|
21
|
+
- pct: 0
|
22
|
+
- pct: 0
|
23
|
+
- pct: 0
|
24
|
+
- pct: 0
|
25
|
+
- pct: 1
|
26
|
+
|
1
27
|
rare: &rare
|
2
28
|
tier_0:
|
3
29
|
- cards_per_loop: 0
|
@@ -44,21 +70,27 @@ super_rare: &super_rare
|
|
44
70
|
|
45
71
|
leagues:
|
46
72
|
global-all_star:
|
73
|
+
limited: *limited
|
47
74
|
rare: *rare
|
48
75
|
super_rare: *super_rare
|
49
76
|
global-under_twenty_one:
|
77
|
+
limited: *limited
|
50
78
|
rare: *rare
|
51
79
|
super_rare: *super_rare
|
52
80
|
champion-europe:
|
81
|
+
limited: *limited
|
53
82
|
rare: *rare
|
54
83
|
super_rare: *super_rare
|
55
84
|
challenger-europe:
|
85
|
+
limited: *limited
|
56
86
|
rare: *rare
|
57
87
|
super_rare: *super_rare
|
58
88
|
champion-asia:
|
89
|
+
limited: *limited
|
59
90
|
rare: *rare
|
60
91
|
super_rare: *super_rare
|
61
92
|
champion-america:
|
93
|
+
limited: *limited
|
62
94
|
rare: *rare
|
63
95
|
super_rare: *super_rare
|
64
96
|
special-weekly:
|
@@ -17,10 +17,8 @@ module Sorare
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def allocate_and_format!
|
20
|
-
|
21
|
-
|
22
|
-
allocations.keys.index_with do |rarity|
|
23
|
-
allocations[rarity].first.keys.index_with do |division|
|
20
|
+
each_rarity_allocation do |rarity|
|
21
|
+
(allocations[rarity].first || {}).keys.index_with do |division|
|
24
22
|
allocations[rarity].each_with_index.map do |qualified_allocations, tier|
|
25
23
|
[Sorare::Rewards.configuration.transform_tier.call(tier), qualified_allocations[division]]
|
26
24
|
end.to_h
|
@@ -28,8 +26,12 @@ module Sorare
|
|
28
26
|
end
|
29
27
|
end
|
30
28
|
|
31
|
-
def
|
32
|
-
|
29
|
+
def each_rarity_allocation(&block)
|
30
|
+
allocations.keys.index_with(&block)
|
31
|
+
end
|
32
|
+
|
33
|
+
def allocations
|
34
|
+
@allocations ||= (config || {}).keys.index_with do |rarity|
|
33
35
|
ComputeForRarity.call!(**context.to_h, supply: supply[rarity], config: config[rarity]).rarity_allocations
|
34
36
|
end
|
35
37
|
end
|
@@ -15,7 +15,13 @@ module Sorare
|
|
15
15
|
def call
|
16
16
|
context.fail!(error: 'Invalid config') unless config
|
17
17
|
|
18
|
-
context.rarity_allocations =
|
18
|
+
context.rarity_allocations = allocations
|
19
|
+
end
|
20
|
+
|
21
|
+
def allocations
|
22
|
+
return [] unless supply
|
23
|
+
|
24
|
+
supply.each_with_index.map do |tier_supply, tier|
|
19
25
|
ComputeForQuality.call!(
|
20
26
|
**context.to_h,
|
21
27
|
supply: tier_supply,
|
@@ -32,7 +32,7 @@ module Sorare
|
|
32
32
|
|
33
33
|
def pick_if_available!
|
34
34
|
player = picker.pick
|
35
|
-
return if picker.player_counter[player] > game_week.player(player).
|
35
|
+
return if picker.player_counter[player] > game_week.player(player).pickable_supply(league, rarity)
|
36
36
|
|
37
37
|
cards_picked.push(player)
|
38
38
|
end
|
@@ -16,16 +16,14 @@ module Sorare
|
|
16
16
|
def call
|
17
17
|
context.rarity_supply = []
|
18
18
|
|
19
|
-
context.rewardable =
|
19
|
+
context.rewardable = rewardable_supply
|
20
20
|
distribute_in_tiers!
|
21
21
|
end
|
22
22
|
|
23
|
-
def
|
24
|
-
|
25
|
-
player_supply(player)
|
26
|
-
end
|
23
|
+
def rewardable_supply
|
24
|
+
total_float_supply = supply.keys.sum { |player| player_supply(player) }
|
27
25
|
|
28
|
-
|
26
|
+
round_and_cap_supply(total_float_supply)
|
29
27
|
end
|
30
28
|
|
31
29
|
def distribute_in_tiers!
|
@@ -43,12 +41,15 @@ module Sorare
|
|
43
41
|
end
|
44
42
|
end
|
45
43
|
|
46
|
-
def
|
47
|
-
|
44
|
+
def round_and_cap_supply(float_supply)
|
45
|
+
[
|
46
|
+
float_supply.floor + remaining_supply(float_supply.modulo(1)), # Supply limit
|
47
|
+
league.cards_in_circulation_limit(rarity) # Circulation limit
|
48
|
+
].compact.min
|
48
49
|
end
|
49
50
|
|
50
|
-
def
|
51
|
-
|
51
|
+
def player_supply(slug)
|
52
|
+
game_week.player(slug).reward_pool_supply_contribution(league, rarity)
|
52
53
|
end
|
53
54
|
|
54
55
|
def remaining_supply(reward_probability)
|
@@ -17,12 +17,18 @@ module Sorare
|
|
17
17
|
@game_week = game_week
|
18
18
|
end
|
19
19
|
|
20
|
-
%w[playing_rate prize_pools].each do |key|
|
20
|
+
%w[playing_rate prize_pools cards_in_circulation].each do |key|
|
21
21
|
define_method(key) do
|
22
22
|
config[key]
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
+
def cards_in_circulation_limit(rarity)
|
27
|
+
return unless cards_in_circulation&.dig(rarity) && game_week.config.rewards_ratio_per_cards_in_circulation
|
28
|
+
|
29
|
+
(cards_in_circulation[rarity] * game_week.config.rewards_ratio_per_cards_in_circulation).floor
|
30
|
+
end
|
31
|
+
|
26
32
|
def each_division_prize_pools
|
27
33
|
prize_pools.each_with_index do |prize_pool, index|
|
28
34
|
return to_enum(:each_division_prize_pools) unless block_given?
|
@@ -25,11 +25,18 @@ module Sorare
|
|
25
25
|
@game_data.present?
|
26
26
|
end
|
27
27
|
|
28
|
-
def
|
28
|
+
def reward_pool_supply_contribution(league, rarity)
|
29
29
|
return 0 unless playing? && remaining_games_for_supply.positive?
|
30
30
|
|
31
31
|
[
|
32
|
-
uncapped_supply_for_game_week(league, rarity),
|
32
|
+
uncapped_supply_for_game_week(league, rarity),
|
33
|
+
pickable_supply(league, rarity)
|
34
|
+
].min
|
35
|
+
end
|
36
|
+
|
37
|
+
def pickable_supply(league, rarity)
|
38
|
+
[
|
39
|
+
overall_supply(league, rarity), # Remaining supply
|
33
40
|
available_during_cooldown(league, rarity), # Cooldown limit
|
34
41
|
@config.distribution_limit(rarity) # Hard limit
|
35
42
|
].min
|
@@ -52,10 +59,12 @@ module Sorare
|
|
52
59
|
end
|
53
60
|
|
54
61
|
def rewarded_during_cooldown(league, rarity)
|
55
|
-
(
|
62
|
+
(@game_data&.dig(league.name, rarity) || []).count do |at|
|
63
|
+
(Time.parse(at) + @config.cooldown_since(rarity)) > Time.now
|
64
|
+
end
|
56
65
|
end
|
57
66
|
|
58
|
-
%w[
|
67
|
+
%w[remaining_games_for_supply remaining_games].each do |key|
|
59
68
|
define_method(key) do
|
60
69
|
@game_data&.dig(key)
|
61
70
|
end
|
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.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pierre
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|