use of com.shatteredpixel.shatteredpixeldungeon.items.bags.MagicalHolster in project shattered-pixel-dungeon-gdx by 00-Evan.
the class ShopRoom method ChooseBag.
protected static Bag ChooseBag(Belongings pack) {
// 0=pouch, 1=holder, 2=bandolier, 3=holster
int[] bagItems = new int[4];
// count up items in the main bag
for (Item item : pack.backpack.items) {
if (item instanceof Plant.Seed || item instanceof Runestone)
bagItems[0]++;
if (item instanceof Scroll)
bagItems[1]++;
if (item instanceof Potion)
bagItems[2]++;
if (item instanceof Wand || item instanceof MissileWeapon)
bagItems[3]++;
}
// disqualify bags that have already been dropped
if (Dungeon.LimitedDrops.VELVET_POUCH.dropped())
bagItems[0] = -1;
if (Dungeon.LimitedDrops.SCROLL_HOLDER.dropped())
bagItems[1] = -1;
if (Dungeon.LimitedDrops.POTION_BANDOLIER.dropped())
bagItems[2] = -1;
if (Dungeon.LimitedDrops.MAGICAL_HOLSTER.dropped())
bagItems[3] = -1;
// find the best bag to drop. This does give a preference to later bags, if counts are equal
int bestBagIdx = 0;
for (int i = 1; i <= 3; i++) {
if (bagItems[bestBagIdx] <= bagItems[i]) {
bestBagIdx = i;
}
}
// drop it, or return nothing if no bag works
if (bagItems[bestBagIdx] == -1)
return null;
switch(bestBagIdx) {
case 0:
default:
Dungeon.LimitedDrops.VELVET_POUCH.drop();
return new VelvetPouch();
case 1:
Dungeon.LimitedDrops.SCROLL_HOLDER.drop();
return new ScrollHolder();
case 2:
Dungeon.LimitedDrops.POTION_BANDOLIER.drop();
return new PotionBandolier();
case 3:
Dungeon.LimitedDrops.MAGICAL_HOLSTER.drop();
return new MagicalHolster();
}
}
Aggregations