diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Recharging.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Recharging.java new file mode 100644 index 000000000..819a23d90 --- /dev/null +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Recharging.java @@ -0,0 +1,54 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * Shattered Pixel Dungeon + * Copyright (C) 2014-2015 Evan Debenham + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see + */ +package com.shatteredpixel.shatteredpixeldungeon.actors.buffs; + +import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; + +public class Recharging extends FlavourBuff { + + @Override + public int icon() { + return BuffIndicator.RECHARGING; + } + + @Override + public String toString() { + return "Recharging"; + } + + //want to process partial turns for this buff, and not count it when it's expiring. + //firstly, if this buff has half a turn left, should give out half the benefit. + //secondly, recall that buffs execute in random order, so this can cause a problem where we can't simply check + //if this buff is still attached, must instead directly check its remaining time, and act accordingly. + //otherwise this causes inconsistent behaviour where this may detach before, or after, a wand charger acts. + public float remainder() { + return Math.min(1f, this.cooldown()); + } + + @Override + public String desc() { + return "Energy is coursing through you, improving the rate that your wands and staffs charge.\n" + + "\n" + + "Each turn this buff will increase current charge by one quarter, in addition to regular recharge. \n" + + "\n" + + "The recharging will last for " + dispTurns() + "."; + } +} diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/HornOfPlenty.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/HornOfPlenty.java index 6e81a7f03..20c312ac6 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/HornOfPlenty.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/HornOfPlenty.java @@ -27,6 +27,7 @@ import com.shatteredpixel.shatteredpixeldungeon.Statistics; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Hunger; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.LockedFloor; +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Recharging; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.effects.Speck; import com.shatteredpixel.shatteredpixeldungeon.effects.SpellSprite; @@ -100,7 +101,7 @@ public class HornOfPlenty extends Artifact { break; case MAGE: //1 charge - Buff.affect( hero, ScrollOfRecharging.Recharging.class, 4f ); + Buff.affect( hero, Recharging.class, 4f ); ScrollOfRecharging.charge(hero); break; case ROGUE: diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/food/Blandfruit.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/food/Blandfruit.java index 38cae352c..767344379 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/food/Blandfruit.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/food/Blandfruit.java @@ -32,6 +32,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FireImbue; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Hunger; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Invisibility; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Poison; +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Recharging; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.ToxicImbue; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Weakness; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; @@ -161,7 +162,7 @@ public class Blandfruit extends Food { break; case MAGE: //1 charge - Buff.affect(hero, ScrollOfRecharging.Recharging.class, 4f); + Buff.affect(hero, Recharging.class, 4f); ScrollOfRecharging.charge(hero); break; case ROGUE: diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/food/Food.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/food/Food.java index 082627890..b16a423da 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/food/Food.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/food/Food.java @@ -25,6 +25,7 @@ import com.shatteredpixel.shatteredpixeldungeon.Badges; import com.shatteredpixel.shatteredpixeldungeon.Statistics; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Hunger; +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Recharging; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.effects.Speck; import com.shatteredpixel.shatteredpixeldungeon.effects.SpellSprite; @@ -80,7 +81,7 @@ public class Food extends Item { break; case MAGE: //1 charge - Buff.affect( hero, ScrollOfRecharging.Recharging.class, 4f ); + Buff.affect( hero, Recharging.class, 4f ); ScrollOfRecharging.charge( hero ); break; case ROGUE: diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/food/Pasty.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/food/Pasty.java index b281331be..0a98fb82a 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/food/Pasty.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/food/Pasty.java @@ -22,6 +22,7 @@ package com.shatteredpixel.shatteredpixeldungeon.items.food; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Hunger; +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Recharging; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRecharging; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; @@ -86,7 +87,7 @@ public class Pasty extends Food { case NONE: default: break; //do nothing extra case XMAS: - Buff.affect( hero, ScrollOfRecharging.Recharging.class, 2f ); //half of a charge + Buff.affect( hero, Recharging.class, 2f ); //half of a charge ScrollOfRecharging.charge( hero ); break; } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/ScrollOfRecharging.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/ScrollOfRecharging.java index e0ae79f0b..973736740 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/ScrollOfRecharging.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/ScrollOfRecharging.java @@ -21,8 +21,7 @@ package com.shatteredpixel.shatteredpixeldungeon.items.scrolls; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; -import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FlavourBuff; -import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Recharging; import com.watabou.noosa.audio.Sample; import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Invisibility; @@ -71,36 +70,4 @@ public class ScrollOfRecharging extends Scroll { public int price() { return isKnown() ? 40 * quantity : super.price(); } - - - public static class Recharging extends FlavourBuff { - - @Override - public int icon() { - return BuffIndicator.RECHARGING; - } - - @Override - public String toString() { - return "Recharging"; - } - - //want to process partial turns for this buff, and not count it when it's expiring. - //firstly, if this buff has half a turn left, should give out half the benefit. - //secondly, recall that buffs execute in random order, so this can cause a problem where we can't simply check - //if this buff is still attached, must instead directly check its remaining time, and act accordingly. - //otherwise this causes inconsistent behaviour where this may detach before, or after, a wand charger acts. - public float remainder() { - return Math.min(1f, this.cooldown()); - } - - @Override - public String desc() { - return "Energy is coursing through you, improving the rate that your wands and staffs charge.\n" + - "\n" + - "Each turn this buff will increase current charge by one quarter, in addition to regular recharge. \n" + - "\n" + - "The recharging will last for " + dispTurns() + "."; - } - } } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/CursedWand.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/CursedWand.java index 7524f9939..adf7db552 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/CursedWand.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/CursedWand.java @@ -34,6 +34,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.ToxicGas; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Frost; +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Recharging; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mimic; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob; @@ -275,7 +276,7 @@ public class CursedWand { //shock and recharge case 3: new LightningTrap().set( user.pos ).activate(); - Buff.prolong(user, ScrollOfRecharging.Recharging.class, 20f); + Buff.prolong(user, Recharging.class, 20f); ScrollOfRecharging.charge(user); SpellSprite.show(user, SpellSprite.CHARGE); wand.wandUsed(); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/Wand.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/Wand.java index e453054c3..f55baa970 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/Wand.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/Wand.java @@ -24,10 +24,10 @@ import java.util.ArrayList; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.LockedFloor; +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Recharging; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.SoulMark; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroSubClass; -import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRecharging; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MagesStaff; import com.watabou.noosa.audio.Sample; import com.shatteredpixel.shatteredpixeldungeon.Assets; @@ -431,7 +431,7 @@ public abstract class Wand extends Item { if (lock == null || lock.regenOn()) partialCharge += 1f/turnsToCharge; - ScrollOfRecharging.Recharging bonus = target.buff(ScrollOfRecharging.Recharging.class); + Recharging bonus = target.buff(Recharging.class); if (bonus != null && bonus.remainder() > 0f){ partialCharge += CHARGE_BUFF_BONUS * bonus.remainder(); } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfMagicMissile.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfMagicMissile.java index 66f0ae8a7..06fd04918 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfMagicMissile.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfMagicMissile.java @@ -23,8 +23,8 @@ package com.shatteredpixel.shatteredpixeldungeon.items.wands; import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Recharging; import com.shatteredpixel.shatteredpixeldungeon.effects.SpellSprite; -import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRecharging; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MagesStaff; import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; @@ -55,7 +55,7 @@ public class WandOfMagicMissile extends Wand { public void onHit(MagesStaff staff, Char attacker, Char defender, int damage) { //gain 1 turn of recharging buff per level of the wand. if (level() > 0) { - Buff.prolong( attacker, ScrollOfRecharging.Recharging.class, (float)staff.level()); + Buff.prolong( attacker, Recharging.class, (float)staff.level()); SpellSprite.show(attacker, SpellSprite.CHARGE); } }