From 1325f3317e20db422e0190861e90e1c52e914141 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Wed, 5 Aug 2020 12:19:08 -0400 Subject: [PATCH] v0.8.2: unique stackable items can now be sold to shops --- .../actors/mobs/npcs/Shopkeeper.java | 9 +++++++++ .../shatteredpixeldungeon/windows/WndBag.java | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Shopkeeper.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Shopkeeper.java index f2997d83b..ed108b39e 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Shopkeeper.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Shopkeeper.java @@ -28,6 +28,7 @@ import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter; import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ElmoParticle; import com.shatteredpixel.shatteredpixeldungeon.items.Heap; import com.shatteredpixel.shatteredpixeldungeon.items.Item; +import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor; import com.shatteredpixel.shatteredpixeldungeon.journal.Notes; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; @@ -102,6 +103,14 @@ public class Shopkeeper extends NPC { public static WndBag sell() { return GameScene.selectItem( itemSelector, WndBag.Mode.FOR_SALE, Messages.get(Shopkeeper.class, "sell")); } + + public static boolean willBuyItem( Item item ){ + if (item.value() < 0) return false; + if (item.unique && !item.stackable) return false; + if (item instanceof Armor && ((Armor) item).checkSeal() != null) return false; + if (item.isEquipped(Dungeon.hero) && item.cursed) return false; + return true; + } private static WndBag.Listener itemSelector = new WndBag.Listener() { @Override diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java index b7c48d3a3..4cc7088c7 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java @@ -26,6 +26,7 @@ import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.SPDAction; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Belongings; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; +import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Shopkeeper; import com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem; import com.shatteredpixel.shatteredpixeldungeon.items.Gold; import com.shatteredpixel.shatteredpixeldungeon.items.Item; @@ -412,7 +413,7 @@ public class WndBag extends WndTabbed { enable( false ); } else { enable( - mode == Mode.FOR_SALE && !item.unique && (item.value() > 0) && (!item.isEquipped( Dungeon.hero ) || !item.cursed) || + mode == Mode.FOR_SALE && Shopkeeper.willBuyItem(item) || mode == Mode.UPGRADEABLE && item.isUpgradable() || mode == Mode.UNIDENTIFED && !item.isIdentified() || mode == Mode.UNCURSABLE && ScrollOfRemoveCurse.uncursable(item) ||