Skip to content

Commit ed7aed6

Browse files
committed
fix(takao): fix parsing on ship stats
1 parent 5d0760b commit ed7aed6

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# Changelog
22

3-
## 3.1.3 (2020-18-02)
3+
## 3.1.4 (2020-07-19)
4+
5+
### Bug fixes
6+
7+
- Fix errors on ship stats parsing: optional value if it doesn't exist
8+
9+
## 3.1.3 (2020-02-18)
410

511
### Bug fixes
612

src/main/kotlin/com/github/azurapi/azurapikotlin/internal/utils/parser/ShipParser.kt

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,19 @@ private fun jsonToSkins(jsonArray: JSONArray): List<Skin> {
7474
private fun jsonToStatsDetails(json: JSONObject): StatsDetails {
7575
try {
7676
return StatsDetails(
77-
speed = json.getInt("speed"),
78-
accuracy = json.getInt("accuracy"),
79-
antiAir = json.getInt("antiair"),
80-
antiSub = json.getInt("antisubmarineWarfare"),
81-
armor = json.getString("armor"),
82-
aviation = json.getInt("aviation"),
83-
evasion = json.getInt("evasion"),
84-
firepower = json.getInt("firepower"),
85-
health = json.getInt("health"),
86-
luck = json.getInt("luck"),
87-
// FIXME: it should be defined
77+
speed = json.optInt("speed"),
78+
accuracy = json.optInt("accuracy"),
79+
antiAir = json.optInt("antiair"),
80+
antiSub = json.optInt("antisubmarineWarfare"),
81+
armor = json.optString("armor"),
82+
aviation = json.optInt("aviation"),
83+
evasion = json.optInt("evasion"),
84+
firepower = json.optInt("firepower"),
85+
health = json.optInt("health"),
86+
luck = json.optInt("luck"),
8887
oil = json.optInt("oilConsumption"),
89-
reload = json.getInt("reload"),
90-
torpedo = json.getInt("torpedo")
88+
reload = json.optInt("reload"),
89+
torpedo = json.optInt("torpedo")
9190
)
9291
} catch (e: JSONException) {
9392
throw e

0 commit comments

Comments
 (0)