sorare-rewards 1.0.2 → 1.1.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd12e11f5b4eb146655a6944d6ffd4b541a3cfe926e38b5bb77e7235d4cc92fd
|
4
|
+
data.tar.gz: 12acbcb47c3d6f366855278b96d75ab787414f802cbbfe9c597f98a96867c8ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 858689cacfc5e20404a485c5500266c613c47ec4838fbf909b7975594a6e1eb59cc96d0e3fa14cdc3cfdf4cea2b0f1ad9cd01adc215d02c0369d3ef02a3a7351
|
7
|
+
data.tar.gz: ba9f2aa66b4332ba1611f38a9b7fad80582bc1d03f67530bb356d203d4a71f9405ac353461ea4f6383775a03145adb923ade0762b9f1d89041299f7aa2b27e74
|
data/Gemfile.lock
CHANGED
@@ -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?
|