runeterra_cards 0.4.1 → 0.5.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 +18 -2
- data/doc/README.md +2 -2
- data/lib/runeterra_cards.rb +2 -2
- data/lib/runeterra_cards/{card_and_count.rb → card.rb} +5 -11
- data/lib/runeterra_cards/card_set.rb +27 -19
- data/lib/runeterra_cards/factions.rb +2 -0
- data/lib/runeterra_cards/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 143a6e1907badc2fc066202446fa5106a8ddfda903e195b4fadd2a8c45fcc824
|
4
|
+
data.tar.gz: '0669ded1c45362335feddb5f5f8846407f61a85a04a458877fb728ace2a99cc1'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88a8a01c7a0971da6c084210bbd0b5121add3faf6dd5b28ac12c1235ad5023adeda8729af3fe8b96479a895aab48769a87b81dddabe9d662cc15514cf003ebe6
|
7
|
+
data.tar.gz: 289070859e22694e9014fad41b6fce31a867489541080644c4a98adee6fa87afa653a08ea68cdbe536af3fe3a9875386b508e0f73d0b1301f98152cf3d5203fd
|
data/doc/CHANGELOG.md
CHANGED
@@ -4,11 +4,27 @@ 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.5.0] - 2021-03-05
|
8
|
+
### Added
|
9
|
+
- Support for the Shurima faction.
|
10
|
+
- Support for version 3 deck codes.
|
11
|
+
- A new Card class to represent cards on their own without a count.
|
12
|
+
- CardSet#as_cards, which returns all the cards in the set as Cards.
|
13
|
+
- CardSet#as_card_codes, which returns all the cards in the set as card codes.
|
14
|
+
|
15
|
+
### Removed
|
16
|
+
- RuneterraCards.from_card_and_counts method.
|
17
|
+
- CardAndCount class (replaced by the new Card class).
|
18
|
+
- CardSet#as_card_and_counts (replaced by #as_cards).
|
19
|
+
|
20
|
+
### Deprecated
|
21
|
+
- CardSet#cards – the signature of this method will be changing in a future version to match #as_cards, migrate to #as_card_codes to keep the current #cards behaviour.
|
22
|
+
|
7
23
|
## [0.4.1] - 2021-02-05
|
24
|
+
### Fixed
|
8
25
|
|
9
|
-
Fixed
|
26
|
+
- Fixed issue where card numbers > 127 came out extremely wrong, e.g. Aphelios and several other of the new cards ([issue #4](https://github.com/zofrex/runeterra_cards/issues/4)).
|
10
27
|
|
11
|
-
- Fixed issue where card numbers > 127 came out extremely wrong, e.g. Aphelios and several other of the new cards ([issue #4](https://github.com/zofrex/runeterra_cards/issues/4))
|
12
28
|
## [0.4.0] - 2020-12-08
|
13
29
|
### Added
|
14
30
|
- [`CardMetadata` now has a `#cost` attribute representing the mana cost of a card.](https://github.com/zofrex/runeterra_cards/pull/3) (thanks, [nieszkah](https://github.com/alpm)!) Technically this is backwards-compatibility breaking as it makes a new field in metadata json mandatory.
|
data/doc/README.md
CHANGED
@@ -9,13 +9,13 @@ 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.5.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.5.0'
|
19
19
|
```
|
20
20
|
|
21
21
|
## Updates & Versioning
|
data/lib/runeterra_cards.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'runeterra_cards/version'
|
4
4
|
require 'runeterra_cards/errors'
|
5
5
|
require 'runeterra_cards/factions'
|
6
|
-
require 'runeterra_cards/
|
6
|
+
require 'runeterra_cards/card'
|
7
7
|
require 'runeterra_cards/card_metadata'
|
8
8
|
require 'runeterra_cards/metadata'
|
9
9
|
require 'runeterra_cards/card_set'
|
@@ -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 = 3
|
20
20
|
public_constant :SUPPORTED_VERSION
|
21
21
|
end
|
@@ -1,22 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module RuneterraCards
|
4
|
-
# Represents a card
|
4
|
+
# Represents a card
|
5
5
|
# @deprecated
|
6
|
-
class
|
6
|
+
class Card
|
7
7
|
# The card code, for example "01DE123"
|
8
8
|
# @return [String]
|
9
9
|
attr_reader :code
|
10
10
|
|
11
|
-
# How many of this card are in a collection (between 1-3).
|
12
|
-
# @return [Fixnum]
|
13
|
-
attr_reader :count
|
14
|
-
|
15
11
|
# @param set [Fixnum]
|
16
12
|
# @param faction_number [Fixnum]
|
17
13
|
# @param card_number [Fixnum]
|
18
|
-
|
19
|
-
def initialize(count:, code: nil, set: nil, faction_number: nil, card_number: nil)
|
14
|
+
def initialize(code: nil, set: nil, faction_number: nil, card_number: nil)
|
20
15
|
if code
|
21
16
|
raise if set || faction_number || card_number
|
22
17
|
|
@@ -27,17 +22,16 @@ module RuneterraCards
|
|
27
22
|
padded_card_number = format('%<i>03d', i: card_number)
|
28
23
|
@code = "#{padded_set}#{faction}#{padded_card_number}"
|
29
24
|
end
|
30
|
-
@count = count
|
31
25
|
end
|
32
26
|
|
33
27
|
#:nodoc:
|
34
28
|
def eql?(other)
|
35
|
-
code.eql?(other.code)
|
29
|
+
code.eql?(other.code)
|
36
30
|
end
|
37
31
|
|
38
32
|
#:nodoc:
|
39
33
|
def hash
|
40
|
-
|
34
|
+
code.hash
|
41
35
|
end
|
42
36
|
end
|
43
37
|
end
|
@@ -7,19 +7,19 @@ module RuneterraCards
|
|
7
7
|
#
|
8
8
|
# @todo The API to this class is very unstable and will change a lot in a coming release.
|
9
9
|
class CardSet
|
10
|
-
#
|
10
|
+
# Extract this bitmask so Mutant can't see it, until this fix is released https://github.com/mbj/mutant/pull/1218
|
11
|
+
HIGH_BIT = 0b1000_0000
|
12
|
+
private_constant :HIGH_BIT
|
13
|
+
|
14
|
+
# @return [Hash{String => Number}]
|
15
|
+
# @deprecated
|
11
16
|
attr_reader :cards
|
12
17
|
|
13
|
-
# @param [Hash
|
18
|
+
# @param [Hash{String => Number},Enumerable{String => Number}] cards A Hash of card codes mapping to card counts
|
14
19
|
def initialize(cards)
|
15
20
|
@cards = cards
|
16
21
|
end
|
17
22
|
|
18
|
-
# @deprecated
|
19
|
-
def self.from_card_and_counts(set)
|
20
|
-
new(Hash[set.map { |cac| [cac.code, cac.count] }])
|
21
|
-
end
|
22
|
-
|
23
23
|
# Subtract another {CardSet CardSet} from this one. Items with count 0 are not represented in the returned
|
24
24
|
# {CardSet CardSet}, they are removed altogether.
|
25
25
|
# @param [CardSet] other An object that responds to {#count_for_card_code}
|
@@ -34,15 +34,22 @@ module RuneterraCards
|
|
34
34
|
CardSet.new(remaining_cards)
|
35
35
|
end
|
36
36
|
|
37
|
-
# @return [
|
38
|
-
|
39
|
-
|
40
|
-
|
37
|
+
# @return [Enumerable<Card => Number>]
|
38
|
+
def as_cards
|
39
|
+
cards.transform_keys { |code| Card.new(code: code) }
|
40
|
+
end
|
41
|
+
|
42
|
+
# Return all cards in the card set as a map of card codes to counts.
|
43
|
+
# @example
|
44
|
+
# set.as_card_codes #=> { '01DE044' => 1, '02NX003' => 2 }
|
45
|
+
# @return [Enumerable<String => Number>]
|
46
|
+
def as_card_codes
|
47
|
+
cards
|
41
48
|
end
|
42
49
|
|
43
50
|
# Returns how many of the given card are in this CardSet.
|
44
51
|
# @param [String] code Card code, e.g. "01DE031"
|
45
|
-
# @return [
|
52
|
+
# @return [Integer] How many of the card are in this CardSet, or 0 if it isn't present.
|
46
53
|
def count_for_card_code(code)
|
47
54
|
cards[code] || 0
|
48
55
|
end
|
@@ -62,10 +69,10 @@ module RuneterraCards
|
|
62
69
|
|
63
70
|
raise unless format.equal? 1
|
64
71
|
|
65
|
-
int_array =
|
72
|
+
int_array = unpack_big_endian_varint(binary_data[1..])
|
66
73
|
cards = assemble_card_list(int_array)
|
67
74
|
|
68
|
-
|
75
|
+
new(cards.to_h)
|
69
76
|
end
|
70
77
|
|
71
78
|
# @param string [String] base32-encoded string
|
@@ -94,7 +101,7 @@ module RuneterraCards
|
|
94
101
|
private_class_method :decode_format_and_version
|
95
102
|
|
96
103
|
# @param [Array<Fixnum>] array
|
97
|
-
# @return [Array<
|
104
|
+
# @return [Array<Card>]
|
98
105
|
def self.assemble_card_list(array)
|
99
106
|
3.downto(1).flat_map do |number_of_copies|
|
100
107
|
set_faction_combination_count = array.shift
|
@@ -102,7 +109,8 @@ module RuneterraCards
|
|
102
109
|
number_of_cards, set, faction = array.shift(3)
|
103
110
|
|
104
111
|
array.shift(number_of_cards).map do |card_number|
|
105
|
-
|
112
|
+
cac = Card.new(set: set, faction_number: faction, card_number: card_number)
|
113
|
+
[cac.code, number_of_copies]
|
106
114
|
end
|
107
115
|
end
|
108
116
|
end
|
@@ -112,8 +120,8 @@ module RuneterraCards
|
|
112
120
|
|
113
121
|
# @param [String] binary
|
114
122
|
# @return [Enumerable<Fixnum>]
|
115
|
-
def self.
|
116
|
-
binary.each_byte.slice_after { |b| (b &
|
123
|
+
def self.unpack_big_endian_varint(binary)
|
124
|
+
binary.each_byte.slice_after { |b| (b & HIGH_BIT).zero? }.map do |int_bytes|
|
117
125
|
acc = 0
|
118
126
|
int_bytes.each_with_index do |byte, index|
|
119
127
|
acc += (byte & 0b0111_1111) << (7 * index)
|
@@ -122,6 +130,6 @@ module RuneterraCards
|
|
122
130
|
end
|
123
131
|
end
|
124
132
|
|
125
|
-
private_class_method :
|
133
|
+
private_class_method :unpack_big_endian_varint
|
126
134
|
end
|
127
135
|
end
|
@@ -13,6 +13,7 @@ module RuneterraCards
|
|
13
13
|
4 => 'PZ',
|
14
14
|
5 => 'SI',
|
15
15
|
6 => 'BW',
|
16
|
+
7 => 'SH',
|
16
17
|
9 => 'MT',
|
17
18
|
}.freeze
|
18
19
|
public_constant :FACTION_IDENTIFIERS_FROM_INT
|
@@ -29,6 +30,7 @@ module RuneterraCards
|
|
29
30
|
'PZ' => 4,
|
30
31
|
'SI' => 5,
|
31
32
|
'BW' => 6,
|
33
|
+
'SH' => 7,
|
32
34
|
'MT' => 9,
|
33
35
|
}.freeze
|
34
36
|
public_constant :FACTION_INTS_FROM_IDENTIFIER
|
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.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James "zofrex" Sanderson
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: base32
|
@@ -204,7 +204,7 @@ files:
|
|
204
204
|
- doc/CHANGELOG.md
|
205
205
|
- doc/README.md
|
206
206
|
- lib/runeterra_cards.rb
|
207
|
-
- lib/runeterra_cards/
|
207
|
+
- lib/runeterra_cards/card.rb
|
208
208
|
- lib/runeterra_cards/card_metadata.rb
|
209
209
|
- lib/runeterra_cards/card_set.rb
|
210
210
|
- lib/runeterra_cards/cost.rb
|
@@ -212,7 +212,7 @@ files:
|
|
212
212
|
- lib/runeterra_cards/factions.rb
|
213
213
|
- lib/runeterra_cards/metadata.rb
|
214
214
|
- lib/runeterra_cards/version.rb
|
215
|
-
homepage:
|
215
|
+
homepage:
|
216
216
|
licenses:
|
217
217
|
- MIT
|
218
218
|
metadata:
|
@@ -220,7 +220,7 @@ metadata:
|
|
220
220
|
changelog_uri: https://www.rubydoc.info/gems/runeterra_cards/file/doc/CHANGELOG.md
|
221
221
|
source_code_uri: https://github.com/zofrex/runeterra_cards
|
222
222
|
documentation_uri: https://www.rubydoc.info/gems/runeterra_cards/
|
223
|
-
post_install_message:
|
223
|
+
post_install_message:
|
224
224
|
rdoc_options: []
|
225
225
|
require_paths:
|
226
226
|
- lib
|
@@ -236,7 +236,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
236
236
|
version: '0'
|
237
237
|
requirements: []
|
238
238
|
rubygems_version: 3.1.4
|
239
|
-
signing_key:
|
239
|
+
signing_key:
|
240
240
|
specification_version: 4
|
241
241
|
summary: Legends of Runeterra deck code decoder & Data Dragon card data loader.
|
242
242
|
test_files: []
|