From f0542ebf1e3b9f654c66a6303e4849b592811355 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Wed, 19 Jun 2024 19:28:54 -0400 Subject: [PATCH] v2.5.0: added a method for recording multiple bestiary encounters --- .../shatteredpixeldungeon/journal/Bestiary.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/journal/Bestiary.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/journal/Bestiary.java index 9f364675b..ae0ba02a4 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/journal/Bestiary.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/journal/Bestiary.java @@ -305,16 +305,22 @@ public enum Bestiary { } public static void countEncounter(Class cls){ + countEncounters(cls, 1); + } + + public static void countEncounters(Class cls, int encounters){ if (classConversions.containsKey(cls)){ cls = classConversions.get(cls); } for (Bestiary cat : values()) { if (cat.encounterCount.containsKey(cls) && cat.encounterCount.get(cls) != Integer.MAX_VALUE){ - cat.encounterCount.put(cls, cat.encounterCount.get(cls)+1); + cat.encounterCount.put(cls, cat.encounterCount.get(cls)+encounters); + if (cat.encounterCount.get(cls) < -1_000_000_000){ //to catch cases of overflow + cat.encounterCount.put(cls, Integer.MAX_VALUE); + } Journal.saveNeeded = true; } } - Badges.validateCatalogBadges(); } private static final String BESTIARY_CLASSES = "bestiary_classes";