runeterra_cards 0.5.0 → 0.7.0
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 +23 -0
- data/doc/README.md +10 -2
- data/lib/runeterra_cards/card.rb +12 -4
- data/lib/runeterra_cards/card_set.rb +26 -5
- data/lib/runeterra_cards/cost.rb +9 -8
- data/lib/runeterra_cards/factions.rb +4 -0
- data/lib/runeterra_cards/metadata.rb +1 -1
- data/lib/runeterra_cards/version.rb +1 -1
- data/lib/runeterra_cards.rb +1 -1
- metadata +20 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 353f87a2a2c4e5d16342a19e52f9ae679b9e7e046a7136d6149a54394bc8aec0
|
4
|
+
data.tar.gz: 3b2bdacf5d4bf409f973a8717e4c1891b870bb2ef5d91c68d945a3a74ad3494a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff27c6e2bbd96d649b56296cd85a83e221aabb6ab8cee984e37e8ef86802e11ebf86e792163deb467647b1af0b8aec4ac37d1d259f0a22fc87ec919886fbd7c8
|
7
|
+
data.tar.gz: 320369b766faa12a6b9b2236fab749d5c1297ffa5cbb52323e29976e98709c8a388513a34af69b49458b62c2c78c467035672097b43e4c9049a908fb026ea6d5
|
data/doc/CHANGELOG.md
CHANGED
@@ -4,6 +4,29 @@ 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.7.0] - 2022-05-26
|
8
|
+
### Added
|
9
|
+
|
10
|
+
- Support for the Runeterra faction.
|
11
|
+
- Support for version 5 deck codes.
|
12
|
+
|
13
|
+
## [0.6.1] - 2022-04-30
|
14
|
+
### Added
|
15
|
+
|
16
|
+
- Documented which versions of Ruby are officially supported:
|
17
|
+
- Ruby: 2.6, 2.7, 3.0, 3.1
|
18
|
+
- JRuby: 9.3
|
19
|
+
- TruffleRuby: 20, 21, 22
|
20
|
+
|
21
|
+
### Fixed
|
22
|
+
|
23
|
+
- Various scenarios where invalid deck codes would produce unhelpful exceptions now raise a `DeckCodeParseError` instead.
|
24
|
+
|
25
|
+
## [0.6.0] - 2021-08-25
|
26
|
+
### Added
|
27
|
+
- Support for the Bandle City faction.
|
28
|
+
- Support for version 4 deck codes.
|
29
|
+
|
7
30
|
## [0.5.0] - 2021-03-05
|
8
31
|
### Added
|
9
32
|
- Support for the Shurima 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.
|
12
|
+
gem 'runeterra_cards', '~> 0.7.0'
|
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.
|
18
|
+
spec.add_dependency 'runeterra_cards', '~> 0.7.0'
|
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.
|
data/lib/runeterra_cards/card.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module RuneterraCards
|
4
|
-
# Represents a card
|
5
|
-
#
|
4
|
+
# Represents a card.
|
5
|
+
#
|
6
|
+
# @todo: add getters for set, faction, card number
|
6
7
|
class Card
|
7
8
|
# The card code, for example "01DE123"
|
8
9
|
# @return [String]
|
@@ -24,12 +25,19 @@ module RuneterraCards
|
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
27
|
-
|
28
|
+
# Returns +true+ if _this_ and _other_ both have the same card code.
|
29
|
+
#
|
30
|
+
# @param other [Card]
|
31
|
+
# @return [Boolean]
|
28
32
|
def eql?(other)
|
29
33
|
code.eql?(other.code)
|
30
34
|
end
|
31
35
|
|
32
|
-
|
36
|
+
# Compute a hash code for this card. Two cards with the same card code will have the same hash code (and will
|
37
|
+
# compare using {#eql?}).
|
38
|
+
#
|
39
|
+
# @see Object#hash.
|
40
|
+
# @return [Integer]
|
33
41
|
def hash
|
34
42
|
code.hash
|
35
43
|
end
|
@@ -6,6 +6,7 @@ module RuneterraCards
|
|
6
6
|
# Represents a collection of cards.
|
7
7
|
#
|
8
8
|
# @todo The API to this class is very unstable and will change a lot in a coming release.
|
9
|
+
# @todo add #== !
|
9
10
|
class CardSet
|
10
11
|
# Extract this bitmask so Mutant can't see it, until this fix is released https://github.com/mbj/mutant/pull/1218
|
11
12
|
HIGH_BIT = 0b1000_0000
|
@@ -28,7 +29,7 @@ module RuneterraCards
|
|
28
29
|
remaining_cards =
|
29
30
|
cards.each_with_object({}) do |(code, count), result|
|
30
31
|
new_count = count - other.count_for_card_code(code)
|
31
|
-
result[code] = new_count unless new_count.
|
32
|
+
result[code] = new_count unless new_count.eql?(0)
|
32
33
|
end
|
33
34
|
|
34
35
|
CardSet.new(remaining_cards)
|
@@ -67,7 +68,7 @@ module RuneterraCards
|
|
67
68
|
|
68
69
|
raise UnrecognizedVersionError.new(SUPPORTED_VERSION, version) unless version <= SUPPORTED_VERSION
|
69
70
|
|
70
|
-
raise unless format.
|
71
|
+
raise unless format.eql? 1
|
71
72
|
|
72
73
|
int_array = unpack_big_endian_varint(binary_data[1..])
|
73
74
|
cards = assemble_card_list(int_array)
|
@@ -104,11 +105,11 @@ module RuneterraCards
|
|
104
105
|
# @return [Array<Card>]
|
105
106
|
def self.assemble_card_list(array)
|
106
107
|
3.downto(1).flat_map do |number_of_copies|
|
107
|
-
set_faction_combination_count = array
|
108
|
+
set_faction_combination_count = shift_and_check(array)
|
108
109
|
set_faction_combination_count.times.flat_map do
|
109
|
-
number_of_cards, set, faction = array
|
110
|
+
number_of_cards, set, faction = shift_and_check(array, 3)
|
110
111
|
|
111
|
-
array
|
112
|
+
shift_and_check(array, number_of_cards).map do |card_number|
|
112
113
|
cac = Card.new(set: set, faction_number: faction, card_number: card_number)
|
113
114
|
[cac.code, number_of_copies]
|
114
115
|
end
|
@@ -118,6 +119,26 @@ module RuneterraCards
|
|
118
119
|
|
119
120
|
private_class_method :assemble_card_list
|
120
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
|
+
|
121
142
|
# @param [String] binary
|
122
143
|
# @return [Enumerable<Fixnum>]
|
123
144
|
def self.unpack_big_endian_varint(binary)
|
data/lib/runeterra_cards/cost.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# @todo could be more obvious what's wrong when you call == on the wrong class e.g. a number
|
3
4
|
module RuneterraCards
|
4
5
|
# Represents the cost of a {CardSet}, as wildcards or shards.
|
5
6
|
# To get the cost of a {CardSet} you need to call {Metadata#cost_of}, as rarity (and therefore cost) is a property
|
@@ -54,10 +55,10 @@ module RuneterraCards
|
|
54
55
|
# The number of shards needed. I.e. the equivalent amount of shards for all these wildcards.
|
55
56
|
# @return [Fixnum] shards
|
56
57
|
def shards
|
57
|
-
common * 100 +
|
58
|
-
rare * 300 +
|
59
|
-
epic * 1200 +
|
60
|
-
champion * 3000
|
58
|
+
(common * 100) +
|
59
|
+
(rare * 300) +
|
60
|
+
(epic * 1200) +
|
61
|
+
(champion * 3000)
|
61
62
|
end
|
62
63
|
|
63
64
|
# Whether this Cost is equal to another. Equality means exactly the same number of each wildcard, not just the
|
@@ -65,10 +66,10 @@ module RuneterraCards
|
|
65
66
|
# @param [Cost] other an object that response to {#common}, {#rare}, {#epic}, and {#champion}.
|
66
67
|
# @return [Boolean] equal?
|
67
68
|
def ==(other)
|
68
|
-
common.
|
69
|
-
rare.
|
70
|
-
epic.
|
71
|
-
champion.
|
69
|
+
common.eql?(other.common) &&
|
70
|
+
rare.eql?(other.rare) &&
|
71
|
+
epic.eql?(other.epic) &&
|
72
|
+
champion.eql?(other.champion)
|
72
73
|
end
|
73
74
|
|
74
75
|
# Subtracts another Cost from this one. Subtraction is performed by subtracting each wildcard type individually,
|
@@ -15,6 +15,8 @@ module RuneterraCards
|
|
15
15
|
6 => 'BW',
|
16
16
|
7 => 'SH',
|
17
17
|
9 => 'MT',
|
18
|
+
10 => 'BC',
|
19
|
+
12 => 'RU',
|
18
20
|
}.freeze
|
19
21
|
public_constant :FACTION_IDENTIFIERS_FROM_INT
|
20
22
|
|
@@ -32,6 +34,8 @@ module RuneterraCards
|
|
32
34
|
'BW' => 6,
|
33
35
|
'SH' => 7,
|
34
36
|
'MT' => 9,
|
37
|
+
'BC' => 10,
|
38
|
+
'RU' => 12,
|
35
39
|
}.freeze
|
36
40
|
public_constant :FACTION_INTS_FROM_IDENTIFIER
|
37
41
|
end
|
data/lib/runeterra_cards.rb
CHANGED
@@ -16,6 +16,6 @@ require 'runeterra_cards/cost'
|
|
16
16
|
# You might also want to check out the {file:doc/README.md} and the {file:doc/CHANGELOG.md}.
|
17
17
|
module RuneterraCards
|
18
18
|
# The version of deck encoding supported
|
19
|
-
SUPPORTED_VERSION =
|
19
|
+
SUPPORTED_VERSION = 5
|
20
20
|
public_constant :SUPPORTED_VERSION
|
21
21
|
end
|
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.
|
4
|
+
version: 0.7.0
|
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-05-26 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
|
@@ -122,6 +94,20 @@ dependencies:
|
|
122
94
|
- - "~>"
|
123
95
|
- !ruby/object:Gem::Version
|
124
96
|
version: 13.0.1
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: redcarpet
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 3.5.1
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 3.5.1
|
125
111
|
- !ruby/object:Gem::Dependency
|
126
112
|
name: rubocop
|
127
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,14 +128,14 @@ dependencies:
|
|
142
128
|
requirements:
|
143
129
|
- - "~>"
|
144
130
|
- !ruby/object:Gem::Version
|
145
|
-
version: 0.
|
131
|
+
version: 0.15.2
|
146
132
|
type: :development
|
147
133
|
prerelease: false
|
148
134
|
version_requirements: !ruby/object:Gem::Requirement
|
149
135
|
requirements:
|
150
136
|
- - "~>"
|
151
137
|
- !ruby/object:Gem::Version
|
152
|
-
version: 0.
|
138
|
+
version: 0.15.2
|
153
139
|
- !ruby/object:Gem::Dependency
|
154
140
|
name: rubocop-packaging
|
155
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -220,6 +206,7 @@ metadata:
|
|
220
206
|
changelog_uri: https://www.rubydoc.info/gems/runeterra_cards/file/doc/CHANGELOG.md
|
221
207
|
source_code_uri: https://github.com/zofrex/runeterra_cards
|
222
208
|
documentation_uri: https://www.rubydoc.info/gems/runeterra_cards/
|
209
|
+
rubygems_mfa_required: 'true'
|
223
210
|
post_install_message:
|
224
211
|
rdoc_options: []
|
225
212
|
require_paths:
|
@@ -235,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
235
222
|
- !ruby/object:Gem::Version
|
236
223
|
version: '0'
|
237
224
|
requirements: []
|
238
|
-
rubygems_version: 3.
|
225
|
+
rubygems_version: 3.3.7
|
239
226
|
signing_key:
|
240
227
|
specification_version: 4
|
241
228
|
summary: Legends of Runeterra deck code decoder & Data Dragon card data loader.
|