runeterra_cards 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/doc/CHANGELOG.md +12 -0
- data/doc/README.md +10 -2
- data/lib/runeterra_cards/card_set.rb +25 -5
- data/lib/runeterra_cards/cost.rb +8 -8
- data/lib/runeterra_cards/version.rb +1 -1
- metadata +6 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1e0528d970e63dfad42a4f65e907f76cc966bc5da298de031bb8b0903870ebe
|
4
|
+
data.tar.gz: 4546f417aeea04a3dd767d959603670235a8fe0f382e4a6a15a61fe726d09e49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6fe77c6a6ca5c0f7c40c2f75678737f44ac4a6d3d5f120ffd2b55228462e1ebdb3963a1cdfc965d0569e252c5df7b7b9721f8b52810eb7f5fabb3fd9372719cf
|
7
|
+
data.tar.gz: 7686da5bfecde6a4322cff7989f25c3668c776e4185870231f39cfb998ac72c99d44c24d8383234189c6f876cbdd12d4ba283bf049b0e9982815b22fbf4575ea
|
data/doc/CHANGELOG.md
CHANGED
@@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## [0.6.1] - 2022-04-30
|
8
|
+
### Added
|
9
|
+
|
10
|
+
- Documented which versions of Ruby are officially supported:
|
11
|
+
- Ruby: 2.6, 2.7, 3.0, 3.1
|
12
|
+
- JRuby: 9.3
|
13
|
+
- TruffleRuby: 20, 21, 22
|
14
|
+
|
15
|
+
### Fixed
|
16
|
+
|
17
|
+
- Various scenarios where invalid deck codes would produce unhelpful exceptions now raise a `DeckCodeParseError` instead.
|
18
|
+
|
7
19
|
## [0.6.0] - 2021-08-25
|
8
20
|
### Added
|
9
21
|
- Support for the Bandle City faction.
|
data/doc/README.md
CHANGED
@@ -9,15 +9,23 @@ This library makes it easy to decode Legends of Runeterra deck codes, load Data
|
|
9
9
|
Add the following to your `Gemfile`:
|
10
10
|
|
11
11
|
```
|
12
|
-
gem 'runeterra_cards', '~> 0.6.
|
12
|
+
gem 'runeterra_cards', '~> 0.6.1'
|
13
13
|
```
|
14
14
|
|
15
15
|
Or, if you're building a Gem, your `.gemspec`:
|
16
16
|
|
17
17
|
```
|
18
|
-
spec.add_dependency 'runeterra_cards', '~> 0.6.
|
18
|
+
spec.add_dependency 'runeterra_cards', '~> 0.6.1'
|
19
19
|
```
|
20
20
|
|
21
|
+
### Ruby version support
|
22
|
+
|
23
|
+
* Ruby: 2.6, 2.7, 3.0, 3.1
|
24
|
+
* JRuby: 9.3 only
|
25
|
+
* TruffleRuby: 20, 21, 22
|
26
|
+
|
27
|
+
Note that only Linux and Windows are included in automated testing, although other platforms are expected to work. Also note that truffleruby compatibility is not tested on Windows.
|
28
|
+
|
21
29
|
## Updates & Versioning
|
22
30
|
|
23
31
|
This library will conform to [semantic versioning](https://semver.org/) once it hits 1.0. In the meantime, you can rely on the minor version (Y in x.Y.z) being bumped for backwards-incompatible changes.
|
@@ -29,7 +29,7 @@ module RuneterraCards
|
|
29
29
|
remaining_cards =
|
30
30
|
cards.each_with_object({}) do |(code, count), result|
|
31
31
|
new_count = count - other.count_for_card_code(code)
|
32
|
-
result[code] = new_count unless new_count.
|
32
|
+
result[code] = new_count unless new_count.eql?(0)
|
33
33
|
end
|
34
34
|
|
35
35
|
CardSet.new(remaining_cards)
|
@@ -68,7 +68,7 @@ module RuneterraCards
|
|
68
68
|
|
69
69
|
raise UnrecognizedVersionError.new(SUPPORTED_VERSION, version) unless version <= SUPPORTED_VERSION
|
70
70
|
|
71
|
-
raise unless format.
|
71
|
+
raise unless format.eql? 1
|
72
72
|
|
73
73
|
int_array = unpack_big_endian_varint(binary_data[1..])
|
74
74
|
cards = assemble_card_list(int_array)
|
@@ -105,11 +105,11 @@ module RuneterraCards
|
|
105
105
|
# @return [Array<Card>]
|
106
106
|
def self.assemble_card_list(array)
|
107
107
|
3.downto(1).flat_map do |number_of_copies|
|
108
|
-
set_faction_combination_count = array
|
108
|
+
set_faction_combination_count = shift_and_check(array)
|
109
109
|
set_faction_combination_count.times.flat_map do
|
110
|
-
number_of_cards, set, faction = array
|
110
|
+
number_of_cards, set, faction = shift_and_check(array, 3)
|
111
111
|
|
112
|
-
array
|
112
|
+
shift_and_check(array, number_of_cards).map do |card_number|
|
113
113
|
cac = Card.new(set: set, faction_number: faction, card_number: card_number)
|
114
114
|
[cac.code, number_of_copies]
|
115
115
|
end
|
@@ -119,6 +119,26 @@ module RuneterraCards
|
|
119
119
|
|
120
120
|
private_class_method :assemble_card_list
|
121
121
|
|
122
|
+
# Like Array#shift but checks that the number of items requested was
|
123
|
+
# actually retrieved, errors otherwise.
|
124
|
+
# @param [Array<T>] array Array to shift one or more values from
|
125
|
+
# @param [Integer] count Number of items to shift from the array (default 1)
|
126
|
+
# @return [Array<T>,T]
|
127
|
+
# @raise [DeckCodeParseError]
|
128
|
+
def self.shift_and_check(array, count=nil)
|
129
|
+
if count
|
130
|
+
raise DeckCodeParseError if array.length < count
|
131
|
+
|
132
|
+
array.shift(count)
|
133
|
+
else
|
134
|
+
raise DeckCodeParseError if array.empty?
|
135
|
+
|
136
|
+
array.shift
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
private_class_method :shift_and_check
|
141
|
+
|
122
142
|
# @param [String] binary
|
123
143
|
# @return [Enumerable<Fixnum>]
|
124
144
|
def self.unpack_big_endian_varint(binary)
|
data/lib/runeterra_cards/cost.rb
CHANGED
@@ -55,10 +55,10 @@ module RuneterraCards
|
|
55
55
|
# The number of shards needed. I.e. the equivalent amount of shards for all these wildcards.
|
56
56
|
# @return [Fixnum] shards
|
57
57
|
def shards
|
58
|
-
common * 100 +
|
59
|
-
rare * 300 +
|
60
|
-
epic * 1200 +
|
61
|
-
champion * 3000
|
58
|
+
(common * 100) +
|
59
|
+
(rare * 300) +
|
60
|
+
(epic * 1200) +
|
61
|
+
(champion * 3000)
|
62
62
|
end
|
63
63
|
|
64
64
|
# Whether this Cost is equal to another. Equality means exactly the same number of each wildcard, not just the
|
@@ -66,10 +66,10 @@ module RuneterraCards
|
|
66
66
|
# @param [Cost] other an object that response to {#common}, {#rare}, {#epic}, and {#champion}.
|
67
67
|
# @return [Boolean] equal?
|
68
68
|
def ==(other)
|
69
|
-
common.
|
70
|
-
rare.
|
71
|
-
epic.
|
72
|
-
champion.
|
69
|
+
common.eql?(other.common) &&
|
70
|
+
rare.eql?(other.rare) &&
|
71
|
+
epic.eql?(other.epic) &&
|
72
|
+
champion.eql?(other.champion)
|
73
73
|
end
|
74
74
|
|
75
75
|
# Subtracts another Cost from this one. Subtraction is performed by subtracting each wildcard type individually,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: runeterra_cards
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James "zofrex" Sanderson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: base32
|
@@ -24,34 +24,6 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.3.2
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: bundler
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '2.0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '2.0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: deep-cover
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0.7'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0.7'
|
55
27
|
- !ruby/object:Gem::Dependency
|
56
28
|
name: minitest
|
57
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -156,14 +128,14 @@ dependencies:
|
|
156
128
|
requirements:
|
157
129
|
- - "~>"
|
158
130
|
- !ruby/object:Gem::Version
|
159
|
-
version: 0.
|
131
|
+
version: 0.15.2
|
160
132
|
type: :development
|
161
133
|
prerelease: false
|
162
134
|
version_requirements: !ruby/object:Gem::Requirement
|
163
135
|
requirements:
|
164
136
|
- - "~>"
|
165
137
|
- !ruby/object:Gem::Version
|
166
|
-
version: 0.
|
138
|
+
version: 0.15.2
|
167
139
|
- !ruby/object:Gem::Dependency
|
168
140
|
name: rubocop-packaging
|
169
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -234,6 +206,7 @@ metadata:
|
|
234
206
|
changelog_uri: https://www.rubydoc.info/gems/runeterra_cards/file/doc/CHANGELOG.md
|
235
207
|
source_code_uri: https://github.com/zofrex/runeterra_cards
|
236
208
|
documentation_uri: https://www.rubydoc.info/gems/runeterra_cards/
|
209
|
+
rubygems_mfa_required: 'true'
|
237
210
|
post_install_message:
|
238
211
|
rdoc_options: []
|
239
212
|
require_paths:
|
@@ -249,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
249
222
|
- !ruby/object:Gem::Version
|
250
223
|
version: '0'
|
251
224
|
requirements: []
|
252
|
-
rubygems_version: 3.1.
|
225
|
+
rubygems_version: 3.1.6
|
253
226
|
signing_key:
|
254
227
|
specification_version: 4
|
255
228
|
summary: Legends of Runeterra deck code decoder & Data Dragon card data loader.
|