From 65b0a40865301a575c020577d1c15ebfb532b390 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sun, 12 Jun 2016 20:52:34 -0400 Subject: [PATCH] v0.4.0: improved some interactions with full inventories --- .../shatteredpixeldungeon/items/KindofMisc.java | 4 +++- .../shatteredpixeldungeon/items/bags/Bag.java | 16 +++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/KindofMisc.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/KindofMisc.java index a13eb756f..bd8fb8f83 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/KindofMisc.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/KindofMisc.java @@ -38,7 +38,6 @@ public abstract class KindofMisc extends EquipableItem { final KindofMisc m1 = hero.belongings.misc1; final KindofMisc m2 = hero.belongings.misc2; - final KindofMisc toEquip = this; GameScene.show( new WndOptions(Messages.get(KindofMisc.class, "unequip_title"), @@ -50,8 +49,11 @@ public abstract class KindofMisc extends EquipableItem { protected void onSelect(int index) { KindofMisc equipped = (index == 0 ? m1 : m2); + detach( hero.belongings.backpack ); if (equipped.doUnequip(hero, true, false)) { execute(hero, AC_EQUIP); + } else { + collect( hero.belongings.backpack ); } } }); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/bags/Bag.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/bags/Bag.java index 266514568..25c507780 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/bags/Bag.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/bags/Bag.java @@ -65,17 +65,19 @@ public class Bag extends Item implements Iterable { @Override public boolean collect( Bag container ) { + + for (Item item : container.items.toArray( new Item[0] )) { + if (grab( item )) { + item.detachAll( container ); + if (!item.collect( this )) + item.collect( container ); + } + } + if (super.collect( container )) { owner = container.owner; - for (Item item : container.items.toArray( new Item[0] )) { - if (grab( item )) { - item.detachAll( container ); - item.collect( this ); - } - } - Badges.validateAllBagsBought( this ); return true;