sorare-rewards 1.0.0 → 1.0.1

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: 253e18e26532e141a2fa48969f8484d6c7f92f399cf4eecc248b5017978e6747
4
- data.tar.gz: c7ed9fd27b8a78240a492eb0d75df26e5fb34b55a5a96b3a46b4cc74cc845d59
3
+ metadata.gz: 8cc85589244de6f453ed70184da06e8c679ec19b4b2c5fe86ee1ea4936c2c402
4
+ data.tar.gz: 521385c5b0b1e917d7be61eaef02d2284c24082fb18eeec561f9da6160ea650f
5
5
  SHA512:
6
- metadata.gz: d3ef4eae789a0f616c270f8d08eb16d87d5964cd4b8c99a0501fe78ed02347942cb205baea2cc0b299822d9f158e6e2548915bd9d13917cf392ec8ebb4ff9be6
7
- data.tar.gz: bbb905bf57270350136d28946ef963e841efc5acd780db50d90d0bcef4bfdee11fd7488df00d1bddcb5ce96981bbab64bad8177e3e699dd8b09d816518445cd6
6
+ metadata.gz: 4b998f1b6bca4cbb8ca9fc9fcab6b2d9f2f32b7f4384e4b736ec2dcd3b51b9e1e17d62daf7f85b715e21a060445abd5e495342a01bc725994847ca028a991733
7
+ data.tar.gz: fff45a44fc25d684adeb45985aac4fde3b876977feca1f9fd3b4f9cd7b3e60f82b3f3f0294df25cc28aead951ee16f0b287192d4bb44fb1cd823602067f3ac42
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sorare-rewards (1.0.0)
4
+ sorare-rewards (1.0.1)
5
5
  activesupport (~> 6.1)
6
6
  interactor (~> 3.0)
7
7
  json (~> 2)
@@ -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).supply(league, rarity).ceil
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
@@ -44,7 +44,7 @@ module Sorare
44
44
  end
45
45
 
46
46
  def player_supply(slug)
47
- game_week.player(slug).supply(league, rarity)
47
+ game_week.player(slug).reward_pool_supply_contribution(league, rarity)
48
48
  end
49
49
 
50
50
  def rounded_supply(float_supply)
@@ -25,11 +25,18 @@ module Sorare
25
25
  @game_data.present?
26
26
  end
27
27
 
28
- def supply(league, rarity)
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), # Remaining supply
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
- (rewards&.dig(league) || []).count { |at| (Time.parse(at) + @config.cooldown_since(rarity)) < Time.now }
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[rewards remaining_games_for_supply remaining_games].each do |key|
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sorare
4
4
  module Rewards
5
- VERSION = '1.0.0'
5
+ VERSION = '1.0.1'
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.0.0
4
+ version: 1.0.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-07-08 00:00:00.000000000 Z
11
+ date: 2021-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport