v0.2.3: artifact refactoring, pulled some display logic into superclass

This commit is contained in:
Evan Debenham
2014-12-10 13:58:20 -05:00
parent 7940bc78ec
commit e359b5f9ef
12 changed files with 73 additions and 103 deletions
@@ -6,7 +6,6 @@ import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.shatteredpixel.shatteredpixeldungeon.ui.QuickSlot;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
import com.watabou.utils.Random;
/**
@@ -17,22 +16,15 @@ public class CapeOfThorns extends Artifact {
{
name = "Cape of Thorns";
image = ItemSpriteSheet.ARTIFACT_CAPE;
level = 0;
levelCap = 10;
charge = 0;
chargeCap = 100;
cooldown = 0;
defaultAction = "NONE";
//partialcharge is unused
}
private int timer = 0;
@Override
public String status() {
if (timer == 0)
return Utils.format("%d%%", charge);
else
return Utils.format("%d", timer);
}
@Override
@@ -47,7 +39,7 @@ public class CapeOfThorns extends Artifact {
"perhaps it has some of the DM-300's power?";
if (isEquipped( Dungeon.hero )) {
desc += "\n\n";
if (timer == 0)
if (cooldown == 0)
desc += "The cape feels reassuringly heavy on your shoulders. You're not sure if it will directly " +
"help you in a fight, but it seems to be gaining energy from the physical damage you take.";
else
@@ -58,21 +50,13 @@ public class CapeOfThorns extends Artifact {
return desc;
}
@Override
public String toString(){
if (level > 0)
return Utils.format("%s+%d %d%%", name, level, charge);
else
return Utils.format("%s %d%%", name, charge);
}
public class Thorns extends ArtifactBuff{
@Override
public boolean act(){
if (timer > 0) {
timer--;
if (timer == 0) {
if (cooldown > 0) {
cooldown--;
if (cooldown == 0) {
BuffIndicator.refreshHero();
GLog.w("Your Cape becomes inert again.");
}
@@ -83,17 +67,17 @@ public class CapeOfThorns extends Artifact {
}
public int proc(int damage, Char attacker){
if (timer == 0){
if (cooldown == 0){
charge += damage*(0.5+level*0.05);
if (charge >= chargeCap){
charge = 0;
timer = 10+level;
cooldown = 10+level;
GLog.p("Your Cape begins radiating energy, you feel protected!");
BuffIndicator.refreshHero();
}
}
if (timer != 0){
if (cooldown != 0){
int deflected = Random.NormalIntRange(0, damage);
damage -= deflected;
@@ -119,7 +103,7 @@ public class CapeOfThorns extends Artifact {
@Override
public int icon() {
if (timer == 0)
if (cooldown == 0)
return BuffIndicator.NONE;
else
return BuffIndicator.THORNS;
@@ -127,7 +111,7 @@ public class CapeOfThorns extends Artifact {
@Override
public void detach(){
timer = 0;
cooldown = 0;
charge = 0;
super.detach();
}