V0.2.0: Implemented artifact level display

This commit is contained in:
Evan Debenham 2014-08-30 19:30:35 -04:00
parent 4721a9476c
commit 9034325963
4 changed files with 43 additions and 15 deletions

View File

@ -6,6 +6,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.items.KindofMisc;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
import com.watabou.utils.Bundle;
import java.util.ArrayList;
@ -15,22 +16,34 @@ import java.util.ArrayList;
*/
public class Artifact extends KindofMisc {
{
levelKnown = true;
}
private static final float TIME_TO_EQUIP = 1f;
private static final String TXT_TO_STRING = "%s";
private static final String TXT_TO_STRING_CHARGE = "%s (%d/%d)";
private static final String TXT_TO_STRING_LVL = "%s%+d";
private static final String TXT_TO_STRING_LVL_CHARGE = "%s%+d (%d/%d)";
protected Buff passiveBuff;
protected Buff activeBuff;
//level is used internally to track upgrades to artifacts, size/logic varies per artifact.
//levelCap is the artifact's maximum level
protected int levelCap = 0;
//the current artifact charge
protected int charge = 0;
//the % towards next charge, should roll over at a value of 1 or higher.
//the build towards next charge, usually rolls over at 1.
//better to keep charge as an int and use a separate float than casting.
protected float partialCharge = 0;
//the maximum charge, varies per artifact, not all artifacts use this.
protected int chargeCap = 0;
public Artifact(){
super();
}
@ -111,11 +124,34 @@ public class Artifact extends KindofMisc {
return false;
}
@Override
public int visiblyUpgraded() {
return ((level*10)/levelCap);
}
@Override
public boolean isIdentified() {
return true;
}
@Override
public String toString() {
if (levelKnown && level != 0) {
if (chargeCap > 0) {
return Utils.format( TXT_TO_STRING_LVL_CHARGE, name(), visiblyUpgraded(), charge, chargeCap );
} else {
return Utils.format( TXT_TO_STRING_LVL, name(), visiblyUpgraded() );
}
} else {
if (chargeCap > 0) {
return Utils.format( TXT_TO_STRING_CHARGE, name(), charge, chargeCap );
} else {
return Utils.format( TXT_TO_STRING, name() );
}
}
}
protected ArtifactBuff passiveBuff() {
return null;
}
@ -131,7 +167,6 @@ public class Artifact extends KindofMisc {
bundle.put( "level", level );
bundle.put( "charge", charge );
bundle.put( "partialcharge", partialCharge);
bundle.put( "chargecap", chargeCap);
}
@Override
@ -139,7 +174,6 @@ public class Artifact extends KindofMisc {
level = bundle.getInt("level");
charge = bundle.getInt("charge");
partialCharge = bundle.getFloat("partialcharge");
chargeCap = bundle.getInt("chargecap");
}

View File

@ -20,6 +20,7 @@ public class ChaliceOfBlood extends Artifact {
name = "Chalice of Blood";
image = ItemSpriteSheet.ARTIFACT_CHALICE;
level = 0;
levelCap = 8;
//charge & chargecap are unused
}

View File

@ -2,7 +2,6 @@ package com.shatteredpixel.shatteredpixeldungeon.items.artifacts;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
@ -26,6 +25,7 @@ public class CloakOfShadows extends Artifact {
name = "Cloak of Shadows";
image = ItemSpriteSheet.ARTIFACT_CLOAK;
level = 0;
levelCap = 15;
charge = level+5;
chargeCap = level+5;
defaultAction = AC_STEALTH;
@ -128,11 +128,6 @@ public class CloakOfShadows extends Artifact {
return Utils.format(TXT_CD, cooldown);
}
@Override
public String toString() {
return super.toString() + " (" + Utils.format(TXT_CHARGE, charge, chargeCap) + ")" ;
}
public class cloakRecharge extends ArtifactBuff{
@Override
public boolean act() {
@ -191,7 +186,7 @@ public class CloakOfShadows extends Artifact {
exp += 10 + ((Hero)target).lvl;
//max level is 15 (20 charges)
if (exp >= (level+1)*50 && level < 15) {
if (exp >= (level+1)*50 && level < levelCap) {
level++;
chargeCap++;
exp -= level*50;
@ -226,6 +221,7 @@ public class CloakOfShadows extends Artifact {
@Override
public void storeInBundle( Bundle bundle ) {
super.storeInBundle(bundle);
bundle.put("chargecap", chargeCap);
bundle.put("stealthed", stealthed);
bundle.put("cooldown", cooldown);
bundle.put("exp", exp);
@ -234,6 +230,7 @@ public class CloakOfShadows extends Artifact {
@Override
public void restoreFromBundle( Bundle bundle ) {
super.restoreFromBundle(bundle);
chargeCap = bundle.getInt("chargecap");
stealthed = bundle.getBoolean("stealthed");
cooldown = bundle.getInt("cooldown");
exp = bundle.getInt("exp");

View File

@ -32,6 +32,7 @@ public class HornOfPlenty extends Artifact {
name = "Horn of Plenty";
image = ItemSpriteSheet.ARTIFACT_HORN;
level = 0;
levelCap = 30;
charge = 0;
chargeCap = 10;
}
@ -120,11 +121,6 @@ public class HornOfPlenty extends Artifact {
return Utils.format(TXT_STATUS, charge, chargeCap);
}
@Override
public String toString() {
return super.toString() + " (" + status() + ")" ;
}
public class hornRecharge extends ArtifactBuff{
@Override