From 93b5fe3eb6d54145a7caf89202d5f41679c46048 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Wed, 3 Sep 2014 10:38:02 -0400 Subject: [PATCH] V0.2.0: fully implemented charging chalice --- .../items/artifacts/ChaliceOfBlood.java | 86 ++++++++++++++++--- 1 file changed, 76 insertions(+), 10 deletions(-) diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/ChaliceOfBlood.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/ChaliceOfBlood.java index 0dbc9e48a..7e0a3914e 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/ChaliceOfBlood.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/ChaliceOfBlood.java @@ -1,11 +1,18 @@ package com.shatteredpixel.shatteredpixeldungeon.items.artifacts; +import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.ResultDescriptions; 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.utils.GLog; 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; @@ -16,6 +23,14 @@ public class ChaliceOfBlood extends Artifact { //TODO: add polish //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"; image = ItemSpriteSheet.ARTIFACT_CHALICE; @@ -29,35 +44,86 @@ public class ChaliceOfBlood extends Artifact { @Override public ArrayList actions( Hero hero ) { ArrayList actions = super.actions( hero ); - if (isEquipped( hero ) && level < 8) + if (isEquipped( hero ) && level < levelCap) actions.add(AC_PRICK); return actions; } @Override - public void execute( Hero hero, String action ) { + public void execute(Hero hero, String action ) { super.execute(hero, action); if (action.equals(AC_PRICK)){ - //TODO: add warning screen if chalice would take more than 75% current hp. - hero.spendAndNext(1f); - hero.damage((level*2)*(level*2), this); + int damage = (level*2)*(level*2); - if (!hero.isAlive()) { - Dungeon.fail(Utils.format(ResultDescriptions.ITEM, name, Dungeon.depth)); - GLog.n("The Chalice sucks your life essence dry..."); - } else - level++; + 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()) { + Dungeon.fail(Utils.format(ResultDescriptions.ITEM, name, Dungeon.depth)); + GLog.n("The Chalice sucks your life essence dry..."); + } else + level++; } + @Override protected ArtifactBuff passiveBuff() { return new chaliceRegen(); } + @Override + public String desc() { + //TODO: add description + return ""; + } + public class chaliceRegen extends ArtifactBuff { public int level() { return level;