From 5eb0881e1b470d33a8e02f7d877f9b225516789b Mon Sep 17 00:00:00 2001 From: Lulonaut Date: Thu, 4 Jan 2024 11:14:30 +0100 Subject: Fix bestiary migration check for newly created profiles (#986) --- .../miscfeatures/profileviewer/bestiary/BestiaryData.kt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/profileviewer/bestiary/BestiaryData.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/profileviewer/bestiary/BestiaryData.kt index 69688fcc..ef8468ac 100644 --- a/src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/profileviewer/bestiary/BestiaryData.kt +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/profileviewer/bestiary/BestiaryData.kt @@ -99,8 +99,12 @@ object BestiaryData { */ fun hasMigrated(profileInfo: JsonObject): Boolean { val bestiaryObject = profileInfo.getAsJsonObject("bestiary") ?: return false - - return (bestiaryObject.get("migration") ?: return false).asBoolean + return if (bestiaryObject.has("migration")) { + bestiaryObject.get("migration").asBoolean + } else { + // The account is new and therefore already uses the new format + true + } } /** @@ -231,7 +235,7 @@ object BestiaryData { kills } - val totalProgress = (effectiveKills/cap*100).roundToDecimals(1) + val totalProgress = (effectiveKills / cap * 100).roundToDecimals(1) var level = 0 for (requiredKills in bracketData) { @@ -253,8 +257,8 @@ object BestiaryData { var completed = 0 for (mob in mobs) { - if(mob.kills > 0) found++ - if(mob.mobLevelData.maxLevel) completed++ + if (mob.kills > 0) found++ + if (mob.mobLevelData.maxLevel) completed++ } return FamilyData(found, completed, mobs.size) -- cgit