v0.6.1: refactoring to limited drops now that they are more flexible
This commit is contained in:
parent
67d39b856f
commit
92349dfbb1
|
@ -80,32 +80,32 @@ 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.
|
||||||
public static enum limitedDrops{
|
public static enum LimitedDrops {
|
||||||
//limited world drops
|
//limited world drops
|
||||||
strengthPotions,
|
STRENGTH_POTIONS,
|
||||||
upgradeScrolls,
|
UPGRADE_SCROLLS,
|
||||||
arcaneStyli,
|
ARCANE_STYLI,
|
||||||
|
|
||||||
//all unlimited health potion sources (except guards, which are at the bottom.
|
//Health potion sources
|
||||||
swarmHP,
|
//enemies
|
||||||
batHP,
|
SWARM_HP,
|
||||||
warlockHP,
|
GUARD_HP,
|
||||||
scorpioHP,
|
BAT_HP,
|
||||||
cookingHP,
|
WARLOCK_HP,
|
||||||
//blandfruit, which can technically be an unlimited health potion source
|
SCORPIO_HP,
|
||||||
blandfruitSeed,
|
//alchemy
|
||||||
|
COOKING_HP,
|
||||||
|
BLANDFRUIT_SEED,
|
||||||
|
|
||||||
//doesn't use Generator, so we have to enforce one armband drop here
|
//doesn't use Generator, so we have to enforce one armband drop here
|
||||||
armband,
|
THIEVES_ARMBAND,
|
||||||
|
|
||||||
//containers
|
//containers
|
||||||
dewVial,
|
DEW_VIAL,
|
||||||
seedBag,
|
SEED_POUCH,
|
||||||
scrollBag,
|
SCROLL_HOLDER,
|
||||||
potionBag,
|
POTION_BANDOLIER,
|
||||||
wandBag,
|
WAND_HOLSTER;
|
||||||
|
|
||||||
guardHP;
|
|
||||||
|
|
||||||
public int count = 0;
|
public int count = 0;
|
||||||
|
|
||||||
|
@ -118,19 +118,19 @@ public class Dungeon {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void reset(){
|
public static void reset(){
|
||||||
for (limitedDrops lim : values()){
|
for (LimitedDrops lim : values()){
|
||||||
lim.count = 0;
|
lim.count = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void store( Bundle bundle ){
|
public static void store( Bundle bundle ){
|
||||||
for (limitedDrops lim : values()){
|
for (LimitedDrops lim : values()){
|
||||||
bundle.put(lim.name(), lim.count);
|
bundle.put(lim.name(), lim.count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void restore( Bundle bundle ){
|
public static void restore( Bundle bundle ){
|
||||||
for (limitedDrops lim : values()){
|
for (LimitedDrops lim : values()){
|
||||||
if (bundle.contains(lim.name())){
|
if (bundle.contains(lim.name())){
|
||||||
lim.count = bundle.getInt(lim.name());
|
lim.count = bundle.getInt(lim.name());
|
||||||
} else {
|
} else {
|
||||||
|
@ -141,22 +141,22 @@ public class Dungeon {
|
||||||
|
|
||||||
//for saves prior to 0.6.1
|
//for saves prior to 0.6.1
|
||||||
public static void legacyRestore( int[] counts ){
|
public static void legacyRestore( int[] counts ){
|
||||||
strengthPotions.count = counts[0];
|
STRENGTH_POTIONS.count = counts[0];
|
||||||
upgradeScrolls.count = counts[1];
|
UPGRADE_SCROLLS.count = counts[1];
|
||||||
arcaneStyli.count = counts[2];
|
ARCANE_STYLI.count = counts[2];
|
||||||
swarmHP.count = counts[3];
|
SWARM_HP.count = counts[3];
|
||||||
batHP.count = counts[4];
|
BAT_HP.count = counts[4];
|
||||||
warlockHP.count = counts[5];
|
WARLOCK_HP.count = counts[5];
|
||||||
scorpioHP.count = counts[6];
|
SCORPIO_HP.count = counts[6];
|
||||||
cookingHP.count = counts[7];
|
COOKING_HP.count = counts[7];
|
||||||
blandfruitSeed.count = counts[8];
|
BLANDFRUIT_SEED.count = counts[8];
|
||||||
armband.count = counts[9];
|
THIEVES_ARMBAND.count = counts[9];
|
||||||
dewVial.count = counts[10];
|
DEW_VIAL.count = counts[10];
|
||||||
seedBag.count = counts[11];
|
SEED_POUCH.count = counts[11];
|
||||||
scrollBag.count = counts[12];
|
SCROLL_HOLDER.count = counts[12];
|
||||||
potionBag.count = counts[13];
|
POTION_BANDOLIER.count = counts[13];
|
||||||
wandBag.count = counts[14];
|
WAND_HOLSTER.count = counts[14];
|
||||||
guardHP.count = counts[15];
|
GUARD_HP.count = counts[15];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -213,7 +213,7 @@ public class Dungeon {
|
||||||
|
|
||||||
droppedItems = new SparseArray<ArrayList<Item>>();
|
droppedItems = new SparseArray<ArrayList<Item>>();
|
||||||
|
|
||||||
for (limitedDrops a : limitedDrops.values())
|
for (LimitedDrops a : LimitedDrops.values())
|
||||||
a.count = 0;
|
a.count = 0;
|
||||||
|
|
||||||
chapters = new HashSet<Integer>();
|
chapters = new HashSet<Integer>();
|
||||||
|
@ -398,7 +398,7 @@ public class Dungeon {
|
||||||
|
|
||||||
public static boolean posNeeded() {
|
public static boolean posNeeded() {
|
||||||
//2 POS each floor set
|
//2 POS each floor set
|
||||||
int posLeftThisSet = 2 - (limitedDrops.strengthPotions.count - (depth / 5) * 2);
|
int posLeftThisSet = 2 - (LimitedDrops.STRENGTH_POTIONS.count - (depth / 5) * 2);
|
||||||
if (posLeftThisSet <= 0) return false;
|
if (posLeftThisSet <= 0) return false;
|
||||||
|
|
||||||
int floorThisSet = (depth % 5);
|
int floorThisSet = (depth % 5);
|
||||||
|
@ -414,7 +414,7 @@ public class Dungeon {
|
||||||
|
|
||||||
public static boolean souNeeded() {
|
public static boolean souNeeded() {
|
||||||
//3 SOU each floor set
|
//3 SOU each floor set
|
||||||
int souLeftThisSet = 3 - (limitedDrops.upgradeScrolls.count - (depth / 5) * 3);
|
int souLeftThisSet = 3 - (LimitedDrops.UPGRADE_SCROLLS.count - (depth / 5) * 3);
|
||||||
if (souLeftThisSet <= 0) return false;
|
if (souLeftThisSet <= 0) return false;
|
||||||
|
|
||||||
int floorThisSet = (depth % 5);
|
int floorThisSet = (depth % 5);
|
||||||
|
@ -424,7 +424,7 @@ public class Dungeon {
|
||||||
|
|
||||||
public static boolean asNeeded() {
|
public static boolean asNeeded() {
|
||||||
//1 AS each floor set
|
//1 AS each floor set
|
||||||
int asLeftThisSet = 1 - (limitedDrops.arcaneStyli.count - (depth / 5));
|
int asLeftThisSet = 1 - (LimitedDrops.ARCANE_STYLI.count - (depth / 5));
|
||||||
if (asLeftThisSet <= 0) return false;
|
if (asLeftThisSet <= 0) return false;
|
||||||
|
|
||||||
int floorThisSet = (depth % 5);
|
int floorThisSet = (depth % 5);
|
||||||
|
@ -453,8 +453,6 @@ public class Dungeon {
|
||||||
private static final String DROPPED = "dropped%d";
|
private static final String DROPPED = "dropped%d";
|
||||||
private static final String LEVEL = "level";
|
private static final String LEVEL = "level";
|
||||||
private static final String LIMDROPS = "limiteddrops";
|
private static final String LIMDROPS = "limiteddrops";
|
||||||
private static final String DV = "dewVial";
|
|
||||||
private static final String WT = "transmutation";
|
|
||||||
private static final String CHAPTERS = "chapters";
|
private static final String CHAPTERS = "chapters";
|
||||||
private static final String QUESTS = "quests";
|
private static final String QUESTS = "quests";
|
||||||
private static final String BADGES = "badges";
|
private static final String BADGES = "badges";
|
||||||
|
@ -504,7 +502,7 @@ public class Dungeon {
|
||||||
quickslot.storePlaceholders( bundle );
|
quickslot.storePlaceholders( bundle );
|
||||||
|
|
||||||
Bundle limDrops = new Bundle();
|
Bundle limDrops = new Bundle();
|
||||||
limitedDrops.store( limDrops );
|
LimitedDrops.store( limDrops );
|
||||||
bundle.put ( LIMDROPS, limDrops );
|
bundle.put ( LIMDROPS, limDrops );
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
@ -609,9 +607,9 @@ public class Dungeon {
|
||||||
if (fullLoad) {
|
if (fullLoad) {
|
||||||
|
|
||||||
if( version <= 199 ){
|
if( version <= 199 ){
|
||||||
limitedDrops.legacyRestore( bundle.getIntArray(LIMDROPS) );
|
LimitedDrops.legacyRestore( bundle.getIntArray(LIMDROPS) );
|
||||||
} else {
|
} else {
|
||||||
limitedDrops.restore( bundle.getBundle(LIMDROPS) );
|
LimitedDrops.restore( bundle.getBundle(LIMDROPS) );
|
||||||
}
|
}
|
||||||
|
|
||||||
chapters = new HashSet<Integer>();
|
chapters = new HashSet<Integer>();
|
||||||
|
|
|
@ -81,13 +81,13 @@ public class Bat extends Mob {
|
||||||
@Override
|
@Override
|
||||||
public void die( Object cause ){
|
public void die( Object cause ){
|
||||||
//sets drop chance
|
//sets drop chance
|
||||||
lootChance = 1f/((6 + Dungeon.limitedDrops.batHP.count ));
|
lootChance = 1f/((6 + Dungeon.LimitedDrops.BAT_HP.count ));
|
||||||
super.die( cause );
|
super.die( cause );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Item createLoot(){
|
protected Item createLoot(){
|
||||||
Dungeon.limitedDrops.batHP.count++;
|
Dungeon.LimitedDrops.BAT_HP.count++;
|
||||||
return super.createLoot();
|
return super.createLoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -156,8 +156,8 @@ public class Guard extends Mob {
|
||||||
//otherwise, we may drop a health potion. overall chance is 7/(8 * (7 + potions dropped))
|
//otherwise, we may drop a health potion. overall chance is 7/(8 * (7 + potions dropped))
|
||||||
//with 0 potions dropped that simplifies to 1/8
|
//with 0 potions dropped that simplifies to 1/8
|
||||||
} else {
|
} else {
|
||||||
if (Random.Int(7 + Dungeon.limitedDrops.guardHP.count) < 7){
|
if (Random.Int(7 + Dungeon.LimitedDrops.GUARD_HP.count) < 7){
|
||||||
Dungeon.limitedDrops.guardHP.drop();
|
Dungeon.LimitedDrops.GUARD_HP.drop();
|
||||||
return new PotionOfHealing();
|
return new PotionOfHealing();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,8 +97,8 @@ public class Scorpio extends Mob {
|
||||||
@Override
|
@Override
|
||||||
protected Item createLoot() {
|
protected Item createLoot() {
|
||||||
//5/count+5 total chance of getting healing, failing the 2nd roll drops mystery meat instead.
|
//5/count+5 total chance of getting healing, failing the 2nd roll drops mystery meat instead.
|
||||||
if (Random.Int( 5 + Dungeon.limitedDrops.scorpioHP.count ) <= 4) {
|
if (Random.Int( 5 + Dungeon.LimitedDrops.SCORPIO_HP.count ) < 5) {
|
||||||
Dungeon.limitedDrops.scorpioHP.count++;
|
Dungeon.LimitedDrops.SCORPIO_HP.count++;
|
||||||
return (Item)loot;
|
return (Item)loot;
|
||||||
} else {
|
} else {
|
||||||
return new MysteryMeat();
|
return new MysteryMeat();
|
||||||
|
|
|
@ -141,13 +141,13 @@ public class Swarm extends Mob {
|
||||||
@Override
|
@Override
|
||||||
public void die( Object cause ){
|
public void die( Object cause ){
|
||||||
//sets drop chance
|
//sets drop chance
|
||||||
lootChance = 1f/((6 + 2*Dungeon.limitedDrops.swarmHP.count ) * (generation+1) );
|
lootChance = 1f/((6 + 2* Dungeon.LimitedDrops.SWARM_HP.count ) * (generation+1) );
|
||||||
super.die( cause );
|
super.die( cause );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Item createLoot(){
|
protected Item createLoot(){
|
||||||
Dungeon.limitedDrops.swarmHP.count++;
|
Dungeon.LimitedDrops.SWARM_HP.count++;
|
||||||
return super.createLoot();
|
return super.createLoot();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,8 +105,8 @@ public class Thief extends Mob {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Item createLoot(){
|
protected Item createLoot(){
|
||||||
if (!Dungeon.limitedDrops.armband.dropped()) {
|
if (!Dungeon.LimitedDrops.THIEVES_ARMBAND.dropped()) {
|
||||||
Dungeon.limitedDrops.armband.drop();
|
Dungeon.LimitedDrops.THIEVES_ARMBAND.drop();
|
||||||
return new MasterThievesArmband().identify();
|
return new MasterThievesArmband().identify();
|
||||||
} else
|
} else
|
||||||
return new Gold(Random.NormalIntRange(100, 250));
|
return new Gold(Random.NormalIntRange(100, 250));
|
||||||
|
|
|
@ -135,10 +135,10 @@ public class Warlock extends Mob implements Callback {
|
||||||
if (loot instanceof PotionOfHealing){
|
if (loot instanceof PotionOfHealing){
|
||||||
|
|
||||||
//count/10 chance of not dropping potion
|
//count/10 chance of not dropping potion
|
||||||
if (Random.Int(10)-Dungeon.limitedDrops.warlockHP.count < 0){
|
if ((Random.Int(10) - Dungeon.LimitedDrops.WARLOCK_HP.count) < 0){
|
||||||
return null;
|
return null;
|
||||||
} else
|
} else
|
||||||
Dungeon.limitedDrops.warlockHP.count++;
|
Dungeon.LimitedDrops.WARLOCK_HP.count++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -443,11 +443,14 @@ public class Heap implements Bundlable {
|
||||||
if (Random.Int(1000/bonus) == 0)
|
if (Random.Int(1000/bonus) == 0)
|
||||||
return new PotionOfExperience();
|
return new PotionOfExperience();
|
||||||
|
|
||||||
while (potion instanceof PotionOfHealing && Random.Int(10) < Dungeon.limitedDrops.cookingHP.count)
|
while (potion instanceof PotionOfHealing
|
||||||
potion = Generator.random( Generator.Category.POTION );
|
&& Random.Int(10) < Dungeon.LimitedDrops.COOKING_HP.count) {
|
||||||
|
potion = Generator.random(Generator.Category.POTION);
|
||||||
|
}
|
||||||
|
|
||||||
if (potion instanceof PotionOfHealing)
|
if (potion instanceof PotionOfHealing) {
|
||||||
Dungeon.limitedDrops.cookingHP.count++;
|
Dungeon.LimitedDrops.COOKING_HP.count++;
|
||||||
|
}
|
||||||
|
|
||||||
return potion;
|
return potion;
|
||||||
|
|
||||||
|
|
|
@ -130,9 +130,9 @@ public class WandOfRegrowth extends Wand {
|
||||||
Plant.Seed seed = (Plant.Seed) Generator.random(Generator.Category.SEED);
|
Plant.Seed seed = (Plant.Seed) Generator.random(Generator.Category.SEED);
|
||||||
|
|
||||||
if (seed instanceof BlandfruitBush.Seed) {
|
if (seed instanceof BlandfruitBush.Seed) {
|
||||||
if (Random.Int(15) - Dungeon.limitedDrops.blandfruitSeed.count >= 0) {
|
if (Random.Int(15) - Dungeon.LimitedDrops.BLANDFRUIT_SEED.count >= 0) {
|
||||||
floor.plant(seed, cells.next());
|
floor.plant(seed, cells.next());
|
||||||
Dungeon.limitedDrops.blandfruitSeed.count++;
|
Dungeon.LimitedDrops.BLANDFRUIT_SEED.count++;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
floor.plant(seed, cells.next());
|
floor.plant(seed, cells.next());
|
||||||
|
|
|
@ -104,9 +104,9 @@ public class SewerLevel extends RegularLevel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void createItems() {
|
protected void createItems() {
|
||||||
if (!Dungeon.limitedDrops.dewVial.dropped()) {
|
if (!Dungeon.LimitedDrops.DEW_VIAL.dropped()) {
|
||||||
addItemToSpawn( new DewVial() );
|
addItemToSpawn( new DewVial() );
|
||||||
Dungeon.limitedDrops.dewVial.drop();
|
Dungeon.LimitedDrops.DEW_VIAL.drop();
|
||||||
}
|
}
|
||||||
|
|
||||||
Ghost.Quest.spawn( this );
|
Ghost.Quest.spawn( this );
|
||||||
|
|
|
@ -69,9 +69,9 @@ public class HighGrass {
|
||||||
Item seed = Generator.random(Generator.Category.SEED);
|
Item seed = Generator.random(Generator.Category.SEED);
|
||||||
|
|
||||||
if (seed instanceof BlandfruitBush.Seed) {
|
if (seed instanceof BlandfruitBush.Seed) {
|
||||||
if (Random.Int(15) - Dungeon.limitedDrops.blandfruitSeed.count >= 0) {
|
if (Random.Int(15) - Dungeon.LimitedDrops.BLANDFRUIT_SEED.count >= 0) {
|
||||||
level.drop(seed, pos).sprite.drop();
|
level.drop(seed, pos).sprite.drop();
|
||||||
Dungeon.limitedDrops.blandfruitSeed.count++;
|
Dungeon.LimitedDrops.BLANDFRUIT_SEED.count++;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
level.drop(seed, pos).sprite.drop();
|
level.drop(seed, pos).sprite.drop();
|
||||||
|
|
|
@ -300,32 +300,32 @@ public class ShopRoom extends SpecialRoom {
|
||||||
|
|
||||||
//count up items in the main bag, for bags which haven't yet been dropped.
|
//count up items in the main bag, for bags which haven't yet been dropped.
|
||||||
for (Item item : pack.backpack.items) {
|
for (Item item : pack.backpack.items) {
|
||||||
if (!Dungeon.limitedDrops.seedBag.dropped() && item instanceof Plant.Seed)
|
if (!Dungeon.LimitedDrops.SEED_POUCH.dropped() && item instanceof Plant.Seed)
|
||||||
seeds++;
|
seeds++;
|
||||||
else if (!Dungeon.limitedDrops.scrollBag.dropped() && item instanceof Scroll)
|
else if (!Dungeon.LimitedDrops.SCROLL_HOLDER.dropped() && item instanceof Scroll)
|
||||||
scrolls++;
|
scrolls++;
|
||||||
else if (!Dungeon.limitedDrops.potionBag.dropped() && item instanceof Potion)
|
else if (!Dungeon.LimitedDrops.POTION_BANDOLIER.dropped() && item instanceof Potion)
|
||||||
potions++;
|
potions++;
|
||||||
else if (!Dungeon.limitedDrops.wandBag.dropped() && item instanceof Wand)
|
else if (!Dungeon.LimitedDrops.WAND_HOLSTER.dropped() && item instanceof Wand)
|
||||||
wands++;
|
wands++;
|
||||||
}
|
}
|
||||||
|
|
||||||
//then pick whichever valid bag has the most items available to put into it.
|
//then pick whichever valid bag has the most items available to put into it.
|
||||||
//note that the order here gives a perference if counts are otherwise equal
|
//note that the order here gives a perference if counts are otherwise equal
|
||||||
if (seeds >= scrolls && seeds >= potions && seeds >= wands && !Dungeon.limitedDrops.seedBag.dropped()) {
|
if (seeds >= scrolls && seeds >= potions && seeds >= wands && !Dungeon.LimitedDrops.SEED_POUCH.dropped()) {
|
||||||
Dungeon.limitedDrops.seedBag.drop();
|
Dungeon.LimitedDrops.SEED_POUCH.drop();
|
||||||
return new SeedPouch();
|
return new SeedPouch();
|
||||||
|
|
||||||
} else if (scrolls >= potions && scrolls >= wands && !Dungeon.limitedDrops.scrollBag.dropped()) {
|
} else if (scrolls >= potions && scrolls >= wands && !Dungeon.LimitedDrops.SCROLL_HOLDER.dropped()) {
|
||||||
Dungeon.limitedDrops.scrollBag.drop();
|
Dungeon.LimitedDrops.SCROLL_HOLDER.drop();
|
||||||
return new ScrollHolder();
|
return new ScrollHolder();
|
||||||
|
|
||||||
} else if (potions >= wands && !Dungeon.limitedDrops.potionBag.dropped()) {
|
} else if (potions >= wands && !Dungeon.LimitedDrops.POTION_BANDOLIER.dropped()) {
|
||||||
Dungeon.limitedDrops.potionBag.drop();
|
Dungeon.LimitedDrops.POTION_BANDOLIER.drop();
|
||||||
return new PotionBandolier();
|
return new PotionBandolier();
|
||||||
|
|
||||||
} else if (!Dungeon.limitedDrops.wandBag.dropped()) {
|
} else if (!Dungeon.LimitedDrops.WAND_HOLSTER.dropped()) {
|
||||||
Dungeon.limitedDrops.wandBag.drop();
|
Dungeon.LimitedDrops.WAND_HOLSTER.drop();
|
||||||
return new WandHolster();
|
return new WandHolster();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,9 +89,9 @@ public abstract class Plant implements Bundlable {
|
||||||
Item seed = Generator.random(Generator.Category.SEED);
|
Item seed = Generator.random(Generator.Category.SEED);
|
||||||
|
|
||||||
if (seed instanceof BlandfruitBush.Seed) {
|
if (seed instanceof BlandfruitBush.Seed) {
|
||||||
if (Random.Int(15) - Dungeon.limitedDrops.blandfruitSeed.count >= 0) {
|
if (Random.Int(15) - Dungeon.LimitedDrops.BLANDFRUIT_SEED.count >= 0) {
|
||||||
Dungeon.level.drop(seed, pos).sprite.drop();
|
Dungeon.level.drop(seed, pos).sprite.drop();
|
||||||
Dungeon.limitedDrops.blandfruitSeed.count++;
|
Dungeon.LimitedDrops.BLANDFRUIT_SEED.count++;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
Dungeon.level.drop(seed, pos).sprite.drop();
|
Dungeon.level.drop(seed, pos).sprite.drop();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user