zombie_battleground-api 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/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/zombie_battleground/api/client.rb +13 -1
- data/lib/zombie_battleground/api/constants.rb +4 -0
- data/lib/zombie_battleground/api/extensions/cards.rb +60 -16
- data/lib/zombie_battleground/api/extensions/cards.yml +49 -0
- data/lib/zombie_battleground/api/models/deck.rb +17 -0
- data/lib/zombie_battleground/api/responses/get_cards_response.rb +40 -0
- data/lib/zombie_battleground/api/responses/get_decks_response.rb +40 -0
- data/lib/zombie_battleground/api/responses/get_matches_response.rb +40 -0
- data/lib/zombie_battleground/api/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0eed5214567ac570ecbdfcbeedc8269cd6ccb7b4b9a1478f319ef27a2e67ba8e
|
4
|
+
data.tar.gz: 92782a7faa90816774764b2d70f078d0f9e3c2a1d30f1c29253030935900d130
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b397cee1af935eb4f24084c325bd96cca10ffbeee7916611446057c88497d52c6d35c8a39648ec5292da05e6eea65c74d1414a9b86dbefe177db43656e13d27
|
7
|
+
data.tar.gz: '09ee97e39b13d6dd8e52811d9083c619e6e70a78b00514eb2d2b5c940d85b54bb2971d97f260d51e47fe27ac9f4bca193cb839d8220a5caa08b9cb8a009585f1'
|
data/Gemfile.lock
CHANGED
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.
|
29
|
+
See the [API documentation](https://www.rubydoc.info/gems/zombie_battleground-api/0.5.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.
|
@@ -59,9 +59,10 @@ module ZombieBattleground
|
|
59
59
|
# @param hero_id [Integer] Optionally filter on Deck hero_id
|
60
60
|
# @param primary_skill_id [Integer] Optionally filter on Deck primary_skill_id
|
61
61
|
# @param secondary_skill_id [Integer] Optionally filter on Deck secondary_skill_id
|
62
|
-
# @param version [
|
62
|
+
# @param version [string] optionally filter on deck version
|
63
63
|
# @param page [Integer] Used for pagination of query results
|
64
64
|
# @param limit [Integer] Used for pagination of query results. Max 100
|
65
|
+
# @param remove_invalid [Boolean] Remove invalid decks from response. Default: true
|
65
66
|
#
|
66
67
|
# @return [ZombieBattleground::Api::Responses::GetDecksResponse]
|
67
68
|
#
|
@@ -73,12 +74,15 @@ module ZombieBattleground
|
|
73
74
|
#
|
74
75
|
# @api public
|
75
76
|
def decks_request(**args)
|
77
|
+
remove_invalid = args[:remove_invalid].nil? ? true : args.delete(:remove_invalid)
|
78
|
+
|
76
79
|
request = ZombieBattleground::Api::Requests::GetDecksRequest.new
|
77
80
|
args.each { |key, val| request.send("#{key}=", val) }
|
78
81
|
raise ZombieBattleground::Api::Errors::InvalidInput, request.errors.messages unless request.valid?
|
79
82
|
|
80
83
|
response = connection(uri: request.uri, params: request.params).get
|
81
84
|
decks = ZombieBattleground::Api::Responses::GetDecksResponse.new(response)
|
85
|
+
decks.remove_invalid = remove_invalid
|
82
86
|
raise ZombieBattleground::Api::Errors::InvalidResponse.new(response, decks) unless decks.valid?
|
83
87
|
|
84
88
|
decks
|
@@ -121,6 +125,7 @@ module ZombieBattleground
|
|
121
125
|
# @param winner_id [String] Optionally filter on Match winner_id
|
122
126
|
# @param page [Integer] Used for pagination of query results
|
123
127
|
# @param limit [Integer] Used for pagination of query results. Max 100
|
128
|
+
# @param remove_invalid [Boolean] Remove invalid decks from response. Default: true
|
124
129
|
#
|
125
130
|
# @return [ZombieBattleground::Api::Responses::GetMatchesResponse]
|
126
131
|
#
|
@@ -132,12 +137,15 @@ module ZombieBattleground
|
|
132
137
|
#
|
133
138
|
# @api public
|
134
139
|
def matches_request(**args)
|
140
|
+
remove_invalid = args[:remove_invalid].nil? ? true : args.delete(:remove_invalid)
|
141
|
+
|
135
142
|
request = ZombieBattleground::Api::Requests::GetMatchesRequest.new
|
136
143
|
args.each { |key, val| request.send("#{key}=", val) }
|
137
144
|
raise ZombieBattleground::Api::Errors::InvalidInput, request.errors.messages unless request.valid?
|
138
145
|
|
139
146
|
response = connection(uri: request.uri, params: request.params).get
|
140
147
|
matches = ZombieBattleground::Api::Responses::GetMatchesResponse.new(response)
|
148
|
+
matches.remove_invalid = remove_invalid
|
141
149
|
raise ZombieBattleground::Api::Errors::InvalidResponse.new(response, matches) unless matches.valid?
|
142
150
|
|
143
151
|
matches
|
@@ -186,6 +194,7 @@ module ZombieBattleground
|
|
186
194
|
# @param cost [Integer] Optionally filter on Card cost
|
187
195
|
# @param page [Integer] Used for pagination of query results
|
188
196
|
# @param limit [Integer] Used for pagination of query results. Max 100
|
197
|
+
# @param remove_invalid [Boolean] Remove invalid decks from response. Default: true
|
189
198
|
#
|
190
199
|
# @return [ZombieBattleground::Api::Responses::GetCardsResponse]
|
191
200
|
#
|
@@ -197,12 +206,15 @@ module ZombieBattleground
|
|
197
206
|
#
|
198
207
|
# @api public
|
199
208
|
def cards_request(**args)
|
209
|
+
remove_invalid = args[:remove_invalid].nil? ? true : args.delete(:remove_invalid)
|
210
|
+
|
200
211
|
request = ZombieBattleground::Api::Requests::GetCardsRequest.new
|
201
212
|
args.each { |key, val| request.send("#{key}=", val) }
|
202
213
|
raise ZombieBattleground::Api::Errors::InvalidInput, request.errors.messages unless request.valid?
|
203
214
|
|
204
215
|
response = connection(uri: request.uri, params: request.params).get
|
205
216
|
cards = ZombieBattleground::Api::Responses::GetCardsResponse.new(response)
|
217
|
+
cards.remove_invalid = remove_invalid
|
206
218
|
raise ZombieBattleground::Api::Errors::InvalidResponse.new(response, cards) unless cards.valid?
|
207
219
|
|
208
220
|
cards
|
@@ -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
|
@@ -34,7 +36,7 @@ module ZombieBattleground
|
|
34
36
|
# @api public
|
35
37
|
def all_cards(**args)
|
36
38
|
args.delete(:limit) # query as many as possible
|
37
|
-
return enum_for(:all_cards) unless block_given?
|
39
|
+
return enum_for(:all_cards, args) unless block_given?
|
38
40
|
|
39
41
|
page = 1
|
40
42
|
|
@@ -60,7 +62,7 @@ module ZombieBattleground
|
|
60
62
|
#
|
61
63
|
# @api public
|
62
64
|
def card_kinds
|
63
|
-
|
65
|
+
load_cards_data['kinds']
|
64
66
|
end
|
65
67
|
|
66
68
|
##
|
@@ -74,7 +76,7 @@ module ZombieBattleground
|
|
74
76
|
#
|
75
77
|
# @api public
|
76
78
|
def card_ranks
|
77
|
-
|
79
|
+
load_cards_data['ranks']
|
78
80
|
end
|
79
81
|
|
80
82
|
##
|
@@ -88,7 +90,21 @@ module ZombieBattleground
|
|
88
90
|
#
|
89
91
|
# @api public
|
90
92
|
def card_sets
|
91
|
-
|
93
|
+
load_cards_data['sets']
|
94
|
+
end
|
95
|
+
|
96
|
+
##
|
97
|
+
# Fetches all card factions
|
98
|
+
#
|
99
|
+
# @return [Array<String>]
|
100
|
+
#
|
101
|
+
# @example
|
102
|
+
# factions = ZombieBattleground::Api.card_factions
|
103
|
+
# # => [String]
|
104
|
+
#
|
105
|
+
# @api public
|
106
|
+
def card_factions
|
107
|
+
load_cards_data['factions']
|
92
108
|
end
|
93
109
|
|
94
110
|
##
|
@@ -102,7 +118,7 @@ module ZombieBattleground
|
|
102
118
|
#
|
103
119
|
# @api public
|
104
120
|
def card_types
|
105
|
-
|
121
|
+
load_cards_data['types']
|
106
122
|
end
|
107
123
|
|
108
124
|
##
|
@@ -116,7 +132,7 @@ module ZombieBattleground
|
|
116
132
|
#
|
117
133
|
# @api public
|
118
134
|
def card_rarities
|
119
|
-
|
135
|
+
load_cards_data['rarities']
|
120
136
|
end
|
121
137
|
|
122
138
|
##
|
@@ -127,11 +143,11 @@ module ZombieBattleground
|
|
127
143
|
# @return [Array<ZombieBattleground::Api::Models::Card>]
|
128
144
|
#
|
129
145
|
# @example
|
130
|
-
# cards = ZombieBattleground::Api.cards_by_kind(
|
146
|
+
# cards = ZombieBattleground::Api.cards_by_kind("SPELL")
|
131
147
|
# # => [ZombieBattleground::Api::Models::Card]
|
132
148
|
#
|
133
149
|
# @api public
|
134
|
-
def cards_by_kind(kind
|
150
|
+
def cards_by_kind(kind)
|
135
151
|
all_cards(kind: kind).to_a
|
136
152
|
end
|
137
153
|
|
@@ -143,11 +159,11 @@ module ZombieBattleground
|
|
143
159
|
# @return [Array<ZombieBattleground::Api::Models::Card>]
|
144
160
|
#
|
145
161
|
# @example
|
146
|
-
# cards = ZombieBattleground::Api.cards_by_rank(
|
162
|
+
# cards = ZombieBattleground::Api.cards_by_rank("COMMANDER")
|
147
163
|
# # => [ZombieBattleground::Api::Models::Card]
|
148
164
|
#
|
149
165
|
# @api public
|
150
|
-
def cards_by_rank(rank
|
166
|
+
def cards_by_rank(rank)
|
151
167
|
all_cards(rank: rank).to_a
|
152
168
|
end
|
153
169
|
|
@@ -159,14 +175,30 @@ module ZombieBattleground
|
|
159
175
|
# @return [Array<ZombieBattleground::Api::Models::Card>]
|
160
176
|
#
|
161
177
|
# @example
|
162
|
-
# cards = ZombieBattleground::Api.cards_by_set(
|
178
|
+
# cards = ZombieBattleground::Api.cards_by_set("WATER")
|
163
179
|
# # => [ZombieBattleground::Api::Models::Card]
|
164
180
|
#
|
165
181
|
# @api public
|
166
|
-
def cards_by_set(set
|
182
|
+
def cards_by_set(set)
|
167
183
|
all_cards(set: set).to_a
|
168
184
|
end
|
169
185
|
|
186
|
+
##
|
187
|
+
# Fetches all cards with selected faction
|
188
|
+
#
|
189
|
+
# @param faction [String]
|
190
|
+
#
|
191
|
+
# @return [Array<ZombieBattleground::Api::Models::Card>]
|
192
|
+
#
|
193
|
+
# @example
|
194
|
+
# cards = ZombieBattleground::Api.cards_by_faction("WATER")
|
195
|
+
# # => [ZombieBattleground::Api::Models::Card]
|
196
|
+
#
|
197
|
+
# @api public
|
198
|
+
def cards_by_faction(faction)
|
199
|
+
all_cards(set: faction).to_a
|
200
|
+
end
|
201
|
+
|
170
202
|
##
|
171
203
|
# Fetches all cards with selected type
|
172
204
|
#
|
@@ -175,11 +207,11 @@ module ZombieBattleground
|
|
175
207
|
# @return [Array<ZombieBattleground::Api::Models::Card>]
|
176
208
|
#
|
177
209
|
# @example
|
178
|
-
# cards = ZombieBattleground::Api.cards_by_type(
|
210
|
+
# cards = ZombieBattleground::Api.cards_by_type("WALKER")
|
179
211
|
# # => [ZombieBattleground::Api::Models::Card]
|
180
212
|
#
|
181
213
|
# @api public
|
182
|
-
def cards_by_type(type
|
214
|
+
def cards_by_type(type)
|
183
215
|
all_cards(type: type).to_a
|
184
216
|
end
|
185
217
|
|
@@ -191,13 +223,25 @@ module ZombieBattleground
|
|
191
223
|
# @return [Array<ZombieBattleground::Api::Models::Card>]
|
192
224
|
#
|
193
225
|
# @example
|
194
|
-
# cards = ZombieBattleground::Api.cards_by_rarity(
|
226
|
+
# cards = ZombieBattleground::Api.cards_by_rarity("")
|
195
227
|
# # => [ZombieBattleground::Api::Models::Card]
|
196
228
|
#
|
197
229
|
# @api public
|
198
|
-
def cards_by_rarity(rarity
|
230
|
+
def cards_by_rarity(rarity)
|
199
231
|
all_cards(rarity: rarity).to_a
|
200
232
|
end
|
233
|
+
|
234
|
+
private
|
235
|
+
|
236
|
+
##
|
237
|
+
# Loads the helper data for cards
|
238
|
+
#
|
239
|
+
# @return [Hash]
|
240
|
+
#
|
241
|
+
# @api private
|
242
|
+
def load_cards_data
|
243
|
+
@load_cards_data ||= YAML.safe_load(File.read(File.join(__dir__, 'cards.yml')))
|
244
|
+
end
|
201
245
|
end
|
202
246
|
end
|
203
247
|
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
---
|
2
|
+
|
3
|
+
# API doesn't provide an endpoint for enumerating card metadata
|
4
|
+
|
5
|
+
# https://zombiebattleground.io/index.php/Type
|
6
|
+
types:
|
7
|
+
- 'WALKER' # standard
|
8
|
+
- 'FERAL' # haste
|
9
|
+
- 'HEAVY' # taunt
|
10
|
+
|
11
|
+
# Didn't find docs for these yet, duplicating what API is serving now
|
12
|
+
kinds:
|
13
|
+
- 'CREATURE'
|
14
|
+
- 'SPELL'
|
15
|
+
|
16
|
+
# https://zombiebattleground.io/index.php/Rank
|
17
|
+
# implies rarity for creature cards
|
18
|
+
ranks:
|
19
|
+
- 'MINION'
|
20
|
+
- 'OFFICER'
|
21
|
+
- 'GENERAL'
|
22
|
+
- 'COMMANDER'
|
23
|
+
|
24
|
+
# Didn't find docs for these yet, duplicating what API is serving now
|
25
|
+
sets:
|
26
|
+
- 'AIR'
|
27
|
+
- 'EARTH'
|
28
|
+
- 'FIRE'
|
29
|
+
- 'LIFE'
|
30
|
+
- 'TOXIC'
|
31
|
+
- 'WATER'
|
32
|
+
- 'ITEM'
|
33
|
+
- 'OTHERS'
|
34
|
+
|
35
|
+
# https://zombiebattleground.io/index.php/Faction
|
36
|
+
# factions are a subset of sets
|
37
|
+
factions:
|
38
|
+
- 'AIR'
|
39
|
+
- 'EARTH'
|
40
|
+
- 'FIRE'
|
41
|
+
- 'LIFE'
|
42
|
+
- 'TOXIC'
|
43
|
+
- 'WATER'
|
44
|
+
|
45
|
+
# https://zombiebattleground.io/index.php/File:Card_description.png
|
46
|
+
# https://zombiebattleground.io/index.php/Rarity
|
47
|
+
# This one is strange, API returns empty strings right now
|
48
|
+
rarities:
|
49
|
+
- ''
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'active_record'
|
4
4
|
|
5
|
+
require 'zombie_battleground/api/constants'
|
5
6
|
require 'zombie_battleground/api/validation_helper'
|
6
7
|
require 'zombie_battleground/api/models/simple_card'
|
7
8
|
|
@@ -245,7 +246,23 @@ module ZombieBattleground
|
|
245
246
|
card.errors.size.zero?
|
246
247
|
|
247
248
|
errors.add(:cards, 'cards must be an array of SimpleCard')
|
249
|
+
break
|
248
250
|
end
|
251
|
+
|
252
|
+
cards_has_required_count
|
253
|
+
end
|
254
|
+
|
255
|
+
##
|
256
|
+
# Validator for correct number of cards in deck
|
257
|
+
#
|
258
|
+
# @return [void]
|
259
|
+
#
|
260
|
+
# @api private
|
261
|
+
def cards_has_required_count
|
262
|
+
return if errors.messages.size.zero? &&
|
263
|
+
cards.sum(&:amount) == DECK_REQUIRED_CARDS_COUNT
|
264
|
+
|
265
|
+
errors.add(:cards, 'cards must add up to 30')
|
249
266
|
end
|
250
267
|
end
|
251
268
|
end
|
@@ -65,6 +65,18 @@ module ZombieBattleground
|
|
65
65
|
# @api public
|
66
66
|
attr_reader :cards
|
67
67
|
|
68
|
+
##
|
69
|
+
# @!attribute [a] remove_invalid
|
70
|
+
# flag to remove objects in response that are invalid during validation
|
71
|
+
#
|
72
|
+
# @return [Boolean]
|
73
|
+
#
|
74
|
+
# @example
|
75
|
+
# response.remove_invalid = true
|
76
|
+
#
|
77
|
+
# @api public
|
78
|
+
attr_accessor :remove_invalid
|
79
|
+
|
68
80
|
validate :total_is_a_non_negative_integer
|
69
81
|
validate :page_is_a_non_negative_integer
|
70
82
|
validate :limit_is_a_non_negative_integer
|
@@ -110,6 +122,20 @@ module ZombieBattleground
|
|
110
122
|
return
|
111
123
|
end
|
112
124
|
|
125
|
+
if remove_invalid
|
126
|
+
remove_invalid_cards
|
127
|
+
else
|
128
|
+
cards_contains_valid_cards
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
##
|
133
|
+
# Validator for cards in cards
|
134
|
+
#
|
135
|
+
# @return [void]
|
136
|
+
#
|
137
|
+
# @api private
|
138
|
+
def cards_contains_valid_cards
|
113
139
|
@cards.each do |card|
|
114
140
|
next if card.is_a?(ZombieBattleground::Api::Models::Card) &&
|
115
141
|
card.valid? &&
|
@@ -118,6 +144,20 @@ module ZombieBattleground
|
|
118
144
|
errors.add(:cards, 'cards must be an array of Card')
|
119
145
|
end
|
120
146
|
end
|
147
|
+
|
148
|
+
##
|
149
|
+
# Removes invalid vards from card
|
150
|
+
#
|
151
|
+
# @return [void]
|
152
|
+
#
|
153
|
+
# @api private
|
154
|
+
def remove_invalid_cards
|
155
|
+
@cards.select! do |card|
|
156
|
+
card.is_a?(ZombieBattleground::Api::Models::Card) &&
|
157
|
+
card.valid? &&
|
158
|
+
card.errors.size.zero?
|
159
|
+
end
|
160
|
+
end
|
121
161
|
end
|
122
162
|
end
|
123
163
|
end
|
@@ -65,6 +65,18 @@ module ZombieBattleground
|
|
65
65
|
# @api public
|
66
66
|
attr_reader :decks
|
67
67
|
|
68
|
+
##
|
69
|
+
# @!attribute [a] remove_invalid
|
70
|
+
# flag to remove objects in response that are invalid during validation
|
71
|
+
#
|
72
|
+
# @return [Boolean]
|
73
|
+
#
|
74
|
+
# @example
|
75
|
+
# response.remove_invalid = true
|
76
|
+
#
|
77
|
+
# @api public
|
78
|
+
attr_accessor :remove_invalid
|
79
|
+
|
68
80
|
validate :total_is_a_non_negative_integer
|
69
81
|
validate :page_is_a_non_negative_integer
|
70
82
|
validate :limit_is_a_non_negative_integer
|
@@ -110,6 +122,20 @@ module ZombieBattleground
|
|
110
122
|
return
|
111
123
|
end
|
112
124
|
|
125
|
+
if remove_invalid
|
126
|
+
remove_invalid_decks
|
127
|
+
else
|
128
|
+
decks_contains_valid_decks
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
##
|
133
|
+
# Validator for decks in decks
|
134
|
+
#
|
135
|
+
# @return [void]
|
136
|
+
#
|
137
|
+
# @api private
|
138
|
+
def decks_contains_valid_decks
|
113
139
|
@decks.each do |deck|
|
114
140
|
next if deck.is_a?(ZombieBattleground::Api::Models::Deck) &&
|
115
141
|
deck.valid? &&
|
@@ -118,6 +144,20 @@ module ZombieBattleground
|
|
118
144
|
errors.add(:decks, 'decks must be an array of Deck')
|
119
145
|
end
|
120
146
|
end
|
147
|
+
|
148
|
+
##
|
149
|
+
# Removes invalid vards from deck
|
150
|
+
#
|
151
|
+
# @return [void]
|
152
|
+
#
|
153
|
+
# @api private
|
154
|
+
def remove_invalid_decks
|
155
|
+
@decks.select! do |deck|
|
156
|
+
deck.is_a?(ZombieBattleground::Api::Models::Deck) &&
|
157
|
+
deck.valid? &&
|
158
|
+
deck.errors.size.zero?
|
159
|
+
end
|
160
|
+
end
|
121
161
|
end
|
122
162
|
end
|
123
163
|
end
|
@@ -65,6 +65,18 @@ module ZombieBattleground
|
|
65
65
|
# @api public
|
66
66
|
attr_reader :matches
|
67
67
|
|
68
|
+
##
|
69
|
+
# @!attribute [a] remove_invalid
|
70
|
+
# flag to remove objects in response that are invalid during validation
|
71
|
+
#
|
72
|
+
# @return [Boolean]
|
73
|
+
#
|
74
|
+
# @example
|
75
|
+
# response.remove_invalid = true
|
76
|
+
#
|
77
|
+
# @api public
|
78
|
+
attr_accessor :remove_invalid
|
79
|
+
|
68
80
|
validate :total_is_a_non_negative_integer
|
69
81
|
validate :page_is_a_non_negative_integer
|
70
82
|
validate :limit_is_a_non_negative_integer
|
@@ -110,6 +122,20 @@ module ZombieBattleground
|
|
110
122
|
return
|
111
123
|
end
|
112
124
|
|
125
|
+
if remove_invalid
|
126
|
+
remove_invalid_matches
|
127
|
+
else
|
128
|
+
matches_contains_valid_matches
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
##
|
133
|
+
# Validator for matches in matches
|
134
|
+
#
|
135
|
+
# @return [void]
|
136
|
+
#
|
137
|
+
# @api private
|
138
|
+
def matches_contains_valid_matches
|
113
139
|
@matches.each do |match|
|
114
140
|
next if match.is_a?(ZombieBattleground::Api::Models::Match) &&
|
115
141
|
match.valid? &&
|
@@ -118,6 +144,20 @@ module ZombieBattleground
|
|
118
144
|
errors.add(:matches, 'matches must be an array of Match')
|
119
145
|
end
|
120
146
|
end
|
147
|
+
|
148
|
+
##
|
149
|
+
# Removes invalid vards from match
|
150
|
+
#
|
151
|
+
# @return [void]
|
152
|
+
#
|
153
|
+
# @api private
|
154
|
+
def remove_invalid_matches
|
155
|
+
@matches.select! do |match|
|
156
|
+
match.is_a?(ZombieBattleground::Api::Models::Match) &&
|
157
|
+
match.valid? &&
|
158
|
+
match.errors.size.zero?
|
159
|
+
end
|
160
|
+
end
|
121
161
|
end
|
122
162
|
end
|
123
163
|
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.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Shields
|
@@ -247,6 +247,7 @@ files:
|
|
247
247
|
- lib/zombie_battleground/api/errors.rb
|
248
248
|
- lib/zombie_battleground/api/extensions.rb
|
249
249
|
- lib/zombie_battleground/api/extensions/cards.rb
|
250
|
+
- lib/zombie_battleground/api/extensions/cards.yml
|
250
251
|
- lib/zombie_battleground/api/models/card.rb
|
251
252
|
- lib/zombie_battleground/api/models/deck.rb
|
252
253
|
- lib/zombie_battleground/api/models/match.rb
|