v0.6.1: improved quickslot interactions with thieves and monks

This commit is contained in:
Evan Debenham 2017-08-05 02:52:08 -04:00
parent 0588036643
commit caf6f5ca50
6 changed files with 19 additions and 6 deletions

View File

@ -85,9 +85,9 @@ public class QuickSlot {
return getSlot(item) != -1; return getSlot(item) != -1;
} }
public void replaceSimilar(Item item){ public void replacePlaceholder(Item item){
for (int i = 0; i < SIZE; i++) for (int i = 0; i < SIZE; i++)
if (getItem(i) != null && item.isSimilar(getItem(i))) if (isPlaceholder(i) && item.isSimilar(getItem(i)))
setSlot( i , item ); setSlot( i , item );
} }

View File

@ -139,6 +139,17 @@ public class Belongings implements Iterable<Item> {
return null; return null;
} }
public Item getSimilar( Item similar ){
for (Item item : this) {
if (item.isSimilar(similar)) {
return item;
}
}
return null;
}
public void identify() { public void identify() {
for (Item item : this) { for (Item item : this) {
item.identify(); item.identify();

View File

@ -97,7 +97,7 @@ public class Monk extends Mob {
if (--hitsToDisarm == 0) { if (--hitsToDisarm == 0) {
hero.belongings.weapon = null; hero.belongings.weapon = null;
Dungeon.quickslot.clearItem(weapon); Dungeon.quickslot.convertToPlaceholder(weapon);
weapon.updateQuickslot(); weapon.updateQuickslot();
Dungeon.level.drop(weapon, hero.pos).sprite.drop(); Dungeon.level.drop(weapon, hero.pos).sprite.drop();
GLog.w(Messages.get(this, "disarm", weapon.name())); GLog.w(Messages.get(this, "disarm", weapon.name()));

View File

@ -147,7 +147,9 @@ public class Thief extends Mob {
if (item != null && !item.unique && item.level() < 1 ) { if (item != null && !item.unique && item.level() < 1 ) {
GLog.w( Messages.get(Thief.class, "stole", item.name()) ); GLog.w( Messages.get(Thief.class, "stole", item.name()) );
Dungeon.quickslot.clearItem( item ); if (!item.stackable || hero.belongings.getSimilar(item) == null) {
Dungeon.quickslot.convertToPlaceholder(item);
}
item.updateQuickslot(); item.updateQuickslot();
if (item instanceof Honeypot){ if (item instanceof Honeypot){

View File

@ -190,7 +190,7 @@ public class Item implements Bundlable {
} }
items.add( this ); items.add( this );
if (stackable || this instanceof Boomerang) Dungeon.quickslot.replaceSimilar(this); Dungeon.quickslot.replacePlaceholder(this);
updateQuickslot(); updateQuickslot();
Collections.sort( items, itemComparator ); Collections.sort( items, itemComparator );
return true; return true;

View File

@ -114,7 +114,7 @@ public class Boomerang extends MissileWeapon {
if (throwEquiped) { if (throwEquiped) {
owner.belongings.weapon = this; owner.belongings.weapon = this;
owner.spend( -TIME_TO_EQUIP ); owner.spend( -TIME_TO_EQUIP );
Dungeon.quickslot.replaceSimilar(this); Dungeon.quickslot.replacePlaceholder(this);
updateQuickslot(); updateQuickslot();
} else } else
if (!collect( curUser.belongings.backpack )) { if (!collect( curUser.belongings.backpack )) {