v0.4.0: lots of refactoring to on-upgrade logic
This commit is contained in:
parent
9f65ff4e5b
commit
4c8bcade38
|
@ -189,7 +189,7 @@ public class Blacksmith extends NPC {
|
||||||
if (first.isEquipped( Dungeon.hero )) {
|
if (first.isEquipped( Dungeon.hero )) {
|
||||||
((EquipableItem)first).doUnequip( Dungeon.hero, true );
|
((EquipableItem)first).doUnequip( Dungeon.hero, true );
|
||||||
}
|
}
|
||||||
first.upgrade();
|
first.level(first.level()+1); //prevents on-upgrade effects like enchant/glyph removal
|
||||||
GLog.p( Messages.get(ScrollOfUpgrade.class, "looks_better", first.name()) );
|
GLog.p( Messages.get(ScrollOfUpgrade.class, "looks_better", first.name()) );
|
||||||
Dungeon.hero.spendAndNext( 2f );
|
Dungeon.hero.spendAndNext( 2f );
|
||||||
Badges.validateItemLevelAquired( first );
|
Badges.validateItemLevelAquired( first );
|
||||||
|
|
|
@ -273,6 +273,8 @@ public class Item implements Bundlable {
|
||||||
|
|
||||||
public void level( int value ){
|
public void level( int value ){
|
||||||
level = value;
|
level = value;
|
||||||
|
|
||||||
|
updateQuickslot();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Item upgrade() {
|
public Item upgrade() {
|
||||||
|
|
|
@ -227,26 +227,11 @@ public class Armor extends EquipableItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Item upgrade( boolean inscribe ) {
|
public Item upgrade( boolean inscribe ) {
|
||||||
|
|
||||||
if (glyph != null) {
|
if (inscribe && (glyph == null || glyph.curse())){
|
||||||
if (inscribe && glyph.curse()){
|
inscribe( Glyph.random() );
|
||||||
inscribe( Glyph.random() );
|
} else if (!inscribe && Random.Float() > Math.pow(0.9, level())){
|
||||||
} else if (!inscribe && Random.Float() > Math.pow(0.9, level())) {
|
inscribe(null);
|
||||||
if (!glyph.curse())
|
|
||||||
GLog.w( Messages.get(Armor.class, "incompatible") );
|
|
||||||
else if (cursedKnown) {
|
|
||||||
GLog.p(Messages.get(Item.class, "remove_curse"));
|
|
||||||
Dungeon.hero.sprite.emitter().start( ShadowParticle.UP, 0.05f, 10 );
|
|
||||||
}
|
|
||||||
inscribe( null );
|
|
||||||
} else if (!inscribe && glyph.curse() && cursed && cursedKnown){
|
|
||||||
GLog.p( Messages.get(Item.class, "weaken_curse") );
|
|
||||||
Dungeon.hero.sprite.emitter().start( ShadowParticle.UP, 0.05f, 10 );
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (inscribe) {
|
|
||||||
inscribe( Glyph.random() );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (seal != null && seal.level() == 0)
|
if (seal != null && seal.level() == 0)
|
||||||
|
@ -406,8 +391,16 @@ public class Armor extends EquipableItem {
|
||||||
return inscribe( gl );
|
return inscribe( gl );
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInscribed() {
|
public boolean hasGlyph(Class<?extends Glyph> type) {
|
||||||
return glyph != null;
|
return glyph != null && glyph.getClass() == type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasGoodGlyph(){
|
||||||
|
return glyph != null && !glyph.curse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasCurseGlyph(){
|
||||||
|
return glyph != null && glyph.curse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -127,28 +127,6 @@ public class Ring extends KindofMisc {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Item upgrade() {
|
|
||||||
|
|
||||||
if (cursed && cursedKnown) {
|
|
||||||
GLog.p( Messages.get(Item.class, "weaken_curse") );
|
|
||||||
Dungeon.hero.sprite.emitter().start( ShadowParticle.UP, 0.05f, 10 );
|
|
||||||
}
|
|
||||||
|
|
||||||
super.upgrade();
|
|
||||||
|
|
||||||
if (buff != null) {
|
|
||||||
|
|
||||||
Char owner = buff.target;
|
|
||||||
buff.detach();
|
|
||||||
if ((buff = buff()) != null) {
|
|
||||||
buff.attachTo( owner );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isKnown() {
|
public boolean isKnown() {
|
||||||
return handler.isKnown( this );
|
return handler.isKnown( this );
|
||||||
}
|
}
|
||||||
|
@ -263,11 +241,6 @@ public class Ring extends KindofMisc {
|
||||||
|
|
||||||
public class RingBuff extends Buff {
|
public class RingBuff extends Buff {
|
||||||
|
|
||||||
public int level;
|
|
||||||
public RingBuff() {
|
|
||||||
level = Ring.this.level();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean attachTo( Char target ) {
|
public boolean attachTo( Char target ) {
|
||||||
|
|
||||||
|
@ -284,7 +257,6 @@ public class Ring extends KindofMisc {
|
||||||
public boolean act() {
|
public boolean act() {
|
||||||
|
|
||||||
if (!isIdentified() && --ticksToKnow <= 0) {
|
if (!isIdentified() && --ticksToKnow <= 0) {
|
||||||
String gemName = name();
|
|
||||||
identify();
|
identify();
|
||||||
GLog.w( Messages.get(Ring.class, "identify", Ring.this.toString()) );
|
GLog.w( Messages.get(Ring.class, "identify", Ring.this.toString()) );
|
||||||
Badges.validateItemLevelAquired( Ring.this );
|
Badges.validateItemLevelAquired( Ring.this );
|
||||||
|
@ -294,5 +266,9 @@ public class Ring extends KindofMisc {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int level(){
|
||||||
|
return Ring.this.level();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class ScrollOfRemoveCurse extends InventoryScroll {
|
||||||
}
|
}
|
||||||
if (item instanceof Weapon){
|
if (item instanceof Weapon){
|
||||||
Weapon w = (Weapon) item;
|
Weapon w = (Weapon) item;
|
||||||
if (w.enchantment != null && w.enchantment.curse()){
|
if (w.hasCurseEnchant()){
|
||||||
w.enchant(null);
|
w.enchant(null);
|
||||||
w.cursed = false;
|
w.cursed = false;
|
||||||
procced = true;
|
procced = true;
|
||||||
|
@ -76,7 +76,7 @@ public class ScrollOfRemoveCurse extends InventoryScroll {
|
||||||
}
|
}
|
||||||
if (item instanceof Armor){
|
if (item instanceof Armor){
|
||||||
Armor a = (Armor) item;
|
Armor a = (Armor) item;
|
||||||
if (a.glyph != null && a.glyph.curse()){
|
if (a.hasCurseGlyph()){
|
||||||
a.inscribe(null);
|
a.inscribe(null);
|
||||||
a.cursed = false;
|
a.cursed = false;
|
||||||
procced = true;
|
procced = true;
|
||||||
|
|
|
@ -21,9 +21,15 @@
|
||||||
package com.shatteredpixel.shatteredpixeldungeon.items.scrolls;
|
package com.shatteredpixel.shatteredpixeldungeon.items.scrolls;
|
||||||
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.Badges;
|
import com.shatteredpixel.shatteredpixeldungeon.Badges;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ShadowParticle;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
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.messages.Messages;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
|
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
|
||||||
|
@ -40,10 +46,69 @@ public class ScrollOfUpgrade extends InventoryScroll {
|
||||||
@Override
|
@Override
|
||||||
protected void onItemSelected( Item item ) {
|
protected void onItemSelected( Item item ) {
|
||||||
|
|
||||||
item.upgrade();
|
|
||||||
|
|
||||||
upgrade( curUser );
|
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 );
|
Badges.validateItemLevelAquired( item );
|
||||||
}
|
}
|
||||||
|
@ -52,4 +117,14 @@ public class ScrollOfUpgrade extends InventoryScroll {
|
||||||
hero.sprite.emitter().start( Speck.factory( Speck.UP ), 0.2f, 3 );
|
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 );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -186,17 +186,11 @@ public abstract class Wand extends Item {
|
||||||
@Override
|
@Override
|
||||||
public Item upgrade() {
|
public Item upgrade() {
|
||||||
|
|
||||||
boolean cursedPreUpgrade = cursed;
|
|
||||||
|
|
||||||
super.upgrade();
|
super.upgrade();
|
||||||
|
|
||||||
if (cursedPreUpgrade && Random.Float() > Math.pow(0.9, level())){
|
if (Random.Float() > Math.pow(0.9, level()))
|
||||||
GLog.p( Messages.get(Item.class, "remove_curse") );
|
cursed = false;
|
||||||
Dungeon.hero.sprite.emitter().start( ShadowParticle.UP, 0.05f, 10 );
|
|
||||||
} else {
|
|
||||||
cursed = cursedPreUpgrade;
|
|
||||||
}
|
|
||||||
|
|
||||||
updateLevel();
|
updateLevel();
|
||||||
curCharges = Math.min( curCharges + 1, maxCharges );
|
curCharges = Math.min( curCharges + 1, maxCharges );
|
||||||
updateQuickslot();
|
updateQuickslot();
|
||||||
|
|
|
@ -205,25 +205,11 @@ abstract public class Weapon extends KindOfWeapon {
|
||||||
public abstract int STRReq(int lvl);
|
public abstract int STRReq(int lvl);
|
||||||
|
|
||||||
public Item upgrade( boolean enchant ) {
|
public Item upgrade( boolean enchant ) {
|
||||||
if (enchantment != null) {
|
|
||||||
if (enchant && enchantment.curse()){
|
if (enchant && (enchantment == null || enchantment.curse())){
|
||||||
enchant( Enchantment.random() );
|
enchant( Enchantment.random() );
|
||||||
} else if (!enchant && Random.Float() > Math.pow(0.9, level())) {
|
} else if (!enchant && Random.Float() > Math.pow(0.9, level())){
|
||||||
if (!enchantment.curse())
|
enchant(null);
|
||||||
GLog.w( Messages.get(Weapon.class, "incompatible") );
|
|
||||||
else {
|
|
||||||
GLog.p(Messages.get(Item.class, "remove_curse"));
|
|
||||||
Dungeon.hero.sprite.emitter().start( ShadowParticle.UP, 0.05f, 10 );
|
|
||||||
}
|
|
||||||
enchant( null );
|
|
||||||
} else if (!enchant && enchantment.curse() && cursed && cursedKnown){
|
|
||||||
GLog.p( Messages.get(Item.class, "weaken_curse") );
|
|
||||||
Dungeon.hero.sprite.emitter().start( ShadowParticle.UP, 0.05f, 10 );
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (enchant) {
|
|
||||||
enchant( );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.upgrade();
|
return super.upgrade();
|
||||||
|
@ -275,8 +261,15 @@ abstract public class Weapon extends KindOfWeapon {
|
||||||
return enchant( ench );
|
return enchant( ench );
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEnchanted() {
|
public boolean hasEnchant(Class<?extends Enchantment> type) {
|
||||||
return enchantment != null;
|
return enchantment != null && enchantment.getClass() == type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasGoodEnchant(){
|
||||||
|
return enchantment != null && !enchantment.curse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasCurseEnchant(){ return enchantment != null && enchantment.curse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -620,7 +620,8 @@ items.scrolls.scrollofterror.desc=A flash of red light will overwhelm all creatu
|
||||||
|
|
||||||
items.scrolls.scrollofupgrade.name=scroll of upgrade
|
items.scrolls.scrollofupgrade.name=scroll of upgrade
|
||||||
items.scrolls.scrollofupgrade.inv_title=Select an item to upgrade
|
items.scrolls.scrollofupgrade.inv_title=Select an item to upgrade
|
||||||
items.scrolls.scrollofupgrade.looks_better=Your %s certainly looks better now.
|
items.scrollofupgrade.weaken_curse=The scroll of upgrade weakens the curse on your item.
|
||||||
|
items.scrollofupgrade.remove_curse=The scroll of upgrade cleanses the curse on your item!
|
||||||
items.scrolls.scrollofupgrade.desc=This scroll will upgrade a single item, improving its quality. A wand will increase in power and number of charges, weapons and armor will deal and block more damage, and the effects of rings will intensify. This scroll is even able to sometimes dispel curse effects, though it is not as potent as a scroll of remove curse.
|
items.scrolls.scrollofupgrade.desc=This scroll will upgrade a single item, improving its quality. A wand will increase in power and number of charges, weapons and armor will deal and block more damage, and the effects of rings will intensify. This scroll is even able to sometimes dispel curse effects, though it is not as potent as a scroll of remove curse.
|
||||||
|
|
||||||
|
|
||||||
|
@ -997,8 +998,6 @@ items.item.ac_drop=DROP
|
||||||
items.item.ac_throw=THROW
|
items.item.ac_throw=THROW
|
||||||
items.item.rankings_desc=Killed by: %s
|
items.item.rankings_desc=Killed by: %s
|
||||||
items.item.curse=curse
|
items.item.curse=curse
|
||||||
items.item.weaken_curse=The curse on your item has been weakened.
|
|
||||||
items.item.remove_curse=The curse on your item has been erased!
|
|
||||||
|
|
||||||
items.kindofmisc.unequip_title=Unequip one item
|
items.kindofmisc.unequip_title=Unequip one item
|
||||||
items.kindofmisc.unequip_message=You can only wear two misc items at a time.
|
items.kindofmisc.unequip_message=You can only wear two misc items at a time.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user