sorare-rewards 1.1.1 → 1.1.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: f6897c498226e4f66e5b2a8aa93cd8b46478cc5d48d445950313224fae955922
4
- data.tar.gz: 6a317d2b7767bb86bba95b485516923c1f4fe04780507d068b8d5ebd4a34a836
3
+ metadata.gz: df838191acb56979062609ee4184646e5c45381610efe994cc3c7e84d397aac7
4
+ data.tar.gz: 300f47f3db86b1ea465360f15c59fa926b78544b70bf3c3242972c28213a51f9
5
5
  SHA512:
6
- metadata.gz: d0000887adec07808ab805e1045b196cd413015dd4e99a0b7df65fcf08a6cdf1f7cadd34c976a8da21cbbe72b583f5166e970a624645f02e64c5a77dbc1b119b
7
- data.tar.gz: 72f565145aade90fc49552c1940da0e6f93f9e4f80dc179fb90ff9c20ed2c287ab241e5755bab1f750b3e9a8f4a61425b262729cf0e326465be201a35dfdfccc
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.1.1)
4
+ sorare-rewards (1.1.2)
5
5
  activesupport (~> 6.1)
6
6
  interactor (~> 3.0)
7
7
  json (~> 2)
@@ -21,37 +21,46 @@ module Sorare
21
21
  end
22
22
 
23
23
  def rewardable_supply
24
- total_float_supply = supply.keys.sum { |player| player_supply(player) }
24
+ total_float_supply = supply.keys.sum { |player| player_contribution(player) }
25
25
 
26
- round_and_cap_supply(total_float_supply)
26
+ round_and_cap_league_supply(total_float_supply)
27
27
  end
28
28
 
29
29
  def distribute_in_tiers!
30
30
  ctx = Tiers::QualifySupply.call!(sorted_supply: supply)
31
- ctx.supply.each do |tier_supply|
31
+ qualified_players = Tiers::QualifyPlayers.call!(sorted_supply: supply).players
32
+ ctx.supply.each_with_index do |tier_supply, index|
32
33
  rarity_supply.push(
33
- ComputeForQuality.call!(
34
- randomizer: randomizer,
35
- total_supply: ctx.count,
36
- tier_supply: tier_supply,
37
- rewardable: rewardable,
38
- rewarded: rarity_supply
39
- ).quality_supply
34
+ capped_tier_supply(ctx.count, tier_supply, rewardable, qualified_players[index])
40
35
  )
41
36
  end
42
37
  end
43
38
 
44
- def round_and_cap_supply(float_supply)
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)
45
50
  [
46
51
  float_supply.floor + remaining_supply(float_supply.modulo(1)), # Supply limit
47
52
  league.cards_in_circulation_limit(rarity) # Circulation limit
48
53
  ].compact.min
49
54
  end
50
55
 
51
- def player_supply(slug)
56
+ def player_contribution(slug)
52
57
  game_week.player(slug).reward_pool_supply_contribution(league, rarity)
53
58
  end
54
59
 
60
+ def player_pickable_supply(slug)
61
+ game_week.player(slug).pickable_supply(league, rarity)
62
+ end
63
+
55
64
  def remaining_supply(reward_probability)
56
65
  probability = randomizer.rand
57
66
  return 0 unless probability < reward_probability
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sorare
4
4
  module Rewards
5
- VERSION = '1.1.1'
5
+ VERSION = '1.1.2'
6
6
  end
7
7
  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.1.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-08-17 00:00:00.000000000 Z
11
+ date: 2021-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport