v0.7.1: fixed various errors relating to missile weapons, upgrading, and the blacksmith
This commit is contained in:
parent
e1bfd1bbbc
commit
0ea97b0149
|
@ -150,10 +150,21 @@ public class Belongings implements Iterable<Item> {
|
|||
return null;
|
||||
}
|
||||
|
||||
public boolean contains( Item contains ){
|
||||
|
||||
for (Item item : this) {
|
||||
if (contains == item ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public Item getSimilar( Item similar ){
|
||||
|
||||
for (Item item : this) {
|
||||
if (similar.isSimilar(item)) {
|
||||
if (similar != item && similar.isSimilar(item)) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
@ -165,7 +176,7 @@ public class Belongings implements Iterable<Item> {
|
|||
ArrayList<Item> result = new ArrayList<>();
|
||||
|
||||
for (Item item : this) {
|
||||
if (similar.isSimilar(item)) {
|
||||
if (item != similar && similar.isSimilar(item)) {
|
||||
result.add(item);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.items.quest.DarkGold;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.quest.Pickaxe;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfUpgrade;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.MissileWeapon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.journal.Notes;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.BlacksmithRoom;
|
||||
|
@ -149,7 +150,7 @@ public class Blacksmith extends NPC {
|
|||
|
||||
public static String verify( Item item1, Item item2 ) {
|
||||
|
||||
if (item1 == item2) {
|
||||
if (item1 == item2 && (item1.quantity() == 1 && item2.quantity() == 1)) {
|
||||
return Messages.get(Blacksmith.class, "same_item");
|
||||
}
|
||||
|
||||
|
@ -194,14 +195,20 @@ public class Blacksmith extends NPC {
|
|||
if (first.isEquipped( Dungeon.hero )) {
|
||||
((EquipableItem)first).doUnequip( Dungeon.hero, true );
|
||||
}
|
||||
if (first instanceof MissileWeapon && first.quantity() > 1){
|
||||
first = first.split(1);
|
||||
}
|
||||
first.level(first.level()+1); //prevents on-upgrade effects like enchant/glyph removal
|
||||
if (first instanceof MissileWeapon && !Dungeon.hero.belongings.contains(first)) {
|
||||
first.collect();
|
||||
}
|
||||
Dungeon.hero.spendAndNext( 2f );
|
||||
Badges.validateItemLevelAquired( first );
|
||||
|
||||
if (second.isEquipped( Dungeon.hero )) {
|
||||
((EquipableItem)second).doUnequip( Dungeon.hero, false );
|
||||
}
|
||||
second.detachAll( Dungeon.hero.belongings.backpack );
|
||||
second.detach( Dungeon.hero.belongings.backpack );
|
||||
|
||||
if (second instanceof Armor){
|
||||
BrokenSeal seal = ((Armor) second).checkSeal();
|
||||
|
|
|
@ -28,6 +28,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfUpgrade;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfEnchantment;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.SpiritBow;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
|
@ -44,10 +45,15 @@ public class MagicalInfusion extends InventorySpell {
|
|||
@Override
|
||||
protected void onItemSelected( Item item ) {
|
||||
|
||||
if (item instanceof Weapon)
|
||||
if (item instanceof SpiritBow){
|
||||
if (((SpiritBow) item).enchantment == null){
|
||||
((Weapon)item).enchant();
|
||||
}
|
||||
} else if (item instanceof Weapon) {
|
||||
((Weapon) item).upgrade(true);
|
||||
else
|
||||
} else {
|
||||
((Armor) item).upgrade(true);
|
||||
}
|
||||
|
||||
GLog.p( Messages.get(this, "infuse", item.name()) );
|
||||
|
||||
|
|
|
@ -96,24 +96,32 @@ abstract public class MissileWeapon extends Weapon {
|
|||
}
|
||||
|
||||
@Override
|
||||
//FIXME some logic here assumes the items are in the player's inventory. Might need to adjust
|
||||
public Item upgrade() {
|
||||
if (!bundleRestoring) {
|
||||
if (quantity > 1) {
|
||||
MissileWeapon left = (MissileWeapon) split(quantity - 1);
|
||||
left.parent = null;
|
||||
MissileWeapon upgraded = (MissileWeapon) split(1);
|
||||
upgraded.parent = null;
|
||||
|
||||
super.upgrade();
|
||||
upgraded = (MissileWeapon) upgraded.upgrade();
|
||||
|
||||
//deal with full inventory.
|
||||
if (!left.collect()) {
|
||||
Dungeon.level.drop(left, Dungeon.hero.pos);
|
||||
//try to put the upgraded into inventory, if it didn't already merge
|
||||
if (upgraded.quantity() == 1 && !upgraded.collect()) {
|
||||
Dungeon.level.drop(upgraded, Dungeon.hero.pos);
|
||||
}
|
||||
return upgraded;
|
||||
} else {
|
||||
durability = MAX_DURABILITY;
|
||||
super.upgrade();
|
||||
|
||||
Item similar = Dungeon.hero.belongings.getSimilar(this);
|
||||
if (similar != null){
|
||||
detach(Dungeon.hero.belongings.backpack);
|
||||
return similar.merge(this);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
durability = MAX_DURABILITY;
|
||||
return this;
|
||||
} else {
|
||||
return super.upgrade();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user