v0.2.3: artifact refactoring, pulled some display logic into superclass
This commit is contained in:
parent
7940bc78ec
commit
e359b5f9ef
|
@ -28,8 +28,8 @@ public class AlchemistsToolkit extends Artifact {
|
|||
name = "Alchemists Toolkit";
|
||||
image = ItemSpriteSheet.ARTIFACT_TOOLKIT;
|
||||
|
||||
level = 0;
|
||||
levelCap = 10;
|
||||
//charge, chargecap, partialcharge, and exp are unused.
|
||||
}
|
||||
|
||||
public static final String AC_BREW = "BREW";
|
||||
|
@ -217,7 +217,7 @@ public class AlchemistsToolkit extends Artifact {
|
|||
public boolean tryCook(int count){
|
||||
|
||||
//this logic is handled inside the class with a variable so that it may be stored.
|
||||
//to prevent manipulation where a player could keep trowing in 1-2 seeds until they get lucky.
|
||||
//to prevent manipulation where a player could keep throwing in 1-2 seeds until they get lucky.
|
||||
if (seedsToPotion == 0){
|
||||
if (Random.Int(30) < 10+level){
|
||||
if (Random.Int(30) < level){
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -34,9 +34,9 @@ public class ChaliceOfBlood extends Artifact {
|
|||
{
|
||||
name = "Chalice of Blood";
|
||||
image = ItemSpriteSheet.ARTIFACT_CHALICE1;
|
||||
|
||||
level = 0;
|
||||
levelCap = 10;
|
||||
//charge & chargecap are unused
|
||||
}
|
||||
|
||||
public static final String AC_PRICK = "PRICK";
|
||||
|
|
|
@ -10,7 +10,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.noosa.audio.Sample;
|
||||
import com.watabou.noosa.tweeners.AlphaTweener;
|
||||
import com.watabou.utils.Bundle;
|
||||
|
@ -25,11 +24,17 @@ public class CloakOfShadows extends Artifact {
|
|||
{
|
||||
name = "Cloak of Shadows";
|
||||
image = ItemSpriteSheet.ARTIFACT_CLOAK;
|
||||
|
||||
level = 0;
|
||||
levelCap = 15;
|
||||
charge = level+5;
|
||||
chargeCap = level+5;
|
||||
exp = 0;
|
||||
levelCap = 15;
|
||||
|
||||
charge = level+5;
|
||||
partialCharge = 0;
|
||||
chargeCap = level+5;
|
||||
|
||||
cooldown = 0;
|
||||
|
||||
defaultAction = AC_STEALTH;
|
||||
|
||||
bones = false;
|
||||
|
@ -39,11 +44,6 @@ public class CloakOfShadows extends Artifact {
|
|||
|
||||
public static final String AC_STEALTH = "STEALTH";
|
||||
|
||||
private static final String TXT_CHARGE = "%d/%d";
|
||||
private static final String TXT_CD = "%d";
|
||||
|
||||
private int cooldown = 0;
|
||||
|
||||
@Override
|
||||
public ArrayList<String> actions( Hero hero ) {
|
||||
ArrayList<String> actions = super.actions( hero );
|
||||
|
@ -143,14 +143,6 @@ public class CloakOfShadows extends Artifact {
|
|||
return desc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String status() {
|
||||
if (cooldown == 0)
|
||||
return Utils.format(TXT_CHARGE, charge, chargeCap);
|
||||
else
|
||||
return Utils.format(TXT_CD, cooldown);
|
||||
}
|
||||
|
||||
//Note: cloak needs to bundle chargecap as it is dynamic.
|
||||
private static final String CHARGECAP = "chargecap";
|
||||
private static final String STEALTHED = "stealthed";
|
||||
|
|
|
@ -30,10 +30,13 @@ public class DriedRose extends Artifact {
|
|||
{
|
||||
name = "Dried Rose";
|
||||
image = ItemSpriteSheet.ARTIFACT_ROSE1;
|
||||
|
||||
level = 0;
|
||||
levelCap = 10;
|
||||
|
||||
charge = 100;
|
||||
chargeCap = 100;
|
||||
|
||||
defaultAction = AC_SUMMON;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRecharging
|
|||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
|
||||
|
@ -30,9 +29,12 @@ public class HornOfPlenty extends Artifact {
|
|||
{
|
||||
name = "Horn of Plenty";
|
||||
image = ItemSpriteSheet.ARTIFACT_HORN1;
|
||||
|
||||
level = 0;
|
||||
levelCap = 30;
|
||||
|
||||
charge = 0;
|
||||
partialCharge = 0;
|
||||
chargeCap = 10;
|
||||
|
||||
defaultAction = AC_EAT;
|
||||
|
@ -48,8 +50,6 @@ public class HornOfPlenty extends Artifact {
|
|||
protected String inventoryTitle = "Select a piece of food";
|
||||
protected WndBag.Mode mode = WndBag.Mode.FOOD;
|
||||
|
||||
private static final String TXT_STATUS = "%d/%d";
|
||||
|
||||
@Override
|
||||
public ArrayList<String> actions( Hero hero ) {
|
||||
ArrayList<String> actions = super.actions( hero );
|
||||
|
@ -147,11 +147,6 @@ public class HornOfPlenty extends Artifact {
|
|||
return desc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String status() {
|
||||
return Utils.format(TXT_STATUS, charge, chargeCap);
|
||||
}
|
||||
|
||||
public class hornRecharge extends ArtifactBuff{
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.shatteredpixel.shatteredpixeldungeon.items.artifacts;
|
|||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
/**
|
||||
|
@ -13,22 +12,15 @@ public class MasterThievesArmband extends Artifact {
|
|||
{
|
||||
name = "Master Thieves' Armband";
|
||||
image = ItemSpriteSheet.ARTIFACT_ARMBAND;
|
||||
|
||||
level = 0;
|
||||
levelCap = 10;
|
||||
|
||||
charge = 0;
|
||||
//partialcharge and chargeCap are unused
|
||||
}
|
||||
|
||||
private int exp = 0;
|
||||
|
||||
@Override
|
||||
public String status() {
|
||||
if (charge > 0)
|
||||
return Utils.format("%d", charge);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ArtifactBuff passiveBuff() {
|
||||
return new Thievery();
|
||||
|
|
|
@ -12,7 +12,6 @@ import com.shatteredpixel.shatteredpixeldungeon.plants.Plant;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
|
||||
import com.watabou.noosa.Camera;
|
||||
import com.watabou.utils.Bundle;
|
||||
|
@ -28,10 +27,11 @@ public class SandalsOfNature extends Artifact {
|
|||
{
|
||||
name = "Sandals of Nature";
|
||||
image = ItemSpriteSheet.ARTIFACT_SANDALS;
|
||||
|
||||
level = 0;
|
||||
levelCap = 3;
|
||||
|
||||
charge = 0;
|
||||
//partialcharge, chargeCap and exp are unused
|
||||
|
||||
defaultAction = AC_ROOT;
|
||||
}
|
||||
|
@ -76,14 +76,6 @@ public class SandalsOfNature extends Artifact {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String status() {
|
||||
if (charge > 0)
|
||||
return Utils.format("%d", charge);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ArtifactBuff passiveBuff() {
|
||||
return new Naturalism();
|
||||
|
|
|
@ -11,7 +11,6 @@ import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -24,10 +23,12 @@ public class TalismanOfForesight extends Artifact {
|
|||
{
|
||||
name = "Talisman of Foresight";
|
||||
image = ItemSpriteSheet.ARTIFACT_TALISMAN;
|
||||
|
||||
level = 0;
|
||||
levelCap = 10;
|
||||
charge = 0;
|
||||
exp = 0;
|
||||
levelCap = 10;
|
||||
|
||||
charge = 0;
|
||||
partialCharge = 0;
|
||||
chargeCap = 100;
|
||||
|
||||
|
@ -77,11 +78,6 @@ public class TalismanOfForesight extends Artifact {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String status() {
|
||||
return Utils.format("%d%%", charge);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ArtifactBuff passiveBuff() {
|
||||
return new Foresight();
|
||||
|
|
|
@ -12,7 +12,6 @@ import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.QuickSlot;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
import com.watabou.utils.Bundle;
|
||||
|
@ -32,18 +31,19 @@ public class TimekeepersHourglass extends Artifact {
|
|||
"...";
|
||||
|
||||
{
|
||||
name = "timekeeper's hourglass";
|
||||
name = "Timekeeper's Hourglass";
|
||||
image = ItemSpriteSheet.ARTIFACT_HOURGLASS;
|
||||
|
||||
level = 0;
|
||||
levelCap = 5;
|
||||
|
||||
charge = 10+level*2;
|
||||
partialCharge = 0;
|
||||
chargeCap = 10+level*2;
|
||||
|
||||
defaultAction = AC_ACTIVATE;
|
||||
}
|
||||
|
||||
private static final String TXT_CHARGE = "%d/%d";
|
||||
|
||||
public static final String AC_ACTIVATE = "ACTIVATE";
|
||||
|
||||
//keeps track of generated sandbags.
|
||||
|
@ -113,11 +113,6 @@ public class TimekeepersHourglass extends Artifact {
|
|||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String status() {
|
||||
return Utils.format(TXT_CHARGE, charge, chargeCap);
|
||||
}
|
||||
|
||||
|
||||
//needs to bundle chargecap as it is dynamic.
|
||||
private static final String CHARGECAP = "chargecap";
|
||||
|
|
|
@ -15,7 +15,6 @@ import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.QuickSlot;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
import com.watabou.utils.Bundle;
|
||||
|
@ -31,21 +30,22 @@ public class UnstableSpellbook extends Artifact {
|
|||
//TODO: add display logic
|
||||
|
||||
{
|
||||
name = "unstable spellbook";
|
||||
name = "Unstable Spellbook";
|
||||
image = ItemSpriteSheet.ARTIFACT_SPELLBOOK;
|
||||
|
||||
level = 0;
|
||||
levelCap = 10;
|
||||
|
||||
charge = ((level/2)+1);
|
||||
partialCharge = 0;
|
||||
chargeCap = ((level/2)+1);
|
||||
|
||||
defaultAction = AC_READ;
|
||||
}
|
||||
|
||||
public static final String AC_READ = "READ";
|
||||
public static final String AC_ADD = "ADD";
|
||||
|
||||
private static final String TXT_CHARGE = "%d/%d";
|
||||
|
||||
private final ArrayList<String> scrolls = new ArrayList<String>();
|
||||
|
||||
protected String inventoryTitle = "Select a scroll";
|
||||
|
@ -160,11 +160,6 @@ public class UnstableSpellbook extends Artifact {
|
|||
return desc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String status() {
|
||||
return Utils.format(TXT_CHARGE, charge, chargeCap);
|
||||
}
|
||||
|
||||
//needs to bundle chargecap as it is dynamic.
|
||||
private static final String CHARGECAP = "chargecap";
|
||||
private static final String SCROLLS = "scrolls";
|
||||
|
|
Loading…
Reference in New Issue
Block a user