v0.4.0: refactoring for enchant/glyph referencing
This commit is contained in:
parent
4c8bcade38
commit
912fd447d0
|
@ -83,8 +83,7 @@ public class Burning extends Buff implements Hero.Doom {
|
|||
|
||||
Hero hero = (Hero)target;
|
||||
|
||||
if (hero.belongings.armor != null && hero.belongings.armor.glyph != null
|
||||
&& hero.belongings.armor.glyph instanceof Brimstone){
|
||||
if (hero.belongings.armor != null && hero.belongings.armor.hasGlyph(Brimstone.class)){
|
||||
|
||||
int heal = hero.belongings.armor.level()/2;
|
||||
if (heal > 0 && hero.HP < hero.HT) {
|
||||
|
|
|
@ -295,8 +295,7 @@ public class Hero extends Char {
|
|||
bonus = 0;
|
||||
if (heroClass == HeroClass.ROGUE) bonus += -aEnc;
|
||||
|
||||
if (belongings.armor != null && belongings.armor.glyph != null
|
||||
&& belongings.armor.glyph instanceof Swiftness)
|
||||
if (belongings.armor != null && belongings.armor.hasGlyph(Swiftness.class))
|
||||
bonus += 5 + belongings.armor.level()*1.5f;
|
||||
|
||||
return Math.round((defenseSkill + bonus) * evasion);
|
||||
|
@ -355,11 +354,11 @@ public class Hero extends Char {
|
|||
|
||||
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());
|
||||
} 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());
|
||||
}
|
||||
}
|
||||
|
@ -958,8 +957,8 @@ public class Hero extends Char {
|
|||
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
|
||||
if (belongings.armor != null && belongings.armor.glyph != null
|
||||
&& belongings.armor.glyph instanceof AntiMagic && RingOfElements.FULL.contains(src.getClass())){
|
||||
if (belongings.armor != null && belongings.armor.hasGlyph(AntiMagic.class)
|
||||
&& RingOfElements.FULL.contains(src.getClass())){
|
||||
dmg -= Random.IntRange(0, belongings.armor.DR()/2);
|
||||
}
|
||||
|
||||
|
@ -1235,8 +1234,7 @@ public class Hero extends Char {
|
|||
for (Buff buff : buffs( RingOfEvasion.Evasion.class )) {
|
||||
stealth += ((RingOfEvasion.Evasion)buff).effectiveLevel;
|
||||
}
|
||||
if (belongings.armor != null && belongings.armor.glyph != null
|
||||
&& belongings.armor.glyph instanceof Obfuscation){
|
||||
if (belongings.armor != null && belongings.armor.hasGlyph(Obfuscation.class)){
|
||||
stealth += belongings.armor.level();
|
||||
}
|
||||
return stealth;
|
||||
|
|
|
@ -83,7 +83,7 @@ public class Stylus extends Item {
|
|||
if (!armor.isIdentified() ){
|
||||
GLog.w( Messages.get(this, "identify"));
|
||||
return;
|
||||
} else if (armor.cursed || (armor.glyph != null && armor.glyph.curse())){
|
||||
} else if (armor.cursed || armor.hasCurseGlyph()){
|
||||
GLog.w( Messages.get(this, "cursed"));
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -355,10 +355,10 @@ public class Armor extends EquipableItem {
|
|||
@Override
|
||||
public int price() {
|
||||
int price = 10 * (1 << (tier - 1));
|
||||
if (glyph != null) {
|
||||
if (hasCurseGlyph()) {
|
||||
price *= 1.5;
|
||||
}
|
||||
if (cursed && cursedKnown) {
|
||||
if (cursedKnown && (cursed || hasCurseGlyph())) {
|
||||
price /= 2;
|
||||
}
|
||||
if (levelKnown) {
|
||||
|
|
|
@ -40,7 +40,7 @@ public class RingOfEvasion extends Ring {
|
|||
public boolean attachTo( Char target ) {
|
||||
|
||||
pos = target.pos;
|
||||
effectiveLevel = Math.min(0, level);
|
||||
effectiveLevel = Math.min(0, level());
|
||||
return super.attachTo(target);
|
||||
}
|
||||
|
||||
|
@ -56,12 +56,12 @@ public class RingOfEvasion extends Ring {
|
|||
}
|
||||
}
|
||||
|
||||
if (level < 1){
|
||||
effectiveLevel = level;
|
||||
if (level() < 1){
|
||||
effectiveLevel = level();
|
||||
} else if (seen) {
|
||||
effectiveLevel = Math.max(effectiveLevel - 1, 0);
|
||||
} else {
|
||||
effectiveLevel = Math.min(effectiveLevel + 1, level);
|
||||
effectiveLevel = Math.min(effectiveLevel + 1, level());
|
||||
}
|
||||
|
||||
return super.act();
|
||||
|
|
|
@ -75,7 +75,7 @@ public class ScrollOfUpgrade extends InventoryScroll {
|
|||
|
||||
a.upgrade();
|
||||
|
||||
if (hadCursedGlyph && a.glyph == null){
|
||||
if (hadCursedGlyph && !a.hasCurseGlyph()){
|
||||
removeCurse( Dungeon.hero );
|
||||
} else if (wasCursed && !a.cursed){
|
||||
weakenCurse( Dungeon.hero );
|
||||
|
|
|
@ -141,7 +141,7 @@ abstract public class Weapon extends KindOfWeapon {
|
|||
|
||||
int encumbrance = STRReq() - hero.STR();
|
||||
|
||||
if (enchantment instanceof Wayward)
|
||||
if (hasEnchant(Wayward.class))
|
||||
encumbrance = Math.max(3, encumbrance+3);
|
||||
|
||||
float ACC = this.ACC;
|
||||
|
@ -180,7 +180,7 @@ abstract public class Weapon extends KindOfWeapon {
|
|||
|
||||
@Override
|
||||
public int reachFactor(Hero hero) {
|
||||
return enchantment instanceof Projecting ? RCH+1 : RCH;
|
||||
return hasEnchant(Projecting.class) ? RCH+1 : RCH;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -106,10 +106,10 @@ public class MeleeWeapon extends Weapon {
|
|||
@Override
|
||||
public int price() {
|
||||
int price = 20 * (1 << (tier - 1));
|
||||
if (enchantment != null) {
|
||||
if (hasGoodEnchant()) {
|
||||
price *= 1.5;
|
||||
}
|
||||
if (cursed && cursedKnown) {
|
||||
if (cursedKnown && (cursed || hasCurseEnchant())) {
|
||||
price /= 2;
|
||||
}
|
||||
if (levelKnown) {
|
||||
|
|
|
@ -58,7 +58,7 @@ abstract public class MissileWeapon extends Weapon {
|
|||
protected int throwPos(Hero user, int dst) {
|
||||
int defaultPos = super.throwPos(user, 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 );
|
||||
if (ProjectingTrajectory.dist <= 4) return ProjectingTrajectory.collisionPos;
|
||||
else return super.throwPos(user, dst);
|
||||
|
|
|
@ -96,8 +96,7 @@ public class HighGrass {
|
|||
}
|
||||
|
||||
//Camouflage
|
||||
if (hero.belongings.armor != null && hero.belongings.armor.glyph != null
|
||||
&& hero.belongings.armor.glyph instanceof Camouflage){
|
||||
if (hero.belongings.armor != null && hero.belongings.armor.hasGlyph(Camouflage.class)){
|
||||
Buff.affect(hero, Camouflage.Camo.class).set(3 + hero.belongings.armor.level());
|
||||
leaves += 4;
|
||||
}
|
||||
|
|
|
@ -386,11 +386,11 @@ public class WndBag extends WndTabbed {
|
|||
if (!active && mode == Mode.UNIDED_OR_CURSED){
|
||||
if (item instanceof Weapon){
|
||||
Weapon w = (Weapon) item;
|
||||
enable(w.enchantment != null && w.enchantment.curse());
|
||||
enable(w.hasCurseEnchant());
|
||||
}
|
||||
if (item instanceof Armor){
|
||||
Armor a = (Armor) item;
|
||||
enable(a.glyph != null && a.glyph.curse());
|
||||
enable(a.hasCurseGlyph());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user