Skip to content

Commit 2557516

Browse files
committed
Add pet leveling data
1 parent 2e215b4 commit 2557516

File tree

5 files changed

+130
-0
lines changed

5 files changed

+130
-0
lines changed

src/main/java/io/github/moulberry/repo/NEUConstants.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ public class NEUConstants implements IReloadable {
2424
Misc misc;
2525
@Getter
2626
Leveling leveling;
27+
@Getter
28+
PetLevelingData petLevelingData;
2729

2830
public void reload(NEURepository repository) throws NEURepositoryException {
2931
bonuses = repository.requireFile("constants/bonuses.json").json(Bonuses.class);
@@ -36,6 +38,7 @@ public void reload(NEURepository repository) throws NEURepositoryException {
3638
}));
3739
misc = repository.requireFile("constants/misc.json").json(Misc.class);
3840
leveling = repository.requireFile("constants/leveling.json").json(Leveling.class);
41+
petLevelingData = repository.requireFile("constants/pets.json").json(PetLevelingData.class);
3942
}
4043

4144

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package io.github.moulberry.repo.constants;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import io.github.moulberry.repo.data.Rarity;
5+
import lombok.Getter;
6+
import org.jetbrains.annotations.ApiStatus;
7+
import org.jetbrains.annotations.Nullable;
8+
9+
import java.util.List;
10+
import java.util.Map;
11+
12+
public class PetLevelingBehaviourOverride {
13+
/**
14+
* Constant multiplier for all exp gains. If not present should be treated as {@code 1.0}
15+
*/
16+
@Getter
17+
@SerializedName("xp_multiplier")
18+
@Nullable
19+
Double xpMultiplier;
20+
21+
/**
22+
* Offset the {@link PetLevelingData#getPetExpCostForLevel() pet leveling cost} by a specified amount for each rarity.
23+
* This replaces the default behaviour in {@link PetLevelingData#getPetLevelStartOffset()}.
24+
*/
25+
@Getter
26+
@SerializedName("pet_rarity_offset")
27+
Map<Rarity, Integer> petLevelStartOffset;
28+
29+
@SerializedName("type")
30+
@Getter
31+
@ApiStatus.Obsolete
32+
Integer rawLevelOverrideType;
33+
34+
/**
35+
* Override the max level of this pet.
36+
*/
37+
@SerializedName("max_level")
38+
@Getter
39+
Integer maxLevel;
40+
41+
/**
42+
* List of levels to replace or augment the default ones in {@link PetLevelingData#getPetExpCostForLevel()}
43+
*/
44+
@SerializedName("pet_levels")
45+
@Getter
46+
List<Integer> petExpCostModifier;
47+
48+
/**
49+
* Specify how {@link #getPetExpCostModifier() the pet exp cost modifier list} should be used.
50+
*/
51+
@Nullable
52+
public PetExpModifierType getPetExpCostModifierType() {
53+
if (rawLevelOverrideType == 1) return PetExpModifierType.APPEND;
54+
if (rawLevelOverrideType == 2) return PetExpModifierType.REPLACE;
55+
return null;
56+
}
57+
58+
public enum PetExpModifierType {
59+
/**
60+
* Append the data in {@link #getPetExpCostModifier()} to {@link PetLevelingData#getPetExpCostForLevel()}.
61+
*/
62+
APPEND,
63+
/**
64+
* Replace the data in {@link PetLevelingData#getPetExpCostForLevel()} with {@link #getPetExpCostModifier()}
65+
*/
66+
REPLACE,
67+
;
68+
}
69+
70+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package io.github.moulberry.repo.constants;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import io.github.moulberry.repo.data.Rarity;
5+
import io.github.moulberry.repo.util.PetId;
6+
import lombok.Getter;
7+
8+
import java.util.List;
9+
import java.util.Map;
10+
11+
@Getter
12+
public class PetLevelingData {
13+
/**
14+
* Offset the {@link #getPetExpCostForLevel() pet leveling cost} by a specified amount for each rarity.
15+
*/
16+
@SerializedName("pet_rarity_offset")
17+
Map<Rarity, Integer> petLevelStartOffset;
18+
/**
19+
* EXP needed for each individual pet level. This cost is offset by {@link #getPetLevelStartOffset() the pet level start offset} and then
20+
* capped according to
21+
*/
22+
@SerializedName("pet_levels")
23+
List<Integer> petExpCostForLevel;
24+
25+
/**
26+
* A map of pet name to overrides in the leveling behaviour.
27+
*/
28+
@SerializedName("custom_pet_leveling")
29+
Map<@PetId String, PetLevelingBehaviourOverride> petLevelingBehaviourOverrides;
30+
31+
/**
32+
* A map of pet name to the kind of exp it uses.
33+
* Uses the standard skill names, but may include {@code ALL} or might not be present for pets that
34+
* do not level up via normal means.
35+
*/
36+
@SerializedName("pet_types")
37+
Map<@PetId String, String> petExpTypes;
38+
39+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package io.github.moulberry.repo.util;
2+
3+
import java.lang.annotation.*;
4+
5+
/**
6+
* Indicates that this string is a pet id. Unlike {@link NEUId}, this pet id
7+
* does not include the {@code ;RARITY} postfix. So an {@link PetId} {@link String}
8+
* would be {@code "BEE"}, while a {@link NEUId} {@link String} would be {@code "BEE;2"}.
9+
* When applied to a method, indicates the return type is a pet id.
10+
* When applied to a parameter, field, or local variable indicated that the variable type is a pet id.
11+
*/
12+
@Documented
13+
@Target({ElementType.PARAMETER, ElementType.FIELD, ElementType.LOCAL_VARIABLE, ElementType.METHOD, ElementType.TYPE_USE})
14+
@Retention(RetentionPolicy.CLASS)
15+
public @interface PetId {
16+
}

src/test/java/TestMain.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public static void main(String[] args) throws NEURepositoryException {
2323
.filter(it -> it instanceof NEUUnknownRecipe).map(it -> (NEUUnknownRecipe) it)
2424
.map(NEUUnknownRecipe::getType)
2525
.collect(Collectors.toSet()));
26+
System.out.println("pet exp type for ROCK: " + repository.getConstants().getPetLevelingData().getPetExpTypes().get("ROCK"));
27+
System.out.println("max level of golden dragon: " + repository.getConstants().getPetLevelingData().getPetLevelingBehaviourOverrides().get("GOLDEN_DRAGON").getMaxLevel());
2628
System.out.println("amount of people with rainbow names: " + repository.getConstants().getMisc().getRainbowNames().size());
2729
System.out.println("display name for dynamic zone: " + repository.getConstants().getMisc().getAreaNames().get("dynamic"));
2830
System.out.println("max blaze minion level: " + repository.getConstants().getMisc().getMaxMinionLevel().get("BLAZE_GENERATOR"));

0 commit comments

Comments
 (0)