v0.8.2: unique stackable items can now be sold to shops

This commit is contained in:
Evan Debenham 2020-08-05 12:19:08 -04:00
parent f1c56ba6c7
commit 1325f3317e
2 changed files with 11 additions and 1 deletions

View File

@ -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;
@ -103,6 +104,14 @@ public class Shopkeeper extends NPC {
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
public void onSelect( Item item ) {

View File

@ -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) ||