sorare-rewards 1.1.3.beta0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +1 -1
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +1 -1
- data/lib/sorare/rewards/game_week.rb +0 -6
- data/lib/sorare/rewards/game_week_config.rb +6 -0
- data/lib/sorare/rewards/player.rb +10 -4
- data/lib/sorare/rewards/version.rb +1 -1
- metadata +5 -5
- data/lib/sorare/rewards/concerns/with_analytics.rb +0 -57
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f64ea163ad5ed02120737f8a540b3c1a86cbfc4e2d472ff4906cf2ca836f060
|
4
|
+
data.tar.gz: d9021d4ce7717b197408ee1e9e1da025e3af46f4f744862c987ea58654e9f191
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eafcc27cb84b5974e901b8246fd49a9f351b7e88b784274eb2a3dc0b1086f6b11a6d96611b20790b42c92e83ac97e4abb6dadfa3b2f928f2c66db161451c86c4
|
7
|
+
data.tar.gz: db9da4a9da91484dd38a71afa544cc324d7c1e724a85cebe154453fa381c376c8c028ad3f4494e533cd6480657c6d6b9a6a2c2b6cef6e1be6f96fa2f57516222
|
data/.gitlab-ci.yml
CHANGED
data/CHANGELOG.md
ADDED
data/Gemfile.lock
CHANGED
@@ -8,8 +8,6 @@ module Sorare
|
|
8
8
|
module Rewards
|
9
9
|
# GameWeek stores the reward data of a game week
|
10
10
|
class GameWeek
|
11
|
-
include WithAnalytics
|
12
|
-
|
13
11
|
attr_reader :salt
|
14
12
|
|
15
13
|
delegate :card_allocations, :prize_pools, to: :reward_allocations
|
@@ -71,10 +69,6 @@ module Sorare
|
|
71
69
|
def player(slug)
|
72
70
|
Player.new(slug, self)
|
73
71
|
end
|
74
|
-
|
75
|
-
def inspect
|
76
|
-
super.splice(:version)
|
77
|
-
end
|
78
72
|
end
|
79
73
|
end
|
80
74
|
end
|
@@ -30,6 +30,12 @@ module Sorare
|
|
30
30
|
cooldown.dig(rarity, 'quantity')
|
31
31
|
end
|
32
32
|
|
33
|
+
def cooldown_per_league?(rarity)
|
34
|
+
per_league = cooldown.dig(rarity, 'per_league')
|
35
|
+
|
36
|
+
per_league.nil? ? true : per_league
|
37
|
+
end
|
38
|
+
|
33
39
|
def cooldown_since(rarity)
|
34
40
|
cooldown.dig(rarity, 'since')
|
35
41
|
end
|
@@ -55,16 +55,22 @@ module Sorare
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def available_during_cooldown(league, rarity)
|
58
|
-
[@config.cooldown_limit(rarity) -
|
58
|
+
[@config.cooldown_limit(rarity) - rewarded_under_cooldown(league, rarity), 0].max
|
59
59
|
end
|
60
60
|
|
61
|
-
def
|
62
|
-
(
|
61
|
+
def rewarded_under_cooldown(league, rarity)
|
62
|
+
rewarded(league, rarity).count do |at|
|
63
63
|
(Time.parse(at) + @config.cooldown_since(rarity)) > Time.now
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
-
|
67
|
+
def rewarded(league, rarity)
|
68
|
+
return (@game_data&.dig(league.name, rarity) || []) if @config.cooldown_per_league?(rarity)
|
69
|
+
|
70
|
+
latest_rewarded&.dig(rarity) || []
|
71
|
+
end
|
72
|
+
|
73
|
+
%w[remaining_games_for_supply remaining_games latest_rewarded].each do |key|
|
68
74
|
define_method(key) do
|
69
75
|
@game_data&.dig(key)
|
70
76
|
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.2.0
|
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-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -161,6 +161,7 @@ files:
|
|
161
161
|
- ".gitlab-ci.yml"
|
162
162
|
- ".rspec"
|
163
163
|
- ".rubocop.yml"
|
164
|
+
- CHANGELOG.md
|
164
165
|
- Gemfile
|
165
166
|
- Gemfile.lock
|
166
167
|
- LICENSE.txt
|
@@ -171,7 +172,6 @@ files:
|
|
171
172
|
- data.patch
|
172
173
|
- lib/sorare/rewards.rb
|
173
174
|
- lib/sorare/rewards/allocation_configuration.yml
|
174
|
-
- lib/sorare/rewards/concerns/with_analytics.rb
|
175
175
|
- lib/sorare/rewards/configuration.rb
|
176
176
|
- lib/sorare/rewards/game_week.rb
|
177
177
|
- lib/sorare/rewards/game_week_allocations.rb
|
@@ -221,9 +221,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
221
221
|
version: 2.7.1
|
222
222
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
223
223
|
requirements:
|
224
|
-
- - "
|
224
|
+
- - ">="
|
225
225
|
- !ruby/object:Gem::Version
|
226
|
-
version:
|
226
|
+
version: '0'
|
227
227
|
requirements: []
|
228
228
|
rubygems_version: 3.2.22
|
229
229
|
signing_key:
|
@@ -1,57 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'active_support/concern'
|
4
|
-
|
5
|
-
module Sorare
|
6
|
-
module Rewards
|
7
|
-
# WithAnalytics defines analytics methods
|
8
|
-
module WithAnalytics
|
9
|
-
extend ActiveSupport::Concern
|
10
|
-
|
11
|
-
def analytics
|
12
|
-
@analytics ||= each_league.each_with_object({}) do |league, stats|
|
13
|
-
stats[league.name] = league_analytics(league)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
def reward_distributed
|
20
|
-
@reward_distributed ||= reward_allocations.card_allocations.transform_values do |league|
|
21
|
-
league.transform_values do |rarity|
|
22
|
-
rarity.sum { |_, divisions| divisions.values.sum }
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def league_analytics(league)
|
28
|
-
{
|
29
|
-
playing_players_with_supply: nb_of_playing_players(league),
|
30
|
-
available_cards: nb_of_available_cards(league),
|
31
|
-
cooldown_players: nb_of_fully_cooldown_players(league),
|
32
|
-
rewarded: reward_distributed[league.name]
|
33
|
-
}
|
34
|
-
end
|
35
|
-
|
36
|
-
def nb_of_playing_players(league)
|
37
|
-
supply_for(league.name).keys.index_with do |rarity|
|
38
|
-
(supply_for(league.name, rarity: rarity).keys & playing_players.keys).count
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def nb_of_available_cards(league)
|
43
|
-
supply_for(league.name).keys.index_with do |rarity|
|
44
|
-
supply_for(league.name, rarity: rarity).sum { |_, data| data['supply'] }
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def nb_of_fully_cooldown_players(league)
|
49
|
-
supply_for(league.name).keys.index_with do |rarity|
|
50
|
-
supply_for(league.name, rarity: rarity).filter do |player_slug|
|
51
|
-
player(player_slug).available_during_cooldown(league, rarity).zero?
|
52
|
-
end.count
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|