diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Generator.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Generator.java index 919e01304..95aa2f529 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Generator.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Generator.java @@ -177,35 +177,35 @@ import java.util.LinkedHashMap; public class Generator { public enum Category { - WEAPON ( 4, MeleeWeapon.class), - WEP_T1 ( 0, MeleeWeapon.class), - WEP_T2 ( 0, MeleeWeapon.class), - WEP_T3 ( 0, MeleeWeapon.class), - WEP_T4 ( 0, MeleeWeapon.class), - WEP_T5 ( 0, MeleeWeapon.class), + WEAPON ( 2, 2, MeleeWeapon.class), + WEP_T1 ( 0, 0, MeleeWeapon.class), + WEP_T2 ( 0, 0, MeleeWeapon.class), + WEP_T3 ( 0, 0, MeleeWeapon.class), + WEP_T4 ( 0, 0, MeleeWeapon.class), + WEP_T5 ( 0, 0, MeleeWeapon.class), - ARMOR ( 3, Armor.class ), + ARMOR ( 2, 1, Armor.class ), - MISSILE ( 3, MissileWeapon.class ), - MIS_T1 ( 0, MissileWeapon.class ), - MIS_T2 ( 0, MissileWeapon.class ), - MIS_T3 ( 0, MissileWeapon.class ), - MIS_T4 ( 0, MissileWeapon.class ), - MIS_T5 ( 0, MissileWeapon.class ), + MISSILE ( 1, 2, MissileWeapon.class ), + MIS_T1 ( 0, 0, MissileWeapon.class ), + MIS_T2 ( 0, 0, MissileWeapon.class ), + MIS_T3 ( 0, 0, MissileWeapon.class ), + MIS_T4 ( 0, 0, MissileWeapon.class ), + MIS_T5 ( 0, 0, MissileWeapon.class ), - WAND ( 2, Wand.class ), - RING ( 1, Ring.class ), - ARTIFACT( 1, Artifact.class), + WAND ( 1, 1, Wand.class ), + RING ( 1, 0, Ring.class ), + ARTIFACT( 0, 1, Artifact.class), - FOOD ( 0, Food.class ), + FOOD ( 0, 0, Food.class ), - POTION ( 16, Potion.class ), - SEED ( 2, Plant.Seed.class ), + POTION ( 8, 8, Potion.class ), + SEED ( 1, 1, Plant.Seed.class ), - SCROLL ( 16, Scroll.class ), - STONE ( 2, Runestone.class), + SCROLL ( 8, 8, Scroll.class ), + STONE ( 1, 1, Runestone.class), - GOLD ( 20, Gold.class ); + GOLD ( 10, 10, Gold.class ); public Class[] classes; @@ -215,12 +215,16 @@ public class Generator { //Artifacts in particular don't reset, no duplicates! public float[] probs; public float[] defaultProbs = null; - - public float prob; + + //game has two decks of 35 items for overall category probs + //one deck has a ring and extra armor, the other has an artifact and extra thrown weapon + public float firstProb; + public float secondProb; public Class superClass; - private Category( float prob, Class superClass ) { - this.prob = prob; + private Category( float firstProb, float secondProb, Class superClass ) { + this.firstProb = firstProb; + this.secondProb = secondProb; this.superClass = superClass; } @@ -467,10 +471,12 @@ public class Generator { {0, 0, 20, 40, 40}, {0, 0, 0, 20, 80} }; - + + private static boolean usingFirstDeck = false; private static HashMap categoryProbs = new LinkedHashMap<>(); public static void fullReset() { + usingFirstDeck = Random.Int(2) == 0; generalReset(); for (Category cat : Category.values()) { reset(cat); @@ -479,7 +485,7 @@ public class Generator { public static void generalReset(){ for (Category cat : Category.values()) { - categoryProbs.put( cat, cat.prob ); + categoryProbs.put( cat, usingFirstDeck ? cat.firstProb : cat.secondProb ); } } @@ -490,6 +496,7 @@ public class Generator { public static Item random() { Category cat = Random.chances( categoryProbs ); if (cat == null){ + usingFirstDeck = !usingFirstDeck; generalReset(); cat = Random.chances( categoryProbs ); } @@ -617,10 +624,13 @@ public class Generator { return false; } + private static final String FIRST_DECK = "first_deck"; private static final String GENERAL_PROBS = "general_probs"; private static final String CATEGORY_PROBS = "_probs"; public static void storeInBundle(Bundle bundle) { + bundle.put(FIRST_DECK, usingFirstDeck); + Float[] genProbs = categoryProbs.values().toArray(new Float[0]); float[] storeProbs = new float[genProbs.length]; for (int i = 0; i < storeProbs.length; i++){ @@ -647,6 +657,8 @@ public class Generator { public static void restoreFromBundle(Bundle bundle) { fullReset(); + usingFirstDeck = bundle.getBoolean(FIRST_DECK); + if (bundle.contains(GENERAL_PROBS)){ float[] probs = bundle.getFloatArray(GENERAL_PROBS); for (int i = 0; i < probs.length; i++){