v0.3.1: refactored resting based on new functionality. Hitting full HP now interrupts resting.

This commit is contained in:
Evan Debenham 2015-07-15 14:59:17 -04:00
parent 0a6c9c6e7f
commit 18e488c63e
7 changed files with 22 additions and 17 deletions

View File

@ -88,7 +88,7 @@ public class Hunger extends Buff implements Hero.Doom {
if (newLevel >= STARVING) { if (newLevel >= STARVING) {
GLog.n( TXT_STARVING ); GLog.n( TXT_STARVING );
hero.restoreHealth = false; hero.resting = false;
hero.damage( 1, this ); hero.damage( 1, this );
statusUpdated = true; statusUpdated = true;

View File

@ -58,7 +58,7 @@ public class MagicalSleep extends Buff {
public boolean act(){ public boolean act(){
if (target instanceof Hero) { if (target instanceof Hero) {
target.HP = Math.min(target.HP+1, target.HT); target.HP = Math.min(target.HP+1, target.HT);
((Hero) target).restoreHealth = true; ((Hero) target).resting = true;
if (target.HP == target.HT) { if (target.HP == target.HT) {
GLog.p("You wake up feeling refreshed and healthy."); GLog.p("You wake up feeling refreshed and healthy.");
detach(); detach();
@ -72,7 +72,7 @@ public class MagicalSleep extends Buff {
public void detach() { public void detach() {
target.paralysed = false; target.paralysed = false;
if (target instanceof Hero) if (target instanceof Hero)
((Hero) target).restoreHealth = false; ((Hero) target).resting = false;
super.detach(); super.detach();
} }

View File

@ -36,6 +36,9 @@ public class Regeneration extends Buff {
if (target.HP < target.HT && !((Hero)target).isStarving()) { if (target.HP < target.HT && !((Hero)target).isStarving()) {
target.HP += 1; target.HP += 1;
if (target.HP == target.HT){
((Hero)target).resting = false;
}
} }
ChaliceOfBlood.chaliceRegen regenBuff = Dungeon.hero.buff( ChaliceOfBlood.chaliceRegen.class); ChaliceOfBlood.chaliceRegen regenBuff = Dungeon.hero.buff( ChaliceOfBlood.chaliceRegen.class);

View File

@ -164,7 +164,7 @@ public class Hero extends Char {
private Item theKey; private Item theKey;
public boolean restoreHealth = false; public boolean resting = false;
public MissileWeapon rangedWeapon = null; public MissileWeapon rangedWeapon = null;
public Belongings belongings; public Belongings belongings;
@ -430,7 +430,7 @@ public class Hero extends Char {
if (curAction == null) { if (curAction == null) {
if (restoreHealth) { if (resting) {
spend( TIME_TO_REST ); next(); spend( TIME_TO_REST ); next();
return false; return false;
} }
@ -440,7 +440,7 @@ public class Hero extends Char {
} else { } else {
restoreHealth = false; resting = false;
ready = false; ready = false;
@ -849,12 +849,12 @@ public class Hero extends Char {
} }
} }
public void rest( boolean tillHealthy ) { public void rest( boolean fullRest ) {
spendAndNext( TIME_TO_REST ); spendAndNext( TIME_TO_REST );
if (!tillHealthy) { if (!fullRest) {
sprite.showStatus( CharSprite.DEFAULT, TXT_WAIT ); sprite.showStatus( CharSprite.DEFAULT, TXT_WAIT );
} }
restoreHealth = tillHealthy; resting = fullRest;
} }
@Override @Override
@ -908,7 +908,7 @@ public class Hero extends Char {
if (!(src instanceof Hunger || src instanceof Viscosity.DeferedDamage) && damageInterrupt) { if (!(src instanceof Hunger || src instanceof Viscosity.DeferedDamage) && damageInterrupt) {
interrupt(); interrupt();
restoreHealth = false; resting = false;
} }
if (this.buff(Drowsy.class) != null){ if (this.buff(Drowsy.class) != null){
@ -955,7 +955,7 @@ public class Hero extends Char {
if (newMob) { if (newMob) {
interrupt(); interrupt();
restoreHealth = false; resting = false;
} }
visibleEnemies = visible; visibleEnemies = visible;

View File

@ -24,13 +24,13 @@ import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter; import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck; import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ShaftParticle; import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ShaftParticle;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfHealing; import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfHealing;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
import com.watabou.utils.Bundle; import com.watabou.utils.Bundle;
public class Sungrass extends Plant { public class Sungrass extends Plant {
@ -114,6 +114,10 @@ public class Sungrass extends Plant {
if (healCurr < 6) if (healCurr < 6)
healCurr ++; healCurr ++;
target.sprite.emitter().burst(Speck.factory(Speck.HEALING), 1); target.sprite.emitter().burst(Speck.factory(Speck.HEALING), 1);
if (target.HP == target.HT && target instanceof Hero){
((Hero)target).resting = false;
}
} }
count = 1; count = 1;
} else { } else {

View File

@ -24,7 +24,6 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import com.shatteredpixel.shatteredpixeldungeon.*; import com.shatteredpixel.shatteredpixeldungeon.*;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass;
import com.shatteredpixel.shatteredpixeldungeon.items.Honeypot; import com.shatteredpixel.shatteredpixeldungeon.items.Honeypot;
import com.shatteredpixel.shatteredpixeldungeon.items.bags.PotionBandolier; import com.shatteredpixel.shatteredpixeldungeon.items.bags.PotionBandolier;
import com.shatteredpixel.shatteredpixeldungeon.items.bags.ScrollHolder; import com.shatteredpixel.shatteredpixeldungeon.items.bags.ScrollHolder;
@ -32,7 +31,6 @@ import com.shatteredpixel.shatteredpixeldungeon.items.bags.SeedPouch;
import com.shatteredpixel.shatteredpixeldungeon.items.bags.WandHolster; import com.shatteredpixel.shatteredpixeldungeon.items.bags.WandHolster;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion; import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportation; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportation;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MagesStaff;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap; import com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap;
import com.shatteredpixel.shatteredpixeldungeon.sprites.TrapSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.TrapSprite;
import com.shatteredpixel.shatteredpixeldungeon.ui.LootIndicator; import com.shatteredpixel.shatteredpixeldungeon.ui.LootIndicator;
@ -685,10 +683,10 @@ public class GameScene extends PixelScene {
} }
static boolean cancel() { static boolean cancel() {
if (Dungeon.hero.curAction != null || Dungeon.hero.restoreHealth) { if (Dungeon.hero.curAction != null || Dungeon.hero.resting) {
Dungeon.hero.curAction = null; Dungeon.hero.curAction = null;
Dungeon.hero.restoreHealth = false; Dungeon.hero.resting = false;
return true; return true;
} else { } else {

View File

@ -103,7 +103,7 @@ public class HeroSprite extends CharSprite {
@Override @Override
public void update() { public void update() {
sleeping = ch.isAlive() && ((Hero)ch).restoreHealth; sleeping = ch.isAlive() && ((Hero)ch).resting;
super.update(); super.update();
} }