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
@@ -43,6 +43,8 @@ public class Artifact extends KindofMisc {
//the maximum charge, varies per artifact, not all artifacts use this.
protected int chargeCap = 0;
//used by some artifacts to keep track of duration of effects or cooldowns to use.
protected int cooldown = 0;
public Artifact(){
@@ -179,6 +181,30 @@ public class Artifact extends KindofMisc {
}
}
@Override
public String status() {
//display the current cooldown
if (cooldown != 0)
return Utils.format( "%d", cooldown );
//display as percent
if (chargeCap == 100)
return Utils.format( "%d%%", charge );
//display as #/#
if (chargeCap > 0)
return Utils.format( "%d/%d", charge, chargeCap );
//if there's no cap -
//- but there is charge anyway, display that charge
if (charge != 0)
return Utils.format( "%d", charge );
//otherwise, if there's no charge, return null.
return null;
}
@Override
public Item random() {
if (Random.Float() < 0.3f) {