aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoman / Linnea Gräf <roman.graef@gmail.com>2023-01-13 13:29:39 +0100
committerGitHub <noreply@github.com>2023-01-13 13:29:39 +0100
commite603cf230af0cef44481633888ec13d2097b6310 (patch)
tree9e373e1140e4678fad1fc7624243dc455efe86dc /src
parent4b3aad7142c04071961e8b4a87cb1b4759da38b7 (diff)
downloadNotEnoughUpdates-e603cf230af0cef44481633888ec13d2097b6310.tar.gz
NotEnoughUpdates-e603cf230af0cef44481633888ec13d2097b6310.tar.bz2
NotEnoughUpdates-e603cf230af0cef44481633888ec13d2097b6310.zip
PetLeveling: Allow for defining custom level offsets for pets (#534)
Diffstat (limited to 'src')
-rw-r--r--src/main/kotlin/io/github/moulberry/notenoughupdates/util/PetLeveling.kt5
-rw-r--r--src/test/kotlin/io/github/moulberry/notenoughupdates/util/PetLevelingTest.kt18
2 files changed, 22 insertions, 1 deletions
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 56f84d54..200aa3fa 100644
--- a/src/main/kotlin/io/github/moulberry/notenoughupdates/util/PetLeveling.kt
+++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/util/PetLeveling.kt
@@ -100,7 +100,7 @@ object PetLeveling {
val petConstants = this.petConstants ?: Constants.PETS ?: return stubExpLadder
var levels = petConstants["pet_levels"]?.asJsonArray?.map { it.asLong }?.toMutableList() ?: return stubExpLadder
val customLeveling = petConstants["custom_pet_leveling"]?.asJsonObject?.get(petIdWithoutRarity)
- val offset = petConstants["pet_rarity_offset"]?.asJsonObject?.get(rarity.name)?.asInt ?: return stubExpLadder
+ var rarityOffsets = petConstants["pet_rarity_offset"]?.asJsonObject
var maxLevel = 100
if (customLeveling is JsonObject) {
val customLevels by lazy { customLeveling["pet_levels"]?.asJsonArray?.map { it.asLong } }
@@ -109,7 +109,10 @@ object PetLeveling {
2 -> levels = customLevels?.toMutableList() ?: return stubExpLadder
}
maxLevel = customLeveling["max_level"]?.asInt ?: maxLevel
+ rarityOffsets = customLeveling["rarity_offset"]?.asJsonObject ?: rarityOffsets
}
+ val offset = rarityOffsets?.get(rarity.name)?.asInt ?: return stubExpLadder
+
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 d91ca09d..870b7e59 100644
--- a/src/test/kotlin/io/github/moulberry/notenoughupdates/util/PetLevelingTest.kt
+++ b/src/test/kotlin/io/github/moulberry/notenoughupdates/util/PetLevelingTest.kt
@@ -265,6 +265,16 @@ internal class PetLevelingTest {
1886700
],
"max_level": 200
+ },
+ "BINGO": {
+ "rarity_offset": {
+ "COMMON": 0,
+ "UNCOMMON": 0,
+ "RARE": 0,
+ "EPIC": 0,
+ "LEGENDARY": 0,
+ "MYTHIC": 0
+ }
}
},
"pet_types": {
@@ -357,6 +367,14 @@ internal class PetLevelingTest {
}
@Test
+ fun testBingoPetsLevelLikeCommon() {
+ val levelingC = PetLeveling.getPetLevelingForPet0("BINGO", PetInfoOverlay.Rarity.COMMON)
+ val levelingE = PetLeveling.getPetLevelingForPet0("BINGO", PetInfoOverlay.Rarity.EPIC)
+ Assertions.assertEquals(levelingC.getPetLevel(67790664.0), levelingE.getPetLevel(67790664.0))
+ }
+
+
+ @Test
fun testPetLevelGrandmaWolf() {
val leveling = PetLeveling.getPetLevelingForPet0("GRANDMA_WOLF", PetInfoOverlay.Rarity.LEGENDARY)
val level = leveling.getPetLevel(22_500_000.0)