zombie_battleground-api 0.5.2 → 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2c7c563634fc6b470641f8f5ea49562d4654b23805467a59ed9975e1634c6fcc
4
- data.tar.gz: bc3189b7fa13d12c5dc11d48d36d1275b4f52fbb3fbb10232bb98128a2aad6dd
3
+ metadata.gz: 6d879da9c1d58532b447140afab76f0ec9cb942d0c37d9521ebbc2092e06549e
4
+ data.tar.gz: 2d2702e9607a76814e1db007efb2f0599ca9c3f30a20c62424ab0ad71884c5ac
5
5
  SHA512:
6
- metadata.gz: fbf2525edb696e3b74244a82461d661fc5fc88a0add2405c5d3e60c4d6c77aa085ab47b2ead0389f1a1bce4e8a432abced9df95e43ed82fabbd56cb1597615fe
7
- data.tar.gz: d6356e263cecfdf5882f29106b10925b552664d79a01197f12528c580d3dc4d017cde225890dfb969b2ce4a98e21db79e870a0726aaa023f90fef41e52385c51
6
+ metadata.gz: 9f29636bb98ff7611d717f0408d2379961634aede5f901adef1ee446af838210c5a3d693a0e6e547dc0dee8caa35e89a9a01dae5f7516ddd0c2f6cc4b77b5e1d
7
+ data.tar.gz: 41a7208818c1208ac8a22a1f5e05f588171774422368c44a64641ebba095347d7cc6a90dfac4abff28633a82f23adb8aacdf8a80418f082983d9d768c394b80c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- zombie_battleground-api (0.5.2)
4
+ zombie_battleground-api (0.6.0)
5
5
  activerecord
6
6
  faraday
7
7
  json
data/README.md CHANGED
@@ -26,7 +26,7 @@ Or install it yourself as:
26
26
 
27
27
  ## Usage
28
28
 
29
- See the [API documentation](https://www.rubydoc.info/gems/zombie_battleground-api/0.5.2).
29
+ See the [API documentation](https://www.rubydoc.info/gems/zombie_battleground-api/0.6.0).
30
30
  Every API call returns a response object that contains a complete modeled Ruby object of the response.
31
31
 
32
32
  Use the singleton class `ZombieBattleground::Api`. The singleton has additional extentions, the client implements the public API as is.
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'yaml'
4
+
3
5
  require 'zombie_battleground/api/constants'
4
6
 
5
7
  module ZombieBattleground
@@ -48,6 +50,33 @@ module ZombieBattleground
48
50
  # :nocov:
49
51
  end
50
52
  end
53
+
54
+ ##
55
+ # Return's the deck overlord (hero) type faction
56
+ #
57
+ # @param type [Integer]
58
+ #
59
+ # @return [String}
60
+ #
61
+ # @example
62
+ # deck_faction(0) # => "EARTH"
63
+ #
64
+ # @api public
65
+ def deck_faction(type)
66
+ load_decks_data['overlord_types'][type]
67
+ end
68
+
69
+ private
70
+
71
+ ##
72
+ # Loads the helper data for decks
73
+ #
74
+ # @return [Hash]
75
+ #
76
+ # @api private
77
+ def load_decks_data
78
+ @load_decks_data ||= YAML.safe_load(File.read(File.join(__dir__, 'decks.yml')))
79
+ end
51
80
  end
52
81
  end
53
82
  end
@@ -0,0 +1,27 @@
1
+ ---
2
+
3
+ # API doesn't provide an endpoint for enumerating deck metadata
4
+
5
+ # WHY!? is this not exposed somewhere?... https://zombiebattleground.io/index.php/Faction
6
+ # Complete reverse engineer of overlord number to faction
7
+ # [45] pry(main)> typed_decks = Array.new(6) { |num| [num, Set.new] }.to_h
8
+ # => {0=>#<Set: {}>, 1=>#<Set: {}>, 2=>#<Set: {}>, 3=>#<Set: {}>, 4=>#<Set: {}>, 5=>#<Set: {}>}
9
+ # [46] pry(main)> $decks.map { |deck| typed_decks[deck.hero_id].merge(deck_types(deck)) } ; nil
10
+ # => nil
11
+ # [47] pry(main)> typed_decks
12
+ # => {0=>#<Set: {"TOXIC", "ITEM", "AIR", "EARTH", "FIRE", "WATER"}>,
13
+ # 1=>#<Set: {"FIRE", "ITEM", "LIFE", "EARTH", "AIR", "TOXIC"}>,
14
+ # 2=>#<Set: {"WATER", "ITEM", "LIFE", "FIRE", "EARTH", "TOXIC"}>,
15
+ # 3=>#<Set: {"WATER", "TOXIC", "AIR", "LIFE", "FIRE", "ITEM"}>,
16
+ # 4=>#<Set: {"TOXIC", "WATER", "EARTH", "AIR", "ITEM", "LIFE"}>,
17
+ # 5=>#<Set: {"ITEM", "LIFE", "AIR", "WATER", "EARTH", "FIRE"}>}
18
+ # [48] pry(main)> Array.new(6) { |n| (typed_decks[n]^Set.new(["ITEM", "TOXIC", "LIFE", "AIR", "EARTH", "FIRE", "WATER"])).to_a.first }.map { |weakness| weak_against[weakness] }
19
+ # => ["EARTH", "FIRE", "WATER", "AIR", "TOXIC", "LIFE"]
20
+
21
+ overlord_types:
22
+ - 'EARTH' # 0
23
+ - 'FIRE' # 1
24
+ - 'WATER' # 2
25
+ - 'AIR' # 3
26
+ - 'TOXIC' # 4
27
+ - 'LIFE' # 5
@@ -6,6 +6,6 @@ module ZombieBattleground
6
6
  class Api
7
7
  ##
8
8
  # Verion of the Gem
9
- VERSION = '0.5.2'
9
+ VERSION = '0.6.0'
10
10
  end
11
11
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zombie_battleground-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Shields
@@ -249,6 +249,7 @@ files:
249
249
  - lib/zombie_battleground/api/extensions/cards.rb
250
250
  - lib/zombie_battleground/api/extensions/cards.yml
251
251
  - lib/zombie_battleground/api/extensions/decks.rb
252
+ - lib/zombie_battleground/api/extensions/decks.yml
252
253
  - lib/zombie_battleground/api/models/card.rb
253
254
  - lib/zombie_battleground/api/models/deck.rb
254
255
  - lib/zombie_battleground/api/models/match.rb