admiral_stats_parser 1.15.1 → 1.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -6
- data/lib/admiral_stats_parser/parser/tc_book_info_parser.rb +92 -0
- data/lib/admiral_stats_parser/version.rb +1 -1
- data/lib/admiral_stats_parser.rb +20 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8a532fc6d719dca51bff3ac91ee7e8bb9897ee6
|
4
|
+
data.tar.gz: 49bb96a6f5fa6ce7dc5b2ebd46a671cc5d563689
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8a5916ec9b77b552bb39096d2b2999a5b6db7c2d4e3aa4ac0e363454f94ea26e18bea92ca6a501f7e5c5a6690a79e567d1e426512435f262a03581f33c49230
|
7
|
+
data.tar.gz: d6f27c93cd393546cac9ac983f9483782af798d95be97c1e53ec73191708999b2c86571792c808f158c1360519443e9c659070cbb340a2c9f04d9b33537f8452
|
data/README.md
CHANGED
@@ -73,7 +73,9 @@ AdmiralStatsParser は、以下の API version をサポートしています。
|
|
73
73
|
| 12 | 2018-02-16 (ケッコンカッコカリの実装日) 〜 2018-04-18 |
|
74
74
|
| 13 | 2018-04-19 (第4回イベントの EO 開始日) 〜 2018-05-13 |
|
75
75
|
| 14 | 2018-05-14 (大型艦建造の実装日) 〜 2018-07-23 |
|
76
|
-
| 15 | 2018-07-24 (VERSION B のリリース日) 〜 |
|
76
|
+
| 15 | 2018-07-24 (VERSION B のリリース日) 〜 2019-05-08 |
|
77
|
+
| 16 | 2019-05-09 (三周年記念キャンペーンの開始日) 〜 2019-07-03 |
|
78
|
+
| 17 | 2019-07-04 (VERSION B REVISION 6 のリリース日 〜 |
|
77
79
|
|
78
80
|
各 API version でパースできる JSON の種類は以下の通りです。また、同じ情報でも、API version によって、含まれる情報量が異なる場合があります。その場合は Supported (1), Supported (2) のように記載して区別しています。
|
79
81
|
|
@@ -85,6 +87,7 @@ AdmiralStatsParser は、以下の API version をサポートしています。
|
|
85
87
|
| 11 | Supported (3) | Supported (4) | Supported (2) | Supported |
|
86
88
|
| 12 〜 13 | Supported (3) | Supported (4) | Supported (3) | Supported |
|
87
89
|
| 14 〜 15 | Supported (3) | Supported (4) | Supported (4) | Supported |
|
90
|
+
| 17 | Supported (3) | Supported (4) | Supported (5) | Supported |
|
88
91
|
|
89
92
|
| API version | 艦娘一覧 | 装備一覧 | イベント海域情報 |
|
90
93
|
|------------:|:-----|:-----|:-----|
|
@@ -97,14 +100,14 @@ AdmiralStatsParser は、以下の API version をサポートしています。
|
|
97
100
|
| 9 〜 11 | Supported (4) | Supported (2) | Supported (2) |
|
98
101
|
| 12 | Supported (5) | Supported (2) | Supported (2) |
|
99
102
|
| 13 | Supported (5) | Supported (2) | Supported (3) |
|
100
|
-
| 14 〜
|
103
|
+
| 14 〜 17 | Supported (6) | Supported (2) | Supported (3) |
|
101
104
|
|
102
105
|
| API version | 改装設計図一覧 | 輸送イベント海域情報 |
|
103
106
|
|------------:|:-----|:-----|
|
104
|
-
| 1 〜 6
|
105
|
-
| 7
|
106
|
-
| 8 〜 14
|
107
|
-
| 15
|
107
|
+
| 1 〜 6 | Unsupported | Unsupported |
|
108
|
+
| 7 | Supported (1) | Unsupported |
|
109
|
+
| 8 〜 14 | Supported (2) | Unsupported |
|
110
|
+
| 15 〜 17 | Supported (2) | Supported (1) |
|
108
111
|
|
109
112
|
## Development
|
110
113
|
|
@@ -54,6 +54,17 @@ class TcBookInfoParser
|
|
54
54
|
lv: Integer,
|
55
55
|
status_img: Array,
|
56
56
|
},
|
57
|
+
5 => {
|
58
|
+
book_no: Integer,
|
59
|
+
ship_class: String,
|
60
|
+
ship_type: String,
|
61
|
+
ship_name: String,
|
62
|
+
card_index_img: String,
|
63
|
+
card_list: :card_list,
|
64
|
+
variation_num: Integer,
|
65
|
+
acquire_num: Integer,
|
66
|
+
lv: Integer,
|
67
|
+
},
|
57
68
|
}
|
58
69
|
|
59
70
|
OPTIONAL_KEYS = {
|
@@ -68,6 +79,21 @@ class TcBookInfoParser
|
|
68
79
|
is_married: Array,
|
69
80
|
married_img: Array,
|
70
81
|
},
|
82
|
+
5 => {
|
83
|
+
ship_class_index: Integer,
|
84
|
+
is_married: Array,
|
85
|
+
married_img: Array,
|
86
|
+
},
|
87
|
+
}
|
88
|
+
|
89
|
+
CARD_LIST_MANDATORY_KEYS = {
|
90
|
+
5 => {
|
91
|
+
priority: Integer,
|
92
|
+
card_img_list: Array,
|
93
|
+
status_img: Array,
|
94
|
+
variation_num_in_page: Integer,
|
95
|
+
acquire_num_in_page: Integer,
|
96
|
+
},
|
71
97
|
}
|
72
98
|
|
73
99
|
def self.parse(json, api_version)
|
@@ -88,6 +114,13 @@ class TcBookInfoParser
|
|
88
114
|
raise "Mandatory key #{key} does not exist"
|
89
115
|
end
|
90
116
|
|
117
|
+
# # 有効期限の情報を格納するために、特別な処理を追加
|
118
|
+
if key_class == :card_list
|
119
|
+
result.instance_variable_set(
|
120
|
+
"@#{key.to_s}", TcBookInfoParser.parse_card_list(result, items[camel_case_key], api_version))
|
121
|
+
next
|
122
|
+
end
|
123
|
+
|
91
124
|
# 結果のクラスが合わなければエラー
|
92
125
|
unless items[camel_case_key].is_a?(key_class)
|
93
126
|
raise "Mandatory key #{key} is not class #{key_class}"
|
@@ -114,4 +147,63 @@ class TcBookInfoParser
|
|
114
147
|
|
115
148
|
results
|
116
149
|
end
|
150
|
+
|
151
|
+
def self.parse_card_list(tc_book_info, card_list, api_version)
|
152
|
+
results = []
|
153
|
+
|
154
|
+
card_list.each do |c|
|
155
|
+
result = TcBookInfoParser::CardList.new
|
156
|
+
|
157
|
+
CARD_LIST_MANDATORY_KEYS[api_version].each do |key, key_class|
|
158
|
+
# 必須のキーが含まれなければエラー
|
159
|
+
camel_case_key = key.to_s.split('_').inject([]){ |buffer,e| buffer.push(buffer.empty? ? e : e.capitalize) }.join
|
160
|
+
unless c.include?(camel_case_key)
|
161
|
+
raise "Mandatory key #{key} does not exist"
|
162
|
+
end
|
163
|
+
|
164
|
+
# 結果のクラスが合わなければエラー
|
165
|
+
unless c[camel_case_key].is_a?(key_class)
|
166
|
+
raise "Optional key #{key} is not class #{key_class}"
|
167
|
+
end
|
168
|
+
|
169
|
+
result.instance_variable_set("@#{key.to_s}", c[camel_case_key])
|
170
|
+
end
|
171
|
+
|
172
|
+
results << result
|
173
|
+
end
|
174
|
+
|
175
|
+
case results.size
|
176
|
+
when 0
|
177
|
+
# 未入手の場合
|
178
|
+
tc_book_info.card_img_list = []
|
179
|
+
tc_book_info.status_img = []
|
180
|
+
when 1
|
181
|
+
tc_book_info.card_img_list = results[0].card_img_list
|
182
|
+
tc_book_info.status_img = results[0].status_img
|
183
|
+
else
|
184
|
+
raise "Number of entry in card_list is #{results.size}"
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
class CardList
|
189
|
+
# 不明
|
190
|
+
# いまは配列中の要素が1個しかないが、これが2個以上になったときに意味が出てくる?
|
191
|
+
attr_accessor :priority
|
192
|
+
|
193
|
+
# 取得済み画像のファイル名
|
194
|
+
# Array
|
195
|
+
# 未取得の場合は、空の Array
|
196
|
+
attr_accessor :card_img_list
|
197
|
+
|
198
|
+
# 艦娘のステータス画像(横長の画像)のファイル名 (From API version 2)
|
199
|
+
# Array
|
200
|
+
# 未取得の場合は、空の Array
|
201
|
+
attr_accessor :status_img
|
202
|
+
|
203
|
+
# 不明
|
204
|
+
attr_accessor :variation_num_in_page
|
205
|
+
|
206
|
+
# 不明
|
207
|
+
attr_accessor :acquire_num_in_page
|
208
|
+
end
|
117
209
|
end
|
data/lib/admiral_stats_parser.rb
CHANGED
@@ -13,7 +13,7 @@ require 'admiral_stats_parser/parser/cop_info_parser'
|
|
13
13
|
module AdmiralStatsParser
|
14
14
|
# 最新の API バージョンを返します。
|
15
15
|
def self.get_latest_api_version
|
16
|
-
return
|
16
|
+
return 17
|
17
17
|
end
|
18
18
|
|
19
19
|
# エクスポート時刻を元に、API バージョンを推測して返します。
|
@@ -60,6 +60,12 @@ module AdmiralStatsParser
|
|
60
60
|
# version 15 の開始日
|
61
61
|
return 14 if exported_at < Time.parse('2018-07-24T07:00:00+0900')
|
62
62
|
|
63
|
+
# version 16 の開始日
|
64
|
+
return 15 if exported_at < Time.parse('2019-05-09T07:00:00+0900')
|
65
|
+
|
66
|
+
# version 17 の開始日
|
67
|
+
return 16 if exported_at < Time.parse('2019-07-04T07:00:00+0900')
|
68
|
+
|
63
69
|
return self.get_latest_api_version
|
64
70
|
end
|
65
71
|
|
@@ -70,7 +76,7 @@ module AdmiralStatsParser
|
|
70
76
|
PersonalBasicInfoParser.parse(json, 1)
|
71
77
|
when 2..6
|
72
78
|
PersonalBasicInfoParser.parse(json, 2)
|
73
|
-
when 7..
|
79
|
+
when 7..17
|
74
80
|
PersonalBasicInfoParser.parse(json, 3)
|
75
81
|
else
|
76
82
|
raise 'unsupported API version'
|
@@ -86,7 +92,7 @@ module AdmiralStatsParser
|
|
86
92
|
AreaCaptureInfoParser.parse(json, 2)
|
87
93
|
when 7..10
|
88
94
|
AreaCaptureInfoParser.parse(json, 3)
|
89
|
-
when 11..
|
95
|
+
when 11..17
|
90
96
|
AreaCaptureInfoParser.parse(json, 4)
|
91
97
|
else
|
92
98
|
raise 'unsupported API version'
|
@@ -102,8 +108,10 @@ module AdmiralStatsParser
|
|
102
108
|
TcBookInfoParser.parse(json, 2)
|
103
109
|
when 12..13
|
104
110
|
TcBookInfoParser.parse(json, 3)
|
105
|
-
when 14..
|
111
|
+
when 14..16
|
106
112
|
TcBookInfoParser.parse(json, 4)
|
113
|
+
when 17
|
114
|
+
TcBookInfoParser.parse(json, 5)
|
107
115
|
else
|
108
116
|
raise 'unsupported API version'
|
109
117
|
end
|
@@ -112,7 +120,7 @@ module AdmiralStatsParser
|
|
112
120
|
# 装備図鑑をパースします。
|
113
121
|
def self.parse_equip_book_info(json, api_version)
|
114
122
|
case api_version
|
115
|
-
when 1..
|
123
|
+
when 1..17
|
116
124
|
EquipBookInfoParser.parse(json)
|
117
125
|
else
|
118
126
|
raise 'unsupported API version'
|
@@ -134,7 +142,7 @@ module AdmiralStatsParser
|
|
134
142
|
CharacterListInfoParser.parse(json, 4)
|
135
143
|
when 12..13
|
136
144
|
CharacterListInfoParser.parse(json, 5)
|
137
|
-
when 14..
|
145
|
+
when 14..17
|
138
146
|
CharacterListInfoParser.parse(json, 6)
|
139
147
|
else
|
140
148
|
raise 'unsupported API version'
|
@@ -148,7 +156,7 @@ module AdmiralStatsParser
|
|
148
156
|
raise 'API version 1 does not support equip list info'
|
149
157
|
when 2..8
|
150
158
|
EquipListInfoParser.parse(json, 1)
|
151
|
-
when 9..
|
159
|
+
when 9..17
|
152
160
|
EquipListInfoParser.parse(json, 2)
|
153
161
|
else
|
154
162
|
raise 'unsupported API version'
|
@@ -160,7 +168,7 @@ module AdmiralStatsParser
|
|
160
168
|
case api_version
|
161
169
|
when 1..8
|
162
170
|
EquipListInfoParser.parse_max_slot_num(json, 1)
|
163
|
-
when 9..
|
171
|
+
when 9..17
|
164
172
|
EquipListInfoParser.parse_max_slot_num(json, 2)
|
165
173
|
else
|
166
174
|
raise 'unsupported API version'
|
@@ -176,7 +184,7 @@ module AdmiralStatsParser
|
|
176
184
|
EventInfoParser.parse(json, 1)
|
177
185
|
when 7..12
|
178
186
|
EventInfoParser.parse(json, 2)
|
179
|
-
when 13..
|
187
|
+
when 13..17
|
180
188
|
EventInfoParser.parse(json, 3)
|
181
189
|
else
|
182
190
|
raise 'unsupported API version'
|
@@ -188,7 +196,7 @@ module AdmiralStatsParser
|
|
188
196
|
case api_version
|
189
197
|
when 1..3
|
190
198
|
raise "API version #{api_version} does not support event info"
|
191
|
-
when 4..
|
199
|
+
when 4..17
|
192
200
|
{
|
193
201
|
opened: EventInfoParser.opened?(event_info_list, level, period),
|
194
202
|
all_cleared: EventInfoParser.all_cleared?(event_info_list, level, period),
|
@@ -209,7 +217,7 @@ module AdmiralStatsParser
|
|
209
217
|
raise "API version #{api_version} does not support blueprint list info"
|
210
218
|
when 7
|
211
219
|
BlueprintListInfoParser.parse(json, 1)
|
212
|
-
when 8..
|
220
|
+
when 8..17
|
213
221
|
BlueprintListInfoParser.parse(json, 2)
|
214
222
|
else
|
215
223
|
raise 'unsupported API version'
|
@@ -221,7 +229,7 @@ module AdmiralStatsParser
|
|
221
229
|
case api_version
|
222
230
|
when 1..14
|
223
231
|
raise "API version #{api_version} does not support cop info"
|
224
|
-
when 15
|
232
|
+
when 15..17
|
225
233
|
CopInfoParser.parse(json, 1)
|
226
234
|
else
|
227
235
|
raise 'unsupported API version'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: admiral_stats_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.17.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masahiro Yoshizawa
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|