v0.6.1: made storing and restore limited drops much less rigid
This commit is contained in:
parent
dd78517a3a
commit
67d39b856f
|
@ -80,7 +80,6 @@ public class Dungeon {
|
||||||
|
|
||||||
//enum of items which have limited spawns, records how many have spawned
|
//enum of items which have limited spawns, records how many have spawned
|
||||||
//could all be their own separate numbers, but this allows iterating, much nicer for bundling/initializing.
|
//could all be their own separate numbers, but this allows iterating, much nicer for bundling/initializing.
|
||||||
//TODO: this is fairly brittle when it comes to bundling, should look into a more flexible solution.
|
|
||||||
public static enum limitedDrops{
|
public static enum limitedDrops{
|
||||||
//limited world drops
|
//limited world drops
|
||||||
strengthPotions,
|
strengthPotions,
|
||||||
|
@ -117,6 +116,49 @@ public class Dungeon {
|
||||||
public void drop(){
|
public void drop(){
|
||||||
count = 1;
|
count = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void reset(){
|
||||||
|
for (limitedDrops lim : values()){
|
||||||
|
lim.count = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void store( Bundle bundle ){
|
||||||
|
for (limitedDrops lim : values()){
|
||||||
|
bundle.put(lim.name(), lim.count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void restore( Bundle bundle ){
|
||||||
|
for (limitedDrops lim : values()){
|
||||||
|
if (bundle.contains(lim.name())){
|
||||||
|
lim.count = bundle.getInt(lim.name());
|
||||||
|
} else {
|
||||||
|
lim.count = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//for saves prior to 0.6.1
|
||||||
|
public static void legacyRestore( int[] counts ){
|
||||||
|
strengthPotions.count = counts[0];
|
||||||
|
upgradeScrolls.count = counts[1];
|
||||||
|
arcaneStyli.count = counts[2];
|
||||||
|
swarmHP.count = counts[3];
|
||||||
|
batHP.count = counts[4];
|
||||||
|
warlockHP.count = counts[5];
|
||||||
|
scorpioHP.count = counts[6];
|
||||||
|
cookingHP.count = counts[7];
|
||||||
|
blandfruitSeed.count = counts[8];
|
||||||
|
armband.count = counts[9];
|
||||||
|
dewVial.count = counts[10];
|
||||||
|
seedBag.count = counts[11];
|
||||||
|
scrollBag.count = counts[12];
|
||||||
|
potionBag.count = counts[13];
|
||||||
|
wandBag.count = counts[14];
|
||||||
|
guardHP.count = counts[15];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int challenges;
|
public static int challenges;
|
||||||
|
@ -461,10 +503,9 @@ public class Dungeon {
|
||||||
|
|
||||||
quickslot.storePlaceholders( bundle );
|
quickslot.storePlaceholders( bundle );
|
||||||
|
|
||||||
int[] dropValues = new int[limitedDrops.values().length];
|
Bundle limDrops = new Bundle();
|
||||||
for (limitedDrops value : limitedDrops.values())
|
limitedDrops.store( limDrops );
|
||||||
dropValues[value.ordinal()] = value.count;
|
bundle.put ( LIMDROPS, limDrops );
|
||||||
bundle.put ( LIMDROPS, dropValues );
|
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
int ids[] = new int[chapters.size()];
|
int ids[] = new int[chapters.size()];
|
||||||
|
@ -566,10 +607,12 @@ public class Dungeon {
|
||||||
quickslot.restorePlaceholders( bundle );
|
quickslot.restorePlaceholders( bundle );
|
||||||
|
|
||||||
if (fullLoad) {
|
if (fullLoad) {
|
||||||
int[] dropValues = bundle.getIntArray(LIMDROPS);
|
|
||||||
for (limitedDrops value : limitedDrops.values())
|
if( version <= 199 ){
|
||||||
value.count = value.ordinal() < dropValues.length ?
|
limitedDrops.legacyRestore( bundle.getIntArray(LIMDROPS) );
|
||||||
dropValues[value.ordinal()] : 0;
|
} else {
|
||||||
|
limitedDrops.restore( bundle.getBundle(LIMDROPS) );
|
||||||
|
}
|
||||||
|
|
||||||
chapters = new HashSet<Integer>();
|
chapters = new HashSet<Integer>();
|
||||||
int ids[] = bundle.getIntArray( CHAPTERS );
|
int ids[] = bundle.getIntArray( CHAPTERS );
|
||||||
|
|
Loading…
Reference in New Issue
Block a user