@@ -28,16 +28,16 @@ object ShipParser {
28
28
}
29
29
try {
30
30
return SkinInfo (
31
- enClient = json.optString(" EN Client " ),
32
- cnClient = json.optString(" CN Client " ),
33
- jpClient = json.optString(" JP Client " ),
34
- obtainedFrom = json.getString( " Obtained From " ),
31
+ enClient = json.optString(" enClient " ),
32
+ cnClient = json.optString(" cnClient " ),
33
+ jpClient = json.optString(" jpClient " ),
34
+ obtainedFrom = json.optString( " obtainedFrom " ),
35
35
cost = try {
36
- json.optString(" Cost " ).toInt()
36
+ json.optString(" cost " ).toInt()
37
37
} catch (e: NumberFormatException ) {
38
38
0
39
39
},
40
- isLive2D = json.getString( " Live2D Model " ) == " Yes "
40
+ isLive2D = json.getBoolean( " live2DModel " )
41
41
)
42
42
} catch (e: JSONException ) {
43
43
throw e
@@ -68,20 +68,20 @@ object ShipParser {
68
68
private fun jsonToStatsDetails (json : JSONObject ): StatsDetails {
69
69
try {
70
70
return StatsDetails (
71
- speed = json.getInt(" Speed " ),
72
- accuracy = json.getInt(" Accuracy (Hit) " ),
73
- antiAir = json.getInt(" Anti-air " ),
74
- antiSub = json.getInt(" Anti-submarine warfare " ),
75
- armor = json.getString(" Armor " ),
76
- aviation = json.getInt(" Aviation " ),
77
- evasion = json.getInt(" Evasion " ),
78
- firepower = json.getInt(" Firepower " ),
79
- health = json.getInt(" Health " ),
80
- luck = json.getInt(" Luck " ),
71
+ speed = json.getInt(" speed " ),
72
+ accuracy = json.getInt(" accuracyHit " ),
73
+ antiAir = json.getInt(" antiair " ),
74
+ antiSub = json.getInt(" antisubmarineWarfare " ),
75
+ armor = json.getString(" armor " ),
76
+ aviation = json.getInt(" aviation " ),
77
+ evasion = json.getInt(" evasion " ),
78
+ firepower = json.getInt(" firepower " ),
79
+ health = json.getInt(" health " ),
80
+ luck = json.getInt(" luck " ),
81
81
// FIXME: it should be defined
82
- oil = json.optInt(" Oil consumption " ),
83
- reload = json.getInt(" Reload " ),
84
- torpedo = json.getInt(" Torpedo " )
82
+ oil = json.optInt(" oilConsumption " ),
83
+ reload = json.getInt(" reload " ),
84
+ torpedo = json.getInt(" torpedo " )
85
85
)
86
86
} catch (e: JSONException ) {
87
87
throw e
@@ -96,17 +96,17 @@ object ShipParser {
96
96
return Stats (
97
97
level120 = jsonToStatsDetails(
98
98
json.getJSONObject(
99
- " Level 120 "
99
+ " level120 "
100
100
)
101
101
),
102
102
level100 = jsonToStatsDetails(
103
103
json.getJSONObject(
104
- " Level 100 "
104
+ " level100 "
105
105
)
106
106
),
107
107
base = jsonToStatsDetails(
108
108
json.getJSONObject(
109
- " Base Stats "
109
+ " baseStats "
110
110
)
111
111
)
112
112
)
@@ -143,6 +143,26 @@ object ShipParser {
143
143
}
144
144
}
145
145
146
+ private fun jsonToConstruction (json : JSONObject ? ): ShipConstruction ? {
147
+ if (json == null ) {
148
+ return null
149
+ }
150
+ try {
151
+ val availability = json.getJSONObject(" availableIn" )
152
+ // FIXME: not always a boolean
153
+ return ShipConstruction (
154
+ constructionTime = json.getString(" constructionTime" ),
155
+ light = availability.optBoolean(" light" , true ),
156
+ heavy = availability.optBoolean(" heavy" , true ),
157
+ aviation = availability.optBoolean(" aviation" , true ),
158
+ limited = availability.optBoolean(" limited" , true ),
159
+ exchange = availability.optBoolean(" exchange" , true )
160
+ )
161
+ } catch (e: JSONException ) {
162
+ throw e
163
+ }
164
+ }
165
+
146
166
private fun jsonToMiscellaneous (json : JSONObject ? ): Miscellaneous ? {
147
167
if (json == null ) {
148
168
return null
@@ -165,7 +185,11 @@ object ShipParser {
165
185
" twitter"
166
186
)
167
187
),
168
- voice = json.optString(" voice" )
188
+ voice = jsonToUrl(
189
+ json.optJSONObject(
190
+ " voice"
191
+ )
192
+ )
169
193
)
170
194
} catch (e: JSONException ) {
171
195
throw e
@@ -177,7 +201,6 @@ object ShipParser {
177
201
return Ship (
178
202
wikiUrl = json.getString(" wikiUrl" ),
179
203
id = json.getString(" id" ),
180
- buildTime = json.optString(" buildTime" ),
181
204
hullType = json.getString(" hullType" ),
182
205
nationality = json.getString(" nationality" ),
183
206
rarity = json.getString(" rarity" ),
@@ -203,6 +226,11 @@ object ShipParser {
203
226
" stars"
204
227
)
205
228
),
229
+ construction = jsonToConstruction(
230
+ json.optJSONObject(
231
+ " construction"
232
+ )
233
+ ),
206
234
misc = jsonToMiscellaneous(
207
235
json.optJSONObject(
208
236
" misc"
0 commit comments