v0.8.2: Fixed generator reset incorrectly clearing all category decks
This commit is contained in:
parent
2478e18ba6
commit
0b568f5a58
|
@ -212,7 +212,7 @@ public class Dungeon {
|
|||
Blacksmith.Quest.reset();
|
||||
Imp.Quest.reset();
|
||||
|
||||
Generator.reset();
|
||||
Generator.fullReset();
|
||||
hero = new Hero();
|
||||
hero.live();
|
||||
|
||||
|
|
|
@ -173,7 +173,7 @@ public enum Rankings {
|
|||
Actor.clear();
|
||||
Dungeon.hero = null;
|
||||
Dungeon.level = null;
|
||||
Generator.reset();
|
||||
Generator.fullReset();
|
||||
Notes.reset();
|
||||
Dungeon.quickslot.reset();
|
||||
QuickSlotButton.reset();
|
||||
|
|
|
@ -470,22 +470,28 @@ public class Generator {
|
|||
};
|
||||
|
||||
private static HashMap<Category,Float> categoryProbs = new LinkedHashMap<>();
|
||||
|
||||
public static void reset() {
|
||||
|
||||
public static void fullReset() {
|
||||
generalReset();
|
||||
for (Category cat : Category.values()) {
|
||||
reset(cat);
|
||||
}
|
||||
}
|
||||
|
||||
public static void generalReset(){
|
||||
for (Category cat : Category.values()) {
|
||||
categoryProbs.put( cat, cat.prob );
|
||||
if (cat.defaultProbs != null) cat.probs = cat.defaultProbs.clone();
|
||||
}
|
||||
}
|
||||
|
||||
public static void reset(Category cat){
|
||||
cat.probs = cat.defaultProbs.clone();
|
||||
if (cat.defaultProbs != null) cat.probs = cat.defaultProbs.clone();
|
||||
}
|
||||
|
||||
public static Item random() {
|
||||
Category cat = Random.chances( categoryProbs );
|
||||
if (cat == null){
|
||||
reset();
|
||||
generalReset();
|
||||
cat = Random.chances( categoryProbs );
|
||||
}
|
||||
categoryProbs.put( cat, categoryProbs.get( cat ) - 1);
|
||||
|
@ -640,7 +646,7 @@ public class Generator {
|
|||
}
|
||||
|
||||
public static void restoreFromBundle(Bundle bundle) {
|
||||
reset();
|
||||
fullReset();
|
||||
|
||||
if (bundle.contains(GENERAL_PROBS)){
|
||||
float[] probs = bundle.getFloatArray(GENERAL_PROBS);
|
||||
|
|
Loading…
Reference in New Issue
Block a user