v0.4.0: refactor to ring logic
This commit is contained in:
committed by
Evan Debenham
parent
912fd447d0
commit
16a3e5932b
@@ -239,6 +239,14 @@ public class Ring extends KindofMisc {
|
||||
}
|
||||
}
|
||||
|
||||
public static int getBonus(Char target, Class<?extends RingBuff> type){
|
||||
int bonus = 0;
|
||||
for (RingBuff buff : target.buffs(type)) {
|
||||
bonus += buff.level();
|
||||
}
|
||||
return bonus;
|
||||
}
|
||||
|
||||
public class RingBuff extends Buff {
|
||||
|
||||
@Override
|
||||
@@ -270,5 +278,6 @@ public class Ring extends KindofMisc {
|
||||
public int level(){
|
||||
return Ring.this.level();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class RingOfElements extends Ring {
|
||||
public class Resistance extends RingBuff {
|
||||
|
||||
public HashSet<Class<?>> resistances() {
|
||||
if (Random.Int( level + 2 ) >= 2) {
|
||||
if (Random.Int( level() + 2 ) >= 2) {
|
||||
return FULL;
|
||||
} else {
|
||||
return EMPTY;
|
||||
@@ -62,7 +62,7 @@ public class RingOfElements extends Ring {
|
||||
}
|
||||
|
||||
public float durationFactor() {
|
||||
return level < 0 ? 1 : (1 + 0.5f * level) / (1 + level);
|
||||
return level() < 0 ? 1 : (1 + 0.5f * level()) / (1 + level());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,13 +34,11 @@ public class RingOfEvasion extends Ring {
|
||||
//yup, the only ring in the game with logic inside of its class
|
||||
public class Evasion extends RingBuff {
|
||||
public int effectiveLevel;
|
||||
private int pos;
|
||||
|
||||
@Override
|
||||
public boolean attachTo( Char target ) {
|
||||
|
||||
pos = target.pos;
|
||||
effectiveLevel = Math.min(0, level());
|
||||
effectiveLevel = Math.min(0, RingOfEvasion.this.level());
|
||||
return super.attachTo(target);
|
||||
}
|
||||
|
||||
@@ -56,15 +54,20 @@ public class RingOfEvasion extends Ring {
|
||||
}
|
||||
}
|
||||
|
||||
if (level() < 1){
|
||||
effectiveLevel = level();
|
||||
if (RingOfEvasion.this.level() < 1){
|
||||
effectiveLevel = RingOfEvasion.this.level();
|
||||
} else if (seen) {
|
||||
effectiveLevel = Math.max(effectiveLevel - 1, 0);
|
||||
} else {
|
||||
effectiveLevel = Math.min(effectiveLevel + 1, level());
|
||||
effectiveLevel = Math.min(effectiveLevel + 1, RingOfEvasion.this.level());
|
||||
}
|
||||
|
||||
return super.act();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int level() {
|
||||
return effectiveLevel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
package com.shatteredpixel.shatteredpixeldungeon.items.rings;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.watabou.utils.Random;
|
||||
@@ -38,10 +37,7 @@ public class RingOfForce extends Ring {
|
||||
}
|
||||
|
||||
public static int damageRoll( Hero hero ){
|
||||
int level = 0;
|
||||
for (Buff buff : hero.buffs( RingOfForce.Force.class )) {
|
||||
level += ((RingOfForce.Force)buff).level;
|
||||
}
|
||||
int level = getBonus(hero, Force.class);
|
||||
float tier = tier(hero.STR());
|
||||
return Random.NormalIntRange(min(level, tier), max(level, tier));
|
||||
}
|
||||
|
||||
@@ -21,8 +21,54 @@
|
||||
package com.shatteredpixel.shatteredpixeldungeon.items.rings;
|
||||
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
|
||||
public class RingOfMight extends Ring {
|
||||
|
||||
@Override
|
||||
public boolean doEquip(Hero hero) {
|
||||
if (super.doEquip(hero)){
|
||||
hero.HT += level()*5;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doUnequip(Hero hero, boolean collect, boolean single) {
|
||||
|
||||
if (super.doUnequip(hero, collect, single)){
|
||||
hero.HT -= level()*5;
|
||||
hero.HP = Math.min(hero.HP, hero.HT);
|
||||
return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item upgrade() {
|
||||
if (buff != null && buff.target != null){
|
||||
buff.target.HT += 5;
|
||||
}
|
||||
return super.upgrade();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void level(int value) {
|
||||
if (buff != null && buff.target != null){
|
||||
buff.target.HT -= level()*5;
|
||||
}
|
||||
super.level(value);
|
||||
if (buff != null && buff.target != null){
|
||||
buff.target.HT += level()*5;
|
||||
buff.target.HP = Math.min(buff.target.HP, buff.target.HT);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RingBuff buff( ) {
|
||||
return new Might();
|
||||
|
||||
@@ -147,10 +147,7 @@ abstract public class Weapon extends KindOfWeapon {
|
||||
float ACC = this.ACC;
|
||||
|
||||
if (this instanceof MissileWeapon) {
|
||||
int bonus = 0;
|
||||
for (Buff buff : hero.buffs(RingOfSharpshooting.Aim.class)) {
|
||||
bonus += ((RingOfSharpshooting.Aim)buff).level;
|
||||
}
|
||||
int bonus = RingOfSharpshooting.getBonus(hero, RingOfSharpshooting.Aim.class);
|
||||
ACC *= (float)(Math.pow(1.1, bonus));
|
||||
}
|
||||
|
||||
@@ -167,10 +164,7 @@ abstract public class Weapon extends KindOfWeapon {
|
||||
|
||||
float DLY = imbue.delayFactor(this.DLY);
|
||||
|
||||
int bonus = 0;
|
||||
for (Buff buff : hero.buffs(RingOfFuror.Furor.class)) {
|
||||
bonus += ((RingOfFuror.Furor)buff).level;
|
||||
}
|
||||
int bonus = RingOfFuror.getBonus(hero, RingOfFuror.Furor.class);
|
||||
|
||||
DLY = (float)(0.25 + (DLY - 0.25)*Math.pow(0.8, bonus));
|
||||
|
||||
|
||||
+2
-7
@@ -79,10 +79,8 @@ abstract public class MissileWeapon extends Weapon {
|
||||
if (!curUser.shoot( enemy, this )) {
|
||||
miss( cell );
|
||||
} else if (!(this instanceof Boomerang)){
|
||||
int bonus = 0;
|
||||
|
||||
for (Buff buff : curUser.buffs(RingOfSharpshooting.Aim.class))
|
||||
bonus += ((RingOfSharpshooting.Aim)buff).level;
|
||||
int bonus = RingOfSharpshooting.getBonus(curUser, RingOfSharpshooting.Aim.class);
|
||||
|
||||
if (curUser.heroClass == HeroClass.HUNTRESS && enemy.buff(PinCushion.class) == null)
|
||||
bonus += 3;
|
||||
@@ -99,10 +97,7 @@ abstract public class MissileWeapon extends Weapon {
|
||||
}
|
||||
|
||||
protected void miss( int cell ) {
|
||||
int bonus = 0;
|
||||
for (Buff buff : curUser.buffs(RingOfSharpshooting.Aim.class)) {
|
||||
bonus += ((RingOfSharpshooting.Aim)buff).level;
|
||||
}
|
||||
int bonus = RingOfSharpshooting.getBonus(curUser, RingOfSharpshooting.Aim.class);
|
||||
|
||||
//degraded ring of sharpshooting will even make missed shots break.
|
||||
if (Random.Float() < Math.pow(0.6, -bonus))
|
||||
|
||||
Reference in New Issue
Block a user