v0.2.4: refactored handling the quickslot when equipping.
This commit is contained in:
@@ -38,7 +38,14 @@ public abstract class EquipableItem extends Item {
|
|||||||
@Override
|
@Override
|
||||||
public void execute( Hero hero, String action ) {
|
public void execute( Hero hero, String action ) {
|
||||||
if (action.equals( AC_EQUIP )) {
|
if (action.equals( AC_EQUIP )) {
|
||||||
|
//In addition to equipping itself, item reassigns itself to the quickslot
|
||||||
|
//This is a special case as the item is being removed from inventory, but is staying with the hero.
|
||||||
|
int slot = Dungeon.quickslot.getSlot( this );
|
||||||
doEquip(hero);
|
doEquip(hero);
|
||||||
|
if (slot != -1) {
|
||||||
|
Dungeon.quickslot.setSlot( slot, this );
|
||||||
|
updateQuickslot();
|
||||||
|
}
|
||||||
} else if (action.equals( AC_UNEQUIP )) {
|
} else if (action.equals( AC_UNEQUIP )) {
|
||||||
doUnequip( hero, true );
|
doUnequip( hero, true );
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -49,12 +49,8 @@ public class KindOfWeapon extends EquipableItem {
|
|||||||
@Override
|
@Override
|
||||||
public boolean doEquip( Hero hero ) {
|
public boolean doEquip( Hero hero ) {
|
||||||
|
|
||||||
int slot = Dungeon.quickslot.getSlot( this );
|
|
||||||
|
|
||||||
detachAll( hero.belongings.backpack );
|
detachAll( hero.belongings.backpack );
|
||||||
|
|
||||||
if (slot != -1) Dungeon.quickslot.setSlot( slot, this );
|
|
||||||
|
|
||||||
if (hero.belongings.weapon == null || hero.belongings.weapon.doUnequip( hero, true )) {
|
if (hero.belongings.weapon == null || hero.belongings.weapon.doUnequip( hero, true )) {
|
||||||
|
|
||||||
hero.belongings.weapon = this;
|
hero.belongings.weapon = this;
|
||||||
|
|||||||
@@ -93,12 +93,8 @@ public class Armor extends EquipableItem {
|
|||||||
@Override
|
@Override
|
||||||
public boolean doEquip( Hero hero ) {
|
public boolean doEquip( Hero hero ) {
|
||||||
|
|
||||||
int slot = Dungeon.quickslot.getSlot( this );
|
|
||||||
|
|
||||||
detach( hero.belongings.backpack );
|
detach( hero.belongings.backpack );
|
||||||
|
|
||||||
if (slot != -1) Dungeon.quickslot.setSlot( slot, this );
|
|
||||||
|
|
||||||
if (hero.belongings.armor == null || hero.belongings.armor.doUnequip( hero, true, false )) {
|
if (hero.belongings.armor == null || hero.belongings.armor.doUnequip( hero, true, false )) {
|
||||||
|
|
||||||
hero.belongings.armor = this;
|
hero.belongings.armor = this;
|
||||||
|
|||||||
@@ -80,12 +80,8 @@ public class Artifact extends KindofMisc {
|
|||||||
hero.belongings.misc2 = this;
|
hero.belongings.misc2 = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
int slot = Dungeon.quickslot.getSlot( this );
|
|
||||||
|
|
||||||
detach( hero.belongings.backpack );
|
detach( hero.belongings.backpack );
|
||||||
|
|
||||||
if (slot != -1) Dungeon.quickslot.setSlot( slot, this );
|
|
||||||
|
|
||||||
activate( hero );
|
activate( hero );
|
||||||
|
|
||||||
cursedKnown = true;
|
cursedKnown = true;
|
||||||
|
|||||||
@@ -126,12 +126,8 @@ public class Ring extends KindofMisc {
|
|||||||
hero.belongings.misc2 = this;
|
hero.belongings.misc2 = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
int slot = Dungeon.quickslot.getSlot( this );
|
|
||||||
|
|
||||||
detach( hero.belongings.backpack );
|
detach( hero.belongings.backpack );
|
||||||
|
|
||||||
if (slot != -1) Dungeon.quickslot.setSlot( slot, this );
|
|
||||||
|
|
||||||
activate( hero );
|
activate( hero );
|
||||||
|
|
||||||
cursedKnown = true;
|
cursedKnown = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user