From 4a1ee6ae56b5f5b9cab8ad61ef6b26f4aceec694 Mon Sep 17 00:00:00 2001 From: nea Date: Mon, 19 Dec 2022 19:05:20 +0100 Subject: PetLeveling: Fix non legendary pets being able to be leveled above 100 Also adds tests for this --- .../moulberry/notenoughupdates/util/PetLeveling.kt | 2 +- .../notenoughupdates/util/PetLevelingTest.kt | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/util/PetLeveling.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/util/PetLeveling.kt index e7d29642..0a9e37b9 100644 --- a/src/main/kotlin/io/github/moulberry/notenoughupdates/util/PetLeveling.kt +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/util/PetLeveling.kt @@ -105,7 +105,7 @@ object PetLeveling { } maxLevel = customLeveling["max_level"]?.asInt ?: maxLevel } - return ExpLadder(levels.drop(offset).take(maxLevel)) + return ExpLadder(levels.drop(offset).take(maxLevel - 1)) } } diff --git a/src/test/kotlin/io/github/moulberry/notenoughupdates/util/PetLevelingTest.kt b/src/test/kotlin/io/github/moulberry/notenoughupdates/util/PetLevelingTest.kt index 43a0e3fd..d91ca09d 100644 --- a/src/test/kotlin/io/github/moulberry/notenoughupdates/util/PetLevelingTest.kt +++ b/src/test/kotlin/io/github/moulberry/notenoughupdates/util/PetLevelingTest.kt @@ -337,6 +337,25 @@ internal class PetLevelingTest { PetLeveling.petConstants = testJson } + + @Test + fun testMaxedLevel200Pet() { + val leveling = PetLeveling.getPetLevelingForPet0("GOLDEN_DRAGON", PetInfoOverlay.Rarity.LEGENDARY) + Assertions.assertEquals(200, leveling.cumulativeLevelCost.size) + val level = leveling.getPetLevel(219451664.0) + Assertions.assertEquals(200, level.maxLevel) + Assertions.assertEquals(200, level.currentLevel) + } + + @Test + fun testNonLegendaryMaxLevelPet() { + val leveling = PetLeveling.getPetLevelingForPet0("GUARDIAN", PetInfoOverlay.Rarity.EPIC) + Assertions.assertEquals(100, leveling.cumulativeLevelCost.size) + val level = leveling.getPetLevel(67790664.0) + Assertions.assertEquals(100, level.currentLevel) + Assertions.assertEquals(100, level.maxLevel) + } + @Test fun testPetLevelGrandmaWolf() { val leveling = PetLeveling.getPetLevelingForPet0("GRANDMA_WOLF", PetInfoOverlay.Rarity.LEGENDARY) -- cgit