v0.4.0: refactoring for enchant/glyph referencing

This commit is contained in:
Evan Debenham 2016-06-15 03:03:27 -04:00 committed by Evan Debenham
parent 4c8bcade38
commit 912fd447d0
11 changed files with 24 additions and 28 deletions

View File

@ -83,8 +83,7 @@ public class Burning extends Buff implements Hero.Doom {
Hero hero = (Hero)target; Hero hero = (Hero)target;
if (hero.belongings.armor != null && hero.belongings.armor.glyph != null if (hero.belongings.armor != null && hero.belongings.armor.hasGlyph(Brimstone.class)){
&& hero.belongings.armor.glyph instanceof Brimstone){
int heal = hero.belongings.armor.level()/2; int heal = hero.belongings.armor.level()/2;
if (heal > 0 && hero.HP < hero.HT) { if (heal > 0 && hero.HP < hero.HT) {

View File

@ -295,8 +295,7 @@ public class Hero extends Char {
bonus = 0; bonus = 0;
if (heroClass == HeroClass.ROGUE) bonus += -aEnc; if (heroClass == HeroClass.ROGUE) bonus += -aEnc;
if (belongings.armor != null && belongings.armor.glyph != null if (belongings.armor != null && belongings.armor.hasGlyph(Swiftness.class))
&& belongings.armor.glyph instanceof Swiftness)
bonus += 5 + belongings.armor.level()*1.5f; bonus += 5 + belongings.armor.level()*1.5f;
return Math.round((defenseSkill + bonus) * evasion); return Math.round((defenseSkill + bonus) * evasion);
@ -355,11 +354,11 @@ public class Hero extends Char {
Armor armor = belongings.armor; Armor armor = belongings.armor;
if (armor != null && armor.glyph != null){ if (armor != null){
if (armor.glyph instanceof Swiftness) { if (armor.hasGlyph(Swiftness.class)) {
speed *= (1.1f + 0.01f * belongings.armor.level()); speed *= (1.1f + 0.01f * belongings.armor.level());
} else if (armor.glyph instanceof Flow && Level.water[pos]){ } else if (armor.hasGlyph(Flow.class) && Level.water[pos]){
speed *= (1.5f + 0.05f * belongings.armor.level()); speed *= (1.5f + 0.05f * belongings.armor.level());
} }
} }
@ -958,8 +957,8 @@ public class Hero extends Char {
dmg = (int)Math.ceil((float)dmg * Math.pow(0.9, tenacity*((float)(HT - HP)/HT))); dmg = (int)Math.ceil((float)dmg * Math.pow(0.9, tenacity*((float)(HT - HP)/HT)));
//TODO improve this when I have proper damage source logic //TODO improve this when I have proper damage source logic
if (belongings.armor != null && belongings.armor.glyph != null if (belongings.armor != null && belongings.armor.hasGlyph(AntiMagic.class)
&& belongings.armor.glyph instanceof AntiMagic && RingOfElements.FULL.contains(src.getClass())){ && RingOfElements.FULL.contains(src.getClass())){
dmg -= Random.IntRange(0, belongings.armor.DR()/2); dmg -= Random.IntRange(0, belongings.armor.DR()/2);
} }
@ -1235,8 +1234,7 @@ public class Hero extends Char {
for (Buff buff : buffs( RingOfEvasion.Evasion.class )) { for (Buff buff : buffs( RingOfEvasion.Evasion.class )) {
stealth += ((RingOfEvasion.Evasion)buff).effectiveLevel; stealth += ((RingOfEvasion.Evasion)buff).effectiveLevel;
} }
if (belongings.armor != null && belongings.armor.glyph != null if (belongings.armor != null && belongings.armor.hasGlyph(Obfuscation.class)){
&& belongings.armor.glyph instanceof Obfuscation){
stealth += belongings.armor.level(); stealth += belongings.armor.level();
} }
return stealth; return stealth;

View File

@ -83,7 +83,7 @@ public class Stylus extends Item {
if (!armor.isIdentified() ){ if (!armor.isIdentified() ){
GLog.w( Messages.get(this, "identify")); GLog.w( Messages.get(this, "identify"));
return; return;
} else if (armor.cursed || (armor.glyph != null && armor.glyph.curse())){ } else if (armor.cursed || armor.hasCurseGlyph()){
GLog.w( Messages.get(this, "cursed")); GLog.w( Messages.get(this, "cursed"));
return; return;
} }

View File

@ -355,10 +355,10 @@ public class Armor extends EquipableItem {
@Override @Override
public int price() { public int price() {
int price = 10 * (1 << (tier - 1)); int price = 10 * (1 << (tier - 1));
if (glyph != null) { if (hasCurseGlyph()) {
price *= 1.5; price *= 1.5;
} }
if (cursed && cursedKnown) { if (cursedKnown && (cursed || hasCurseGlyph())) {
price /= 2; price /= 2;
} }
if (levelKnown) { if (levelKnown) {

View File

@ -40,7 +40,7 @@ public class RingOfEvasion extends Ring {
public boolean attachTo( Char target ) { public boolean attachTo( Char target ) {
pos = target.pos; pos = target.pos;
effectiveLevel = Math.min(0, level); effectiveLevel = Math.min(0, level());
return super.attachTo(target); return super.attachTo(target);
} }
@ -56,12 +56,12 @@ public class RingOfEvasion extends Ring {
} }
} }
if (level < 1){ if (level() < 1){
effectiveLevel = level; effectiveLevel = level();
} else if (seen) { } else if (seen) {
effectiveLevel = Math.max(effectiveLevel - 1, 0); effectiveLevel = Math.max(effectiveLevel - 1, 0);
} else { } else {
effectiveLevel = Math.min(effectiveLevel + 1, level); effectiveLevel = Math.min(effectiveLevel + 1, level());
} }
return super.act(); return super.act();

View File

@ -75,7 +75,7 @@ public class ScrollOfUpgrade extends InventoryScroll {
a.upgrade(); a.upgrade();
if (hadCursedGlyph && a.glyph == null){ if (hadCursedGlyph && !a.hasCurseGlyph()){
removeCurse( Dungeon.hero ); removeCurse( Dungeon.hero );
} else if (wasCursed && !a.cursed){ } else if (wasCursed && !a.cursed){
weakenCurse( Dungeon.hero ); weakenCurse( Dungeon.hero );

View File

@ -141,7 +141,7 @@ abstract public class Weapon extends KindOfWeapon {
int encumbrance = STRReq() - hero.STR(); int encumbrance = STRReq() - hero.STR();
if (enchantment instanceof Wayward) if (hasEnchant(Wayward.class))
encumbrance = Math.max(3, encumbrance+3); encumbrance = Math.max(3, encumbrance+3);
float ACC = this.ACC; float ACC = this.ACC;
@ -180,7 +180,7 @@ abstract public class Weapon extends KindOfWeapon {
@Override @Override
public int reachFactor(Hero hero) { public int reachFactor(Hero hero) {
return enchantment instanceof Projecting ? RCH+1 : RCH; return hasEnchant(Projecting.class) ? RCH+1 : RCH;
} }
@Override @Override

View File

@ -106,10 +106,10 @@ public class MeleeWeapon extends Weapon {
@Override @Override
public int price() { public int price() {
int price = 20 * (1 << (tier - 1)); int price = 20 * (1 << (tier - 1));
if (enchantment != null) { if (hasGoodEnchant()) {
price *= 1.5; price *= 1.5;
} }
if (cursed && cursedKnown) { if (cursedKnown && (cursed || hasCurseEnchant())) {
price /= 2; price /= 2;
} }
if (levelKnown) { if (levelKnown) {

View File

@ -58,7 +58,7 @@ abstract public class MissileWeapon extends Weapon {
protected int throwPos(Hero user, int dst) { protected int throwPos(Hero user, int dst) {
int defaultPos = super.throwPos(user, dst); int defaultPos = super.throwPos(user, dst);
if (defaultPos == dst) return dst; if (defaultPos == dst) return dst;
else if (enchantment instanceof Projecting){ else if (hasEnchant(Projecting.class)){
Ballistica ProjectingTrajectory = new Ballistica( user.pos, dst, Ballistica.STOP_TARGET ); Ballistica ProjectingTrajectory = new Ballistica( user.pos, dst, Ballistica.STOP_TARGET );
if (ProjectingTrajectory.dist <= 4) return ProjectingTrajectory.collisionPos; if (ProjectingTrajectory.dist <= 4) return ProjectingTrajectory.collisionPos;
else return super.throwPos(user, dst); else return super.throwPos(user, dst);

View File

@ -96,8 +96,7 @@ public class HighGrass {
} }
//Camouflage //Camouflage
if (hero.belongings.armor != null && hero.belongings.armor.glyph != null if (hero.belongings.armor != null && hero.belongings.armor.hasGlyph(Camouflage.class)){
&& hero.belongings.armor.glyph instanceof Camouflage){
Buff.affect(hero, Camouflage.Camo.class).set(3 + hero.belongings.armor.level()); Buff.affect(hero, Camouflage.Camo.class).set(3 + hero.belongings.armor.level());
leaves += 4; leaves += 4;
} }

View File

@ -386,11 +386,11 @@ public class WndBag extends WndTabbed {
if (!active && mode == Mode.UNIDED_OR_CURSED){ if (!active && mode == Mode.UNIDED_OR_CURSED){
if (item instanceof Weapon){ if (item instanceof Weapon){
Weapon w = (Weapon) item; Weapon w = (Weapon) item;
enable(w.enchantment != null && w.enchantment.curse()); enable(w.hasCurseEnchant());
} }
if (item instanceof Armor){ if (item instanceof Armor){
Armor a = (Armor) item; Armor a = (Armor) item;
enable(a.glyph != null && a.glyph.curse()); enable(a.hasCurseGlyph());
} }
} }
} }