V0.2.0: fully implemented charging chalice

This commit is contained in:
Evan Debenham 2014-09-03 10:38:02 -04:00
parent e00291b675
commit 93b5fe3eb6

View File

@ -1,11 +1,18 @@
package com.shatteredpixel.shatteredpixeldungeon.items.artifacts; package com.shatteredpixel.shatteredpixeldungeon.items.artifacts;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.ResultDescriptions; import com.shatteredpixel.shatteredpixeldungeon.ResultDescriptions;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ShadowParticle;
import com.shatteredpixel.shatteredpixeldungeon.plants.Earthroot;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils; import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions;
import com.watabou.noosa.audio.Sample;
import com.watabou.utils.Random;
import java.util.ArrayList; import java.util.ArrayList;
@ -16,6 +23,14 @@ public class ChaliceOfBlood extends Artifact {
//TODO: add polish //TODO: add polish
//TODO: add sprite switching //TODO: add sprite switching
private static final String TXT_CHALICE = "Chalice of Blood";
private static final String TXT_YES = "Yes, I know what I'm doing";
private static final String TXT_NO = "No, I changed my mind";
private static final String TXT_PRICK =
"Each time you use the chalice it will drain more life energy, "+
"if you are not careful this draining effect can easily kill you.\n\n"+
"Are you sure you want to offer it more life energy?";
{ {
name = "Chalice of Blood"; name = "Chalice of Blood";
image = ItemSpriteSheet.ARTIFACT_CHALICE; image = ItemSpriteSheet.ARTIFACT_CHALICE;
@ -29,35 +44,86 @@ public class ChaliceOfBlood extends Artifact {
@Override @Override
public ArrayList<String> actions( Hero hero ) { public ArrayList<String> actions( Hero hero ) {
ArrayList<String> actions = super.actions( hero ); ArrayList<String> actions = super.actions( hero );
if (isEquipped( hero ) && level < 8) if (isEquipped( hero ) && level < levelCap)
actions.add(AC_PRICK); actions.add(AC_PRICK);
return actions; return actions;
} }
@Override @Override
public void execute( Hero hero, String action ) { public void execute(Hero hero, String action ) {
super.execute(hero, action); super.execute(hero, action);
if (action.equals(AC_PRICK)){ if (action.equals(AC_PRICK)){
//TODO: add warning screen if chalice would take more than 75% current hp.
hero.spendAndNext(1f); int damage = (level*2)*(level*2);
hero.damage((level*2)*(level*2), this);
if (damage > hero.HT*(3/4)) {
GameScene.show(
new WndOptions(TXT_CHALICE, TXT_PRICK, TXT_YES, TXT_NO) {
@Override
protected void onSelect(int index) {
if (index == 0)
prick(Dungeon.hero);
};
}
);
} else {
prick(hero);
}
}
}
private void prick(Hero hero){
int damage = (level*2)*(level*2);
hero.spendAndNext(3f);
Earthroot.Armor armor = hero.buff(Earthroot.Armor.class);
if (armor != null) {
damage = armor.absorb(damage);
}
damage -= Random.IntRange(0, hero.dr());
hero.damage(damage, this);
//TODO: make sure this look good
if (damage == 0){
GLog.i("You prick yourself, that hardly hurt at all!");
} else if (damage < 25){
GLog.w("You prick yourself and the chalice feeds on you.");
Sample.INSTANCE.play(Assets.SND_CURSED);
hero.sprite.emitter().burst( ShadowParticle.CURSE, 6 );
} else if (damage < 100){
GLog.w("Your life essence drains into the chalice.");
Sample.INSTANCE.play(Assets.SND_CURSED);
hero.sprite.emitter().burst( ShadowParticle.CURSE, 6 );
} else {
GLog.w("The chalice devours your life energy.");
Sample.INSTANCE.play(Assets.SND_CURSED);
hero.sprite.emitter().burst( ShadowParticle.CURSE, 6 );
}
if (!hero.isAlive()) { if (!hero.isAlive()) {
Dungeon.fail(Utils.format(ResultDescriptions.ITEM, name, Dungeon.depth)); Dungeon.fail(Utils.format(ResultDescriptions.ITEM, name, Dungeon.depth));
GLog.n("The Chalice sucks your life essence dry..."); GLog.n("The Chalice sucks your life essence dry...");
} else } else
level++; level++;
} }
}
@Override @Override
protected ArtifactBuff passiveBuff() { protected ArtifactBuff passiveBuff() {
return new chaliceRegen(); return new chaliceRegen();
} }
@Override
public String desc() {
//TODO: add description
return "";
}
public class chaliceRegen extends ArtifactBuff { public class chaliceRegen extends ArtifactBuff {
public int level() { public int level() {
return level; return level;