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;
}
public void replaceSimilar(Item item){
public void replacePlaceholder(Item item){
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 );
}

View File

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

View File

@ -97,7 +97,7 @@ public class Monk extends Mob {
if (--hitsToDisarm == 0) {
hero.belongings.weapon = null;
Dungeon.quickslot.clearItem(weapon);
Dungeon.quickslot.convertToPlaceholder(weapon);
weapon.updateQuickslot();
Dungeon.level.drop(weapon, hero.pos).sprite.drop();
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 ) {
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();
if (item instanceof Honeypot){

View File

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

View File

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