runeterra_cards 0.2.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +4 -0
- data/doc/CHANGELOG.md +40 -0
- data/doc/README.md +64 -0
- data/lib/runeterra_cards.rb +7 -0
- data/lib/runeterra_cards/card_and_count.rb +3 -1
- data/lib/runeterra_cards/card_metadata.rb +9 -3
- data/lib/runeterra_cards/card_set.rb +19 -5
- data/lib/runeterra_cards/cost.rb +94 -0
- data/lib/runeterra_cards/errors.rb +18 -1
- data/lib/runeterra_cards/factions.rb +2 -0
- data/lib/runeterra_cards/metadata.rb +11 -0
- data/lib/runeterra_cards/version.rb +2 -1
- metadata +38 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 464996b724ae43c17f2725e24aaf616324b1ffbfa945c4ebf1158ebfe250cbab
|
4
|
+
data.tar.gz: e9c571d14c48ef39c5d25594ac7fbacafcd566b318887c1f49e31283cf5a9d00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5cf637f8898ed29afde28ced8036dc3806e5da4d1c03db12cb7d97e4be101dd7252466470f30b9edd709a290c8d8755e62c401d663c34cd945e8a7ea281fbba
|
7
|
+
data.tar.gz: df8cf13cdaaffdbbc985e17f406f66d7611c90c841a5df726d8d4f799bac0ce2dd2e64fe6a4144a44d9ce1e522e1e98ed7dddd0e9f1fac014ec445b2ba219f6c
|
data/.yardopts
ADDED
data/doc/CHANGELOG.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
|
+
|
7
|
+
## [0.4.0] - 2020-12-08
|
8
|
+
### Added
|
9
|
+
- [`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.
|
10
|
+
|
11
|
+
## [0.3.0] - 2020-08-31
|
12
|
+
### Added
|
13
|
+
- `Cost` class to represent crafting cost as wildcards & shards.
|
14
|
+
- `Metadata#cost_of` to get the cost of crafting a `CardSet`.
|
15
|
+
- Documented everything that is public & non-deprecated.
|
16
|
+
|
17
|
+
## [0.2.3] - 2020-08-31
|
18
|
+
### Fixed
|
19
|
+
- Fixed issue with documentation not rendering on rubydoc.info.
|
20
|
+
|
21
|
+
## [0.2.2] - 2020-08-30
|
22
|
+
### Fixed
|
23
|
+
- Included .yardopts in the Gem so README and CHANGELOG get included in documentation generated from the Gem.
|
24
|
+
|
25
|
+
## [0.2.1] - 2020-08-29
|
26
|
+
### Fixed
|
27
|
+
- Correctly packaged README and CHANGELOG in the Gem.
|
28
|
+
|
29
|
+
## [0.2.0] - 2020-08-29
|
30
|
+
### Added
|
31
|
+
- Added support for the Mount Targon faction
|
32
|
+
- UnrecognizedVersionError#version returns the version number that wasn't recognized.
|
33
|
+
- UnrecognizedFactionError, which is raised by CardAndCount#new (and by extension, CardSet#from_deck_code) if an unrecognized faction number is encountered.
|
34
|
+
|
35
|
+
### Changed
|
36
|
+
- FACTION_IDENTIFIERS_FROM_INT is now a Hash instead of an Array. The API for looking up a faction identifier by integer should remain unchanged in most cases.
|
37
|
+
|
38
|
+
## [0.1.0] - 2020-08-28
|
39
|
+
### Added
|
40
|
+
- Initial public release, with support for loading deck codes (Bilgewater and earlier) and loading metadata from Legends of Runeterra Data Dragon.
|
data/doc/README.md
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
<!-- This is the README file for the Gem documentation / online documentation. It should be thorough and authoritative for using the Gem, but not discuss development concerns, which belong in the Github README. -->
|
2
|
+
|
3
|
+
## Description
|
4
|
+
|
5
|
+
This library makes it easy to decode Legends of Runeterra deck codes, load Data Dragon metadata for cards, and perform operations on the data.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add the following to your `Gemfile`:
|
10
|
+
|
11
|
+
```
|
12
|
+
gem 'runeterra_cards', '~> 0.4.0'
|
13
|
+
```
|
14
|
+
|
15
|
+
Or, if you're building a Gem, your `.gemspec`:
|
16
|
+
|
17
|
+
```
|
18
|
+
spec.add_dependency 'runeterra_cards', '~> 0.4.0'
|
19
|
+
```
|
20
|
+
|
21
|
+
## Updates & Versioning
|
22
|
+
|
23
|
+
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.
|
24
|
+
|
25
|
+
All changes are documented in the {file:doc/CHANGELOG.md}.
|
26
|
+
|
27
|
+
## Main Concepts
|
28
|
+
|
29
|
+
Your typical main entry points to this library will be {RuneterraCards::CardSet} for manipulating deck codes and/or {RuneterraCards::Metadata} for handling Data Dragon card data.
|
30
|
+
|
31
|
+
## Examples
|
32
|
+
|
33
|
+
Load a deck code:
|
34
|
+
|
35
|
+
```
|
36
|
+
require 'runeterra_cards'
|
37
|
+
|
38
|
+
deck_code = 'CEBAOAQGC4OSKJZJF44ACAQFBIBAIAQGAEPCYNIBAICQOAYCAECSOMADAIDAKGRWAEBAKAY'
|
39
|
+
deck = RuneterraCards::CardSet.from_deck_code(deck_code)
|
40
|
+
|
41
|
+
deck.count_for_card_code('02BW053') #=> 2
|
42
|
+
|
43
|
+
deck.cards.each do |card, count|
|
44
|
+
puts "#{card} x#{count}"
|
45
|
+
end
|
46
|
+
```
|
47
|
+
|
48
|
+
Load metadata from Legends of Runeterra Data Dragon:
|
49
|
+
|
50
|
+
```
|
51
|
+
require 'runeterra_cards'
|
52
|
+
|
53
|
+
metadata = RuneterraCards::Metadata.new
|
54
|
+
|
55
|
+
metadata.add_set_file 'set1-en_us.json'
|
56
|
+
metadata.add_set_file 'set2-en_us.json'
|
57
|
+
|
58
|
+
card = metadata.lookup_card '02BW053'
|
59
|
+
card.name #=> "Nautilus"
|
60
|
+
```
|
61
|
+
|
62
|
+
## Development & Contributing
|
63
|
+
|
64
|
+
See the [Github project](https://github.com/zofrex/runeterra_cards) for more details.
|
data/lib/runeterra_cards.rb
CHANGED
@@ -7,8 +7,15 @@ require 'runeterra_cards/card_and_count'
|
|
7
7
|
require 'runeterra_cards/card_metadata'
|
8
8
|
require 'runeterra_cards/metadata'
|
9
9
|
require 'runeterra_cards/card_set'
|
10
|
+
require 'runeterra_cards/cost'
|
10
11
|
|
12
|
+
# The top-level module for +runeterra_cards+.
|
13
|
+
#
|
14
|
+
# Some of the most useful classes are {CardSet} and {Metadata}.
|
15
|
+
#
|
16
|
+
# You might also want to check out the {file:doc/README.md} and the {file:doc/CHANGELOG.md}.
|
11
17
|
module RuneterraCards
|
12
18
|
# The version of deck encoding supported
|
13
19
|
SUPPORTED_VERSION = 2
|
20
|
+
public_constant :SUPPORTED_VERSION
|
14
21
|
end
|
@@ -16,7 +16,7 @@ module RuneterraCards
|
|
16
16
|
# @param faction_number [Fixnum]
|
17
17
|
# @param card_number [Fixnum]
|
18
18
|
# @param count [Fixnum]
|
19
|
-
def initialize(code: nil,
|
19
|
+
def initialize(count:, code: nil, set: nil, faction_number: nil, card_number: nil)
|
20
20
|
if code
|
21
21
|
raise if set || faction_number || card_number
|
22
22
|
|
@@ -30,10 +30,12 @@ module RuneterraCards
|
|
30
30
|
@count = count
|
31
31
|
end
|
32
32
|
|
33
|
+
#:nodoc:
|
33
34
|
def eql?(other)
|
34
35
|
code.eql?(other.code) && count.equal?(other.count)
|
35
36
|
end
|
36
37
|
|
38
|
+
#:nodoc:
|
37
39
|
def hash
|
38
40
|
[code, count].hash
|
39
41
|
end
|
@@ -26,6 +26,10 @@ module RuneterraCards
|
|
26
26
|
# @return [String]
|
27
27
|
attr_reader :card_code
|
28
28
|
|
29
|
+
# Returns the cost attribute. For example: 3.
|
30
|
+
# @return [Fixnum]
|
31
|
+
attr_reader :cost
|
32
|
+
|
29
33
|
# Returns the card's rarity as a symbol. Can be one of: +:none+, +:common+, +:rare+, +:epic+, or +:champion+
|
30
34
|
# @return [Symbol]
|
31
35
|
attr_reader :rarity
|
@@ -38,12 +42,15 @@ module RuneterraCards
|
|
38
42
|
# @option hash [String] name
|
39
43
|
# @option hash [String] cardCode
|
40
44
|
# @option hash [Boolean] collectible
|
45
|
+
# @option hash [Fixnum] cost
|
46
|
+
# @option hash [String] rarityRef
|
41
47
|
#
|
42
48
|
# @raise [MissingCardDataError] if any of the expected hash parameters are missing, or if +rarityRef+ contains an
|
43
49
|
# unexpected value.
|
44
50
|
def initialize(hash)
|
45
51
|
begin
|
46
|
-
@name, @card_code, @collectible, rarity_ref =
|
52
|
+
@name, @card_code, @collectible, @cost, rarity_ref =
|
53
|
+
hash.fetch_values('name', 'cardCode', 'collectible', 'cost', 'rarityRef')
|
47
54
|
rescue KeyError => e
|
48
55
|
raise MetadataLoadError.new(hash['name'] || hash['cardCode'], "Missing expected key: #{e.key}")
|
49
56
|
end
|
@@ -51,8 +58,7 @@ module RuneterraCards
|
|
51
58
|
@rarity = RARITIES[rarity_ref]
|
52
59
|
return unless rarity.nil?
|
53
60
|
|
54
|
-
raise MetadataLoadError.
|
55
|
-
"expected one of: #{RARITIES.keys.join ', '}")
|
61
|
+
raise MetadataLoadError.invalid_rarity(name, rarity_ref, RARITIES.keys)
|
56
62
|
end
|
57
63
|
|
58
64
|
# Whether or not the card is collectible.
|
@@ -7,8 +7,10 @@ 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
|
+
# @return [Hash<String,Fixnum>]
|
10
11
|
attr_reader :cards
|
11
12
|
|
13
|
+
# @param [Hash<String,Fixnum>] cards A Hash of card codes mapping to card counts
|
12
14
|
def initialize(cards)
|
13
15
|
@cards = cards
|
14
16
|
end
|
@@ -18,30 +20,40 @@ module RuneterraCards
|
|
18
20
|
new(Hash[set.map { |cac| [cac.code, cac.count] }])
|
19
21
|
end
|
20
22
|
|
23
|
+
# Subtract another {CardSet CardSet} from this one. Items with count 0 are not represented in the returned
|
24
|
+
# {CardSet CardSet}, they are removed altogether.
|
25
|
+
# @param [CardSet] other An object that responds to {#count_for_card_code}
|
26
|
+
# @return [CardSet]
|
21
27
|
def -(other)
|
22
|
-
remaining_cards =
|
23
|
-
|
24
|
-
|
25
|
-
|
28
|
+
remaining_cards =
|
29
|
+
cards.each_with_object({}) do |(code, count), result|
|
30
|
+
new_count = count - other.count_for_card_code(code)
|
31
|
+
result[code] = new_count unless new_count.equal?(0)
|
32
|
+
end
|
26
33
|
|
27
34
|
CardSet.new(remaining_cards)
|
28
35
|
end
|
29
36
|
|
30
|
-
# @return Enumerator<CardAndCount>
|
37
|
+
# @return [Enumerator<CardAndCount>]
|
31
38
|
# @deprecated
|
32
39
|
def as_card_and_counts
|
33
40
|
cards.map { |code, count| CardAndCount.new(code: code, count: count) }
|
34
41
|
end
|
35
42
|
|
43
|
+
# Returns how many of the given card are in this CardSet.
|
44
|
+
# @param [String] code Card code, e.g. "01DE031"
|
45
|
+
# @return [Fixnum] How many of the card are in this CardSet, or 0 if it isn't present.
|
36
46
|
def count_for_card_code(code)
|
37
47
|
cards[code] || 0
|
38
48
|
end
|
39
49
|
|
50
|
+
# Parse a Deck Code.
|
40
51
|
# @param deck_code [String]
|
41
52
|
# @raise [Base32Error] if the deck code cannot be Base32 decoded.
|
42
53
|
# @raise [UnrecognizedVersionError] if the deck code's version is not supported by this library
|
43
54
|
# (see {SUPPORTED_VERSION}).
|
44
55
|
# @raise [EmptyInputError] if the deck code is an empty string.
|
56
|
+
# @return [CardSet]
|
45
57
|
def self.from_deck_code(deck_code)
|
46
58
|
binary_data = decode_base32(deck_code)
|
47
59
|
format, version = decode_format_and_version(binary_data[0])
|
@@ -80,6 +92,8 @@ module RuneterraCards
|
|
80
92
|
|
81
93
|
private_class_method :decode_format_and_version
|
82
94
|
|
95
|
+
# @param [Array<Fixnum>] array
|
96
|
+
# @return [Array<CardAndCount>]
|
83
97
|
def self.assemble_card_list(array)
|
84
98
|
3.downto(1).flat_map do |number_of_copies|
|
85
99
|
set_faction_combination_count = array.shift
|
@@ -0,0 +1,94 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuneterraCards
|
4
|
+
# Represents the cost of a {CardSet}, as wildcards or shards.
|
5
|
+
# To get the cost of a {CardSet} you need to call {Metadata#cost_of}, as rarity (and therefore cost) is a property
|
6
|
+
# of metadata.
|
7
|
+
#
|
8
|
+
# A {Cost} object tells you how many wildcards would be needed to craft a {CardSet}, or alternatively how many
|
9
|
+
# shards would be needed. You can figure out the cost of a mixture of wildcards and shards by creating a new {Cost}
|
10
|
+
# object representing the wildcards to be spent, and subtracting that from the original {Cost} object.
|
11
|
+
#
|
12
|
+
# @example Getting the shard cost for a {CardSet}
|
13
|
+
# cost = metadata.cost_of(card_set)
|
14
|
+
# cost.shards #=> 3000
|
15
|
+
#
|
16
|
+
# @example Getting wildcard costs for a {CardSet}
|
17
|
+
# cost = metadata.cost_of(card_set)
|
18
|
+
# cost.common #=> 3
|
19
|
+
# cost.rare #=> 1
|
20
|
+
# # etc
|
21
|
+
#
|
22
|
+
# @example Getting remaining cost after spending some wildcards
|
23
|
+
# cost = metadata.cost_of(card_set)
|
24
|
+
# cost.dust #=> 11500
|
25
|
+
#
|
26
|
+
# wildcards_in_hand = Cost.new(10, 5, 3, 1)
|
27
|
+
# remaining_cost = cost - wildcards_in_hand
|
28
|
+
# remaining_cost.dust #=> 5100
|
29
|
+
class Cost
|
30
|
+
# The number of Common wildcards needed
|
31
|
+
# @return [Fixnum] count
|
32
|
+
attr_reader :common
|
33
|
+
|
34
|
+
# The number of Rare wildcards needed
|
35
|
+
# @return [Fixnum] count
|
36
|
+
attr_reader :rare
|
37
|
+
|
38
|
+
# The number of Epic wildcards needed
|
39
|
+
# @return [Fixnum] count
|
40
|
+
attr_reader :epic
|
41
|
+
|
42
|
+
# The number of Champion wildcards needed
|
43
|
+
# @return [Fixnum] count
|
44
|
+
attr_reader :champion
|
45
|
+
|
46
|
+
# @param [Fixnum] common
|
47
|
+
# @param [Fixnum] rare
|
48
|
+
# @param [Fixnum] epic
|
49
|
+
# @param [Fixnum] champion
|
50
|
+
def initialize(common, rare, epic, champion)
|
51
|
+
@common, @rare, @epic, @champion = common, rare, epic, champion
|
52
|
+
end
|
53
|
+
|
54
|
+
# The number of shards needed. I.e. the equivalent amount of shards for all these wildcards.
|
55
|
+
# @return [Fixnum] shards
|
56
|
+
def shards
|
57
|
+
common * 100 +
|
58
|
+
rare * 300 +
|
59
|
+
epic * 1200 +
|
60
|
+
champion * 3000
|
61
|
+
end
|
62
|
+
|
63
|
+
# Whether this Cost is equal to another. Equality means exactly the same number of each wildcard, not just the
|
64
|
+
# same shard count.
|
65
|
+
# @param [Cost] other an object that response to {#common}, {#rare}, {#epic}, and {#champion}.
|
66
|
+
# @return [Boolean] equal?
|
67
|
+
def ==(other)
|
68
|
+
common.equal?(other.common) &&
|
69
|
+
rare.equal?(other.rare) &&
|
70
|
+
epic.equal?(other.epic) &&
|
71
|
+
champion.equal?(other.champion)
|
72
|
+
end
|
73
|
+
|
74
|
+
# Subtracts another Cost from this one. Subtraction is performed by subtracting each wildcard type individually,
|
75
|
+
# not by operating on the shard count. The minimum value any wildcard will have is zero, so +5 - 7 = 0+ for
|
76
|
+
# example.
|
77
|
+
# @note This will not return negative values.
|
78
|
+
# @param [Cost] other an object that response to {#common}, {#rare}, {#epic}, and {#champion}.
|
79
|
+
# @return [Cost] The remaining cost, with a floor of 0.
|
80
|
+
# @example
|
81
|
+
# minuend = Cost.new(9, 8, 5, 2)
|
82
|
+
# subtrahend = Cost.new(7, 8, 2, 3)
|
83
|
+
# result = minuend - subtrahend
|
84
|
+
# result #=> Cost.new(2, 0, 3, 0)
|
85
|
+
def -(other)
|
86
|
+
Cost.new(
|
87
|
+
[common - other.common, 0].max,
|
88
|
+
[rare - other.rare, 0].max,
|
89
|
+
[epic - other.epic, 0].max,
|
90
|
+
[champion - other.champion, 0].max
|
91
|
+
)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -8,6 +8,7 @@ module RuneterraCards
|
|
8
8
|
# This exception is raised if the deck code cannot be Base32-decoded. This probably means it isn't a deck code, or
|
9
9
|
# got malformed somehow.
|
10
10
|
class Base32Error < DeckCodeParseError
|
11
|
+
# Returns a new instance of Base32Error with a helpful error message preloaded.
|
11
12
|
def initialize
|
12
13
|
super('Encountered an error while Base32 decoding deck code.' \
|
13
14
|
' Probably an invalid deck code, or possibly a bug in the Base32 handling.')
|
@@ -16,6 +17,7 @@ module RuneterraCards
|
|
16
17
|
|
17
18
|
# This exception is raised if the deck code is an empty string.
|
18
19
|
class EmptyInputError < DeckCodeParseError
|
20
|
+
# Returns a new instance of EmptyInputError with a helpful error message preloaded.
|
19
21
|
def initialize
|
20
22
|
super('The input was an empty string')
|
21
23
|
end
|
@@ -32,6 +34,8 @@ module RuneterraCards
|
|
32
34
|
# @return [Fixnum] the version number encountered in the deck code
|
33
35
|
attr_accessor :version
|
34
36
|
|
37
|
+
# @param [Fixnum] expected The version number we were expecting to see in the deck code.
|
38
|
+
# @param [Fixnum] got The version number we actually got.
|
35
39
|
def initialize(expected, got)
|
36
40
|
super("Unrecognized deck code version number: #{got}, was expecting: #{expected}. \
|
37
41
|
Possibly an invalid deck code, possibly you need to update the deck code library version.")
|
@@ -50,6 +54,7 @@ Possibly an invalid deck code, possibly you need to update the deck code library
|
|
50
54
|
# @return [Fixnum] the faction number that was unrecognized
|
51
55
|
attr_reader :faction_number
|
52
56
|
|
57
|
+
# @param [Fixnum] faction_number The faction number we encountered and did not recognise.
|
53
58
|
def initialize(faction_number)
|
54
59
|
super("Unrecognized faction number '#{faction_number}'."\
|
55
60
|
' Possibly you need to update this library to a newer version')
|
@@ -61,7 +66,7 @@ Possibly an invalid deck code, possibly you need to update the deck code library
|
|
61
66
|
# The message will tell you what data was not right, and the {#card} attribute will tell you which card had issues,
|
62
67
|
# if possible.
|
63
68
|
#
|
64
|
-
# @see CardMetadata#initialize
|
69
|
+
# @see CardMetadata#initialize CardMetadata#initialize for details on when this error is raised.
|
65
70
|
class MetadataLoadError < StandardError
|
66
71
|
# Return the name or card code of the card that was missing an expected attribute.
|
67
72
|
# @return [String] name if the name was present
|
@@ -69,6 +74,8 @@ Possibly an invalid deck code, possibly you need to update the deck code library
|
|
69
74
|
# @return [nil] if neither name nor card code were present
|
70
75
|
attr_reader :card
|
71
76
|
|
77
|
+
# @param [String] card The card's name or cardCode.
|
78
|
+
# @param [String] problem Details on the problem encountered loading the card.
|
72
79
|
def initialize(card, problem)
|
73
80
|
if card.nil?
|
74
81
|
super("Error loading data for unknown card (no code or name): #{problem}")
|
@@ -77,5 +84,15 @@ Possibly an invalid deck code, possibly you need to update the deck code library
|
|
77
84
|
end
|
78
85
|
@card = card
|
79
86
|
end
|
87
|
+
|
88
|
+
# Create a {MetadataLoadError MetadataLoadError} with a helpful message regarding an invalid value for rarityRef.
|
89
|
+
# @param [String] card The card name that had an invalid rarityRef value.
|
90
|
+
#
|
91
|
+
# @param [String] given The value that rarityRef had.
|
92
|
+
# @param [Enumerable<String>] expected A list of values that would have been valid.
|
93
|
+
# @return [MetadataLoadError]
|
94
|
+
def self.invalid_rarity(card, given, expected)
|
95
|
+
new(card, "Invalid value for rarityRef, got: #{given}, expected one of: #{expected.join ', '}")
|
96
|
+
end
|
80
97
|
end
|
81
98
|
end
|
@@ -15,6 +15,7 @@ module RuneterraCards
|
|
15
15
|
6 => 'BW',
|
16
16
|
9 => 'MT',
|
17
17
|
}.freeze
|
18
|
+
public_constant :FACTION_IDENTIFIERS_FROM_INT
|
18
19
|
|
19
20
|
# A map from two-letter Faction identifiers to their integer identifiers
|
20
21
|
# @example
|
@@ -30,4 +31,5 @@ module RuneterraCards
|
|
30
31
|
'BW' => 6,
|
31
32
|
'MT' => 9,
|
32
33
|
}.freeze
|
34
|
+
public_constant :FACTION_INTS_FROM_IDENTIFIER
|
33
35
|
end
|
@@ -20,6 +20,7 @@ module RuneterraCards
|
|
20
20
|
# @note This class cannot yet handle metadata for multiple locales at the same time. You will need multiple instances
|
21
21
|
# of this class, one for each locale, if you wish to handle multiple locales at this time.
|
22
22
|
class Metadata
|
23
|
+
# Create a new, empty, metadata repository.
|
23
24
|
def initialize
|
24
25
|
@cards = {}
|
25
26
|
end
|
@@ -57,5 +58,15 @@ module RuneterraCards
|
|
57
58
|
def full_set
|
58
59
|
CardSet.new(all_collectible.keys.each_with_object({}) { |code, result| result[code] = 3 })
|
59
60
|
end
|
61
|
+
|
62
|
+
# @param [CardSet] card_set
|
63
|
+
# @return [Cost] the cost of crafting all the cards in the supplied CardSet
|
64
|
+
def cost_of(card_set)
|
65
|
+
rarity_and_count = card_set.cards.map { |card, count| [lookup_card(card).rarity, count] }
|
66
|
+
total = { common: 0, rare: 0, epic: 0, champion: 0 }
|
67
|
+
rarity_and_count.each { |(rarity, count)| total[rarity] += count }
|
68
|
+
|
69
|
+
Cost.new(total.fetch(:common), total.fetch(:rare), total.fetch(:epic), total.fetch(:champion))
|
70
|
+
end
|
60
71
|
end
|
61
72
|
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.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- zofrex
|
7
|
+
- James "zofrex" Sanderson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-08
|
11
|
+
date: 2020-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: base32
|
@@ -80,20 +80,34 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 1.4.2
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: mutant
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.10.0
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.10.0
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: mutant-minitest
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
|
-
- - "
|
101
|
+
- - "~>"
|
88
102
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
103
|
+
version: 0.10.0
|
90
104
|
type: :development
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
|
-
- - "
|
108
|
+
- - "~>"
|
95
109
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
110
|
+
version: 0.10.0
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: rake
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,14 +128,14 @@ dependencies:
|
|
114
128
|
requirements:
|
115
129
|
- - "~>"
|
116
130
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
131
|
+
version: '1.2'
|
118
132
|
type: :development
|
119
133
|
prerelease: false
|
120
134
|
version_requirements: !ruby/object:Gem::Requirement
|
121
135
|
requirements:
|
122
136
|
- - "~>"
|
123
137
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
138
|
+
version: '1.2'
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: rubocop-minitest
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,28 +156,28 @@ dependencies:
|
|
142
156
|
requirements:
|
143
157
|
- - "~>"
|
144
158
|
- !ruby/object:Gem::Version
|
145
|
-
version: 0.
|
159
|
+
version: 0.5.1
|
146
160
|
type: :development
|
147
161
|
prerelease: false
|
148
162
|
version_requirements: !ruby/object:Gem::Requirement
|
149
163
|
requirements:
|
150
164
|
- - "~>"
|
151
165
|
- !ruby/object:Gem::Version
|
152
|
-
version: 0.
|
166
|
+
version: 0.5.1
|
153
167
|
- !ruby/object:Gem::Dependency
|
154
168
|
name: rubocop-performance
|
155
169
|
requirement: !ruby/object:Gem::Requirement
|
156
170
|
requirements:
|
157
171
|
- - "~>"
|
158
172
|
- !ruby/object:Gem::Version
|
159
|
-
version: '1.
|
173
|
+
version: '1.8'
|
160
174
|
type: :development
|
161
175
|
prerelease: false
|
162
176
|
version_requirements: !ruby/object:Gem::Requirement
|
163
177
|
requirements:
|
164
178
|
- - "~>"
|
165
179
|
- !ruby/object:Gem::Version
|
166
|
-
version: '1.
|
180
|
+
version: '1.8'
|
167
181
|
- !ruby/object:Gem::Dependency
|
168
182
|
name: yard
|
169
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,18 +192,22 @@ dependencies:
|
|
178
192
|
- - "~>"
|
179
193
|
- !ruby/object:Gem::Version
|
180
194
|
version: 0.9.25
|
181
|
-
description: Legends of Runeterra deck
|
195
|
+
description: Legends of Runeterra deck code decoder & Data Dragon card data loader.
|
182
196
|
email:
|
183
197
|
- zofrex@gmail.com
|
184
198
|
executables: []
|
185
199
|
extensions: []
|
186
200
|
extra_rdoc_files: []
|
187
201
|
files:
|
202
|
+
- ".yardopts"
|
188
203
|
- LICENSE.txt
|
204
|
+
- doc/CHANGELOG.md
|
205
|
+
- doc/README.md
|
189
206
|
- lib/runeterra_cards.rb
|
190
207
|
- lib/runeterra_cards/card_and_count.rb
|
191
208
|
- lib/runeterra_cards/card_metadata.rb
|
192
209
|
- lib/runeterra_cards/card_set.rb
|
210
|
+
- lib/runeterra_cards/cost.rb
|
193
211
|
- lib/runeterra_cards/errors.rb
|
194
212
|
- lib/runeterra_cards/factions.rb
|
195
213
|
- lib/runeterra_cards/metadata.rb
|
@@ -197,7 +215,11 @@ files:
|
|
197
215
|
homepage:
|
198
216
|
licenses:
|
199
217
|
- MIT
|
200
|
-
metadata:
|
218
|
+
metadata:
|
219
|
+
bug_tracker_uri: https://github.com/zofrex/runeterra_cards/issues
|
220
|
+
changelog_uri: https://www.rubydoc.info/gems/runeterra_cards/file/doc/CHANGELOG.md
|
221
|
+
source_code_uri: https://github.com/zofrex/runeterra_cards
|
222
|
+
documentation_uri: https://www.rubydoc.info/gems/runeterra_cards/
|
201
223
|
post_install_message:
|
202
224
|
rdoc_options: []
|
203
225
|
require_paths:
|
@@ -216,5 +238,5 @@ requirements: []
|
|
216
238
|
rubygems_version: 3.1.4
|
217
239
|
signing_key:
|
218
240
|
specification_version: 4
|
219
|
-
summary: Legends of Runeterra deck
|
241
|
+
summary: Legends of Runeterra deck code decoder & Data Dragon card data loader.
|
220
242
|
test_files: []
|