v0.4.0: lots of refactoring to on-upgrade logic
This commit is contained in:
committed by
Evan Debenham
parent
9f65ff4e5b
commit
4c8bcade38
@@ -68,7 +68,7 @@ public class ScrollOfRemoveCurse extends InventoryScroll {
|
||||
}
|
||||
if (item instanceof Weapon){
|
||||
Weapon w = (Weapon) item;
|
||||
if (w.enchantment != null && w.enchantment.curse()){
|
||||
if (w.hasCurseEnchant()){
|
||||
w.enchant(null);
|
||||
w.cursed = false;
|
||||
procced = true;
|
||||
@@ -76,7 +76,7 @@ public class ScrollOfRemoveCurse extends InventoryScroll {
|
||||
}
|
||||
if (item instanceof Armor){
|
||||
Armor a = (Armor) item;
|
||||
if (a.glyph != null && a.glyph.curse()){
|
||||
if (a.hasCurseGlyph()){
|
||||
a.inscribe(null);
|
||||
a.cursed = false;
|
||||
procced = true;
|
||||
|
||||
@@ -21,9 +21,15 @@
|
||||
package com.shatteredpixel.shatteredpixeldungeon.items.scrolls;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Badges;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ShadowParticle;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.rings.Ring;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
|
||||
@@ -40,10 +46,69 @@ public class ScrollOfUpgrade extends InventoryScroll {
|
||||
@Override
|
||||
protected void onItemSelected( Item item ) {
|
||||
|
||||
item.upgrade();
|
||||
|
||||
upgrade( curUser );
|
||||
GLog.p( Messages.get(this, "looks_better", item.name()) );
|
||||
|
||||
//logic for telling the user when item properties change from upgrades
|
||||
//...yes this is rather messy
|
||||
if (item instanceof Weapon){
|
||||
Weapon w = (Weapon) item;
|
||||
boolean wasCursed = w.cursed;
|
||||
boolean hadCursedEnchant = w.hasCurseEnchant();
|
||||
boolean hadGoodEnchant = w.hasGoodEnchant();
|
||||
|
||||
w.upgrade();
|
||||
|
||||
if (hadCursedEnchant && !w.hasCurseEnchant()){
|
||||
removeCurse( Dungeon.hero );
|
||||
} else if (wasCursed && !w.cursed){
|
||||
weakenCurse( Dungeon.hero );
|
||||
}
|
||||
if (hadGoodEnchant && !w.hasGoodEnchant()){
|
||||
GLog.w( Messages.get(Weapon.class, "incompatible") );
|
||||
}
|
||||
|
||||
} else if (item instanceof Armor){
|
||||
Armor a = (Armor) item;
|
||||
boolean wasCursed = a.cursed;
|
||||
boolean hadCursedGlyph = a.hasCurseGlyph();
|
||||
boolean hadGoodGlyph = a.hasGoodGlyph();
|
||||
|
||||
a.upgrade();
|
||||
|
||||
if (hadCursedGlyph && a.glyph == null){
|
||||
removeCurse( Dungeon.hero );
|
||||
} else if (wasCursed && !a.cursed){
|
||||
weakenCurse( Dungeon.hero );
|
||||
}
|
||||
if (hadGoodGlyph && !a.hasGoodGlyph()){
|
||||
GLog.w( Messages.get(Armor.class, "incompatible") );
|
||||
}
|
||||
|
||||
} else if (item instanceof Wand) {
|
||||
boolean wasCursed = item.cursed;
|
||||
|
||||
item.upgrade();
|
||||
|
||||
if (wasCursed && !item.cursed){
|
||||
removeCurse( Dungeon.hero );
|
||||
}
|
||||
|
||||
} else if (item instanceof Ring) {
|
||||
boolean wasCursed = item.cursed;
|
||||
|
||||
item.upgrade();
|
||||
|
||||
if (wasCursed && !item.cursed){
|
||||
if (item.level() < 1){
|
||||
weakenCurse( Dungeon.hero );
|
||||
} else {
|
||||
removeCurse( Dungeon.hero );
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
item.upgrade();
|
||||
}
|
||||
|
||||
Badges.validateItemLevelAquired( item );
|
||||
}
|
||||
@@ -52,4 +117,14 @@ public class ScrollOfUpgrade extends InventoryScroll {
|
||||
hero.sprite.emitter().start( Speck.factory( Speck.UP ), 0.2f, 3 );
|
||||
}
|
||||
|
||||
public static void weakenCurse( Hero hero ){
|
||||
GLog.p( Messages.get(ScrollOfUpgrade.class, "weaken_curse") );
|
||||
hero.sprite.emitter().start( ShadowParticle.UP, 0.05f, 5 );
|
||||
}
|
||||
|
||||
public static void removeCurse( Hero hero ){
|
||||
GLog.p( Messages.get(ScrollOfUpgrade.class, "remove_curse") );
|
||||
hero.sprite.emitter().start( ShadowParticle.UP, 0.05f, 10 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user