diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Statistics.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Statistics.java index 9180aef32..ef1e8346c 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Statistics.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Statistics.java @@ -24,6 +24,9 @@ package com.shatteredpixel.shatteredpixeldungeon; import com.watabou.utils.Bundle; import com.watabou.utils.SparseArray; +import java.util.Arrays; +import java.util.HashSet; + public class Statistics { public static int goldCollected; @@ -34,6 +37,8 @@ public class Statistics { public static int itemsCrafted; public static int piranhasKilled; public static int ankhsUsed; + //tracks every item type 'seen' this run (i.e. would be added to catalogs) + public static HashSet itemTypesDiscovered = new HashSet<>(); //These are used for score calculation // some are built incrementally, most are assigned when full score is calculated @@ -78,6 +83,7 @@ public class Statistics { itemsCrafted = 0; piranhasKilled = 0; ankhsUsed = 0; + itemTypesDiscovered.clear(); progressScore = 0; heldItemValue = 0; @@ -136,6 +142,8 @@ public class Statistics { private static final String SNEAKS = "sneakAttacks"; private static final String THROWN = "thrownAssists"; + private static final String ITEM_DISCOVERIES = "item_discoveries"; + private static final String SPAWNERS = "spawnersAlive"; private static final String DURATION = "duration"; @@ -157,6 +165,7 @@ public class Statistics { bundle.put( ALCHEMY, itemsCrafted ); bundle.put( PIRANHAS, piranhasKilled ); bundle.put( ANKHS, ankhsUsed ); + bundle.put( ITEM_DISCOVERIES, itemTypesDiscovered.toArray(new Class[0]) ); bundle.put( PROG_SCORE, progressScore ); bundle.put( ITEM_VAL, heldItemValue ); @@ -202,6 +211,12 @@ public class Statistics { piranhasKilled = bundle.getInt( PIRANHAS ); ankhsUsed = bundle.getInt( ANKHS ); + if (bundle.contains( ITEM_DISCOVERIES )) { + itemTypesDiscovered = new HashSet<>(Arrays.asList(bundle.getClassArray(ITEM_DISCOVERIES))); + } else { + itemTypesDiscovered.clear(); + } + progressScore = bundle.getInt( PROG_SCORE ); heldItemValue = bundle.getInt( ITEM_VAL ); treasureScore = bundle.getInt( TRES_SCORE ); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/journal/Catalog.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/journal/Catalog.java index 090fe6a0b..a919a0b4c 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/journal/Catalog.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/journal/Catalog.java @@ -22,6 +22,7 @@ package com.shatteredpixel.shatteredpixeldungeon.journal; import com.shatteredpixel.shatteredpixeldungeon.Badges; +import com.shatteredpixel.shatteredpixeldungeon.Statistics; import com.shatteredpixel.shatteredpixeldungeon.items.Amulet; import com.shatteredpixel.shatteredpixeldungeon.items.Ankh; import com.shatteredpixel.shatteredpixeldungeon.items.ArcaneResin; @@ -320,6 +321,7 @@ public enum Catalog { Journal.saveNeeded = true; } } + Statistics.itemTypesDiscovered.add(cls); Badges.validateCatalogBadges(); }