diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Belongings.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Belongings.java index 40565908c..115b59601 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Belongings.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Belongings.java @@ -103,7 +103,7 @@ public class Belongings implements Iterable { public KindOfWeapon weapon(){ boolean lostInvent = owner != null && owner.buff(LostInventory.class) != null; - if (!lostInvent || (weapon != null && weapon.keptThoughLostInvent)){ + if (!lostInvent || (weapon != null && weapon.keptThroughLostInventory())){ return weapon; } else { return null; @@ -112,7 +112,7 @@ public class Belongings implements Iterable { public Armor armor(){ boolean lostInvent = owner != null && owner.buff(LostInventory.class) != null; - if (!lostInvent || (armor != null && armor.keptThoughLostInvent)){ + if (!lostInvent || (armor != null && armor.keptThroughLostInventory())){ return armor; } else { return null; @@ -121,7 +121,7 @@ public class Belongings implements Iterable { public Artifact artifact(){ boolean lostInvent = owner != null && owner.buff(LostInventory.class) != null; - if (!lostInvent || (artifact != null && artifact.keptThoughLostInvent)){ + if (!lostInvent || (artifact != null && artifact.keptThroughLostInventory())){ return artifact; } else { return null; @@ -130,7 +130,7 @@ public class Belongings implements Iterable { public KindofMisc misc(){ boolean lostInvent = owner != null && owner.buff(LostInventory.class) != null; - if (!lostInvent || (misc != null && misc.keptThoughLostInvent)){ + if (!lostInvent || (misc != null && misc.keptThroughLostInventory())){ return misc; } else { return null; @@ -139,7 +139,7 @@ public class Belongings implements Iterable { public Ring ring(){ boolean lostInvent = owner != null && owner.buff(LostInventory.class) != null; - if (!lostInvent || (ring != null && ring.keptThoughLostInvent)){ + if (!lostInvent || (ring != null && ring.keptThroughLostInventory())){ return ring; } else { return null; @@ -148,7 +148,7 @@ public class Belongings implements Iterable { public KindOfWeapon secondWep(){ boolean lostInvent = owner != null && owner.buff(LostInventory.class) != null; - if (!lostInvent || (secondWep != null && secondWep.keptThoughLostInvent)){ + if (!lostInvent || (secondWep != null && secondWep.keptThroughLostInventory())){ return secondWep; } else { return null; @@ -236,7 +236,7 @@ public class Belongings implements Iterable { for (Item item : this) { if (itemClass.isInstance( item )) { - if (!lostInvent || item.keptThoughLostInvent) { + if (!lostInvent || item.keptThroughLostInventory()) { return (T) item; } } @@ -252,7 +252,7 @@ public class Belongings implements Iterable { for (Item item : this) { if (itemClass.isInstance( item )) { - if (!lostInvent || item.keptThoughLostInvent) { + if (!lostInvent || item.keptThroughLostInventory()) { result.add((T) item); } } @@ -267,7 +267,7 @@ public class Belongings implements Iterable { for (Item item : this) { if (contains == item) { - if (!lostInvent || item.keptThoughLostInvent) { + if (!lostInvent || item.keptThroughLostInventory()) { return true; } } @@ -282,7 +282,7 @@ public class Belongings implements Iterable { for (Item item : this) { if (similar != item && similar.isSimilar(item)) { - if (!lostInvent || item.keptThoughLostInvent) { + if (!lostInvent || item.keptThroughLostInventory()) { return item; } } @@ -298,7 +298,7 @@ public class Belongings implements Iterable { for (Item item : this) { if (item != similar && similar.isSimilar(item)) { - if (!lostInvent || item.keptThoughLostInvent) { + if (!lostInvent || item.keptThroughLostInventory()) { result.add(item); } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java index f51aacf78..ade33c2aa 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java @@ -2351,15 +2351,15 @@ public class Hero extends Char { for (Item i : belongings){ if (i instanceof EquipableItem && i.isEquipped(this)){ ((EquipableItem) i).activate(this); - } else if (i instanceof CloakOfShadows && i.keptThoughLostInvent && hasTalent(Talent.LIGHT_CLOAK)){ + } else if (i instanceof CloakOfShadows && i.keptThroughLostInventory() && hasTalent(Talent.LIGHT_CLOAK)){ ((CloakOfShadows) i).activate(this); - } else if (i instanceof Wand && i.keptThoughLostInvent){ + } else if (i instanceof Wand && i.keptThroughLostInventory()){ if (holster != null && holster.contains(i)){ ((Wand) i).charge(this, MagicalHolster.HOLSTER_SCALE_FACTOR); } else { ((Wand) i).charge(this); } - } else if (i instanceof MagesStaff && i.keptThoughLostInvent){ + } else if (i instanceof MagesStaff && i.keptThroughLostInventory()){ ((MagesStaff) i).applyWandChargeBuff(this); } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Talent.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Talent.java index 43609b53d..6a307ca09 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Talent.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Talent.java @@ -431,7 +431,7 @@ public enum Talent { if (talent == LIGHT_CLOAK && hero.heroClass == HeroClass.ROGUE){ for (Item item : Dungeon.hero.belongings.backpack){ if (item instanceof CloakOfShadows){ - if (hero.buff(LostInventory.class) == null || item.keptThoughLostInvent) { + if (hero.buff(LostInventory.class) == null || item.keptThroughLostInventory()) { ((CloakOfShadows) item).activate(Dungeon.hero); } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/EquipableItem.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/EquipableItem.java index 2301a89ea..950a07975 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/EquipableItem.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/EquipableItem.java @@ -127,7 +127,7 @@ public abstract class EquipableItem extends Item { if (cursed && hero.buff(MagicImmune.class) == null - && (hero.buff(LostInventory.class) == null || keptThoughLostInvent)) { + && (hero.buff(LostInventory.class) == null || keptThroughLostInventory())) { GLog.w(Messages.get(EquipableItem.class, "unequip_cursed")); return false; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Item.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Item.java index 8cb73ef0d..af78e8d82 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Item.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Item.java @@ -89,6 +89,7 @@ public class Item implements Bundlable { public boolean unique = false; // These items are preserved even if the hero's inventory is lost via unblessed ankh + // this is largely set by the resurrection window, items can override this to always be kept public boolean keptThoughLostInvent = false; // whether an item can be included in heroes remains @@ -140,6 +141,10 @@ public class Item implements Bundlable { keptThoughLostInvent = false; } + public boolean keptThroughLostInventory(){ + return keptThoughLostInvent; + } + public void doThrow( Hero hero ) { GameScene.selectCell(thrower); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/LostBackpack.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/LostBackpack.java index bb45551fe..8aa0cd729 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/LostBackpack.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/LostBackpack.java @@ -50,7 +50,7 @@ public class LostBackpack extends Item { MagicalHolster holster = hero.belongings.getItem(MagicalHolster.class); for (Item i : hero.belongings){ - if (i.keptThoughLostInvent){ + if (i.keptThroughLostInventory()){ i.keptThoughLostInvent = false; //don't reactivate, was previously activated } else { if (i instanceof EquipableItem && i.isEquipped(hero)){ diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/bags/Bag.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/bags/Bag.java index 57008441c..3c7f8f789 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/bags/Bag.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/bags/Bag.java @@ -168,7 +168,7 @@ public class Bag extends Item implements Iterable { public boolean canHold( Item item ){ if (!loading && owner != null && owner.buff(LostInventory.class) != null - && !item.keptThoughLostInvent){ + && !item.keptThroughLostInventory()){ return false; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/quest/Pickaxe.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/quest/Pickaxe.java index 2ad9f317d..ba9edf2e3 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/quest/Pickaxe.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/quest/Pickaxe.java @@ -41,6 +41,7 @@ import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter; import com.shatteredpixel.shatteredpixeldungeon.effects.Speck; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MeleeWeapon; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; +import com.shatteredpixel.shatteredpixeldungeon.levels.MiningLevel; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; @@ -88,6 +89,10 @@ public class Pickaxe extends MeleeWeapon { if (Blacksmith.Quest.oldMiningQuest()) { actions.add(AC_MINE); } + if (Dungeon.level instanceof MiningLevel){ + actions.remove(AC_DROP); + actions.remove(AC_THROW); + } return actions; } @@ -166,6 +171,12 @@ public class Pickaxe extends MeleeWeapon { return super.proc( attacker, defender, damage ); } + @Override + public boolean keptThroughLostInventory() { + //pickaxe is always kept when it's needed for the mining level + return super.keptThroughLostInventory() || Dungeon.level instanceof MiningLevel; + } + @Override public String defaultAction() { if (Dungeon.hero.heroClass == HeroClass.DUELIST && isEquipped(Dungeon.hero)){ diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/InventoryPane.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/InventoryPane.java index c924d57c8..956fc50f2 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/InventoryPane.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/InventoryPane.java @@ -365,13 +365,13 @@ public class InventoryPane extends Component { b.enable(lastEnabled && !(b.item() instanceof WndBag.Placeholder) && (selector == null || selector.itemSelectable(b.item())) - && (!lostInvent || b.item().keptThoughLostInvent)); + && (!lostInvent || b.item().keptThroughLostInventory())); } for (InventorySlot b : bagItems){ b.enable(lastEnabled && b.item() != null && (selector == null || selector.itemSelectable(b.item())) - && (!lostInvent || b.item().keptThoughLostInvent)); + && (!lostInvent || b.item().keptThroughLostInventory())); } for (BagButton b : bags){ b.enable(lastEnabled); @@ -455,13 +455,13 @@ public class InventoryPane extends Component { b.enable(lastEnabled && !(b.item() instanceof WndBag.Placeholder) && (selector == null || selector.itemSelectable(b.item())) - && (!lostInvent || b.item().keptThoughLostInvent)); + && (!lostInvent || b.item().keptThroughLostInventory())); } for (InventorySlot b : bagItems){ b.enable(lastEnabled && b.item() != null && (selector == null || selector.itemSelectable(b.item())) - && (!lostInvent || b.item().keptThoughLostInvent)); + && (!lostInvent || b.item().keptThroughLostInventory())); } for (BagButton b : bags){ b.enable(lastEnabled); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/InventorySlot.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/InventorySlot.java index df40eb320..62e20af06 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/InventorySlot.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/InventorySlot.java @@ -102,7 +102,7 @@ public class InventorySlot extends ItemSlot { if (item.name() == null) { enable( false ); } else if (Dungeon.hero.buff(LostInventory.class) != null - && !item.keptThoughLostInvent){ + && !item.keptThroughLostInventory()){ enable(false); } } else { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/QuickSlotButton.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/QuickSlotButton.java index 10ad1d106..297380f08 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/QuickSlotButton.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/QuickSlotButton.java @@ -302,7 +302,7 @@ public class QuickSlotButton extends Button { private void enableSlot() { slot.enable(Dungeon.quickslot.isNonePlaceholder( slotNum ) - && (Dungeon.hero.buff(LostInventory.class) == null || Dungeon.quickslot.getItem(slotNum).keptThoughLostInvent)); + && (Dungeon.hero.buff(LostInventory.class) == null || Dungeon.quickslot.getItem(slotNum).keptThroughLostInventory())); } public void slotMargins( int left, int top, int right, int bottom){ diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/Toolbar.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/Toolbar.java index e8e41c90b..84843b4e7 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/Toolbar.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/Toolbar.java @@ -128,7 +128,7 @@ public class Toolbar extends Component { Item item = Dungeon.quickslot.getItem(i); if (item != null && !Dungeon.quickslot.isPlaceholder(i) && - (Dungeon.hero.buff(LostInventory.class) == null || item.keptThoughLostInvent)){ + (Dungeon.hero.buff(LostInventory.class) == null || item.keptThroughLostInventory())){ slotNames[i] = Messages.titleCase(item.name()); slotIcons[i] = new ItemSprite(item); } else { @@ -154,7 +154,7 @@ public class Toolbar extends Component { Item item = Dungeon.quickslot.getItem(idx); if (item == null || Dungeon.quickslot.isPlaceholder(idx) - || (Dungeon.hero.buff(LostInventory.class) != null && !item.keptThoughLostInvent) + || (Dungeon.hero.buff(LostInventory.class) != null && !item.keptThroughLostInventory()) || alt){ //TODO would be nice to use a radial menu for this too // Also a bunch of code could be moved out of here into subclasses of RadialMenu @@ -420,7 +420,7 @@ public class Toolbar extends Component { for(Item i : bag.items){ if (i instanceof Bag) items.remove(i); - if (Dungeon.hero.buff(LostInventory.class) != null && !i.keptThoughLostInvent) items.remove(i); + if (Dungeon.hero.buff(LostInventory.class) != null && !i.keptThroughLostInventory()) items.remove(i); } if (idx == 0){