v0.4.0: improved some interactions with full inventories

This commit is contained in:
Evan Debenham 2016-06-12 20:52:34 -04:00 committed by Evan Debenham
parent edbb426764
commit 65b0a40865
2 changed files with 12 additions and 8 deletions

View File

@ -38,7 +38,6 @@ public abstract class KindofMisc extends EquipableItem {
final KindofMisc m1 = hero.belongings.misc1; final KindofMisc m1 = hero.belongings.misc1;
final KindofMisc m2 = hero.belongings.misc2; final KindofMisc m2 = hero.belongings.misc2;
final KindofMisc toEquip = this;
GameScene.show( GameScene.show(
new WndOptions(Messages.get(KindofMisc.class, "unequip_title"), new WndOptions(Messages.get(KindofMisc.class, "unequip_title"),
@ -50,8 +49,11 @@ public abstract class KindofMisc extends EquipableItem {
protected void onSelect(int index) { protected void onSelect(int index) {
KindofMisc equipped = (index == 0 ? m1 : m2); KindofMisc equipped = (index == 0 ? m1 : m2);
detach( hero.belongings.backpack );
if (equipped.doUnequip(hero, true, false)) { if (equipped.doUnequip(hero, true, false)) {
execute(hero, AC_EQUIP); execute(hero, AC_EQUIP);
} else {
collect( hero.belongings.backpack );
} }
} }
}); });

View File

@ -65,17 +65,19 @@ public class Bag extends Item implements Iterable<Item> {
@Override @Override
public boolean collect( Bag container ) { public boolean collect( Bag container ) {
if (super.collect( container )) {
owner = container.owner;
for (Item item : container.items.toArray( new Item[0] )) { for (Item item : container.items.toArray( new Item[0] )) {
if (grab( item )) { if (grab( item )) {
item.detachAll( container ); item.detachAll( container );
item.collect( this ); if (!item.collect( this ))
item.collect( container );
} }
} }
if (super.collect( container )) {
owner = container.owner;
Badges.validateAllBagsBought( this ); Badges.validateAllBagsBought( this );
return true; return true;