sorare-rewards 1.0.1 → 1.1.2
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/supply/compute_for_rarity.rb +27 -17
- data/lib/sorare/rewards/league.rb +7 -1
- 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: df838191acb56979062609ee4184646e5c45381610efe994cc3c7e84d397aac7
|
4
|
+
data.tar.gz: 300f47f3db86b1ea465360f15c59fa926b78544b70bf3c3242972c28213a51f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29ee679bddd7d79e01c96b3a15331d8c5946ea3cde90650d7afbc68b66a699e21739774a942b1cd2c45c991ce53eb984914d30890c1dc2abcc00ba245ff03775
|
7
|
+
data.tar.gz: 8375b5b15925506505a29fc39e41b7bf8a7dbdbe6f0895abb03d768fd69c99d515ce7aaacf6134d9a2f46b5a9686428d966c4d5f82e1ff0f2571d20ee456042d
|
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.2)
|
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,
|
@@ -16,39 +16,49 @@ 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_contribution(player) }
|
27
25
|
|
28
|
-
|
26
|
+
round_and_cap_league_supply(total_float_supply)
|
29
27
|
end
|
30
28
|
|
31
29
|
def distribute_in_tiers!
|
32
30
|
ctx = Tiers::QualifySupply.call!(sorted_supply: supply)
|
33
|
-
|
31
|
+
qualified_players = Tiers::QualifyPlayers.call!(sorted_supply: supply).players
|
32
|
+
ctx.supply.each_with_index do |tier_supply, index|
|
34
33
|
rarity_supply.push(
|
35
|
-
|
36
|
-
randomizer: randomizer,
|
37
|
-
total_supply: ctx.count,
|
38
|
-
tier_supply: tier_supply,
|
39
|
-
rewardable: rewardable,
|
40
|
-
rewarded: rarity_supply
|
41
|
-
).quality_supply
|
34
|
+
capped_tier_supply(ctx.count, tier_supply, rewardable, qualified_players[index])
|
42
35
|
)
|
43
36
|
end
|
44
37
|
end
|
45
38
|
|
46
|
-
|
39
|
+
# Cap with the actual pickable supply for the tier
|
40
|
+
def capped_tier_supply(total_supply, tier_supply, rewardable, tier_players)
|
41
|
+
target = ComputeForQuality.call!(
|
42
|
+
randomizer: randomizer, total_supply: total_supply,
|
43
|
+
tier_supply: tier_supply, rewardable: rewardable, rewarded: rarity_supply
|
44
|
+
).quality_supply
|
45
|
+
|
46
|
+
[target, tier_players.sum { |player| player_pickable_supply(player) }].min
|
47
|
+
end
|
48
|
+
|
49
|
+
def round_and_cap_league_supply(float_supply)
|
50
|
+
[
|
51
|
+
float_supply.floor + remaining_supply(float_supply.modulo(1)), # Supply limit
|
52
|
+
league.cards_in_circulation_limit(rarity) # Circulation limit
|
53
|
+
].compact.min
|
54
|
+
end
|
55
|
+
|
56
|
+
def player_contribution(slug)
|
47
57
|
game_week.player(slug).reward_pool_supply_contribution(league, rarity)
|
48
58
|
end
|
49
59
|
|
50
|
-
def
|
51
|
-
|
60
|
+
def player_pickable_supply(slug)
|
61
|
+
game_week.player(slug).pickable_supply(league, rarity)
|
52
62
|
end
|
53
63
|
|
54
64
|
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?
|
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.2
|
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-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|