diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Hunger.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Hunger.java index dba574ac4..7813ca23e 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Hunger.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Hunger.java @@ -34,30 +34,30 @@ import com.watabou.utils.Random; public class Hunger extends Buff implements Hero.Doom { private static final float STEP = 10f; - + public static final float HUNGRY = 260f; public static final float STARVING = 360f; - + private static final String TXT_HUNGRY = "You are hungry."; private static final String TXT_STARVING = "You are starving!"; private static final String TXT_DEATH = "You starved to death..."; - + private float level; private static final String LEVEL = "level"; - + @Override public void storeInBundle( Bundle bundle ) { super.storeInBundle( bundle ); bundle.put( LEVEL, level ); } - + @Override public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle( bundle ); level = bundle.getFloat( LEVEL ); } - + @Override public boolean act() { @@ -67,9 +67,9 @@ public class Hunger extends Buff implements Hero.Doom { } if (target.isAlive()) { - + Hero hero = (Hero)target; - + if (isStarving()) { if (Random.Float() < 0.3f && (target.HP > 1 || !target.paralysed)) { @@ -78,40 +78,40 @@ public class Hunger extends Buff implements Hero.Doom { } } else { - + float newLevel = level + STEP; boolean statusUpdated = false; if (newLevel >= STARVING) { - + GLog.n( TXT_STARVING ); hero.damage( 1, this ); statusUpdated = true; - + hero.interrupt(); - + } else if (newLevel >= HUNGRY && level < HUNGRY) { - + GLog.w( TXT_HUNGRY ); statusUpdated = true; - + } level = newLevel; - + if (statusUpdated) { BuffIndicator.refreshHero(); } - + } - + float step = ((Hero)target).heroClass == HeroClass.ROGUE ? STEP * 1.2f : STEP; spend( target.buff( Shadows.class ) == null ? step : step * 1.5f ); - + } else { - + diactivate(); - + } - + return true; } @@ -125,7 +125,8 @@ public class Hunger extends Buff implements Hero.Doom { GLog.n("The cursed horn steals some of the food energy as you eat."); } - reduceHunger( energy ); + if (!Dungeon.isChallenged(Challenges.NO_FOOD)) + reduceHunger( energy ); } public void consumeSoul( float energy ){ @@ -135,12 +136,12 @@ public class Hunger extends Buff implements Hero.Doom { else if (level < HUNGRY) energy *= 0.75f; - reduceHunger( energy ); + if (!Dungeon.isChallenged(Challenges.NO_FOOD)) + reduceHunger( energy ); } - private void reduceHunger( float energy ) { - if (Dungeon.isChallenged(Challenges.NO_FOOD)) - return; + //directly interacts with hunger, no checks. + public void reduceHunger( float energy ) { level -= energy; if (level < 0) { @@ -151,11 +152,11 @@ public class Hunger extends Buff implements Hero.Doom { BuffIndicator.refreshHero(); } - + public boolean isStarving() { return level >= STARVING; } - + @Override public int icon() { if (level < HUNGRY) { @@ -166,7 +167,7 @@ public class Hunger extends Buff implements Hero.Doom { return BuffIndicator.STARVATION; } } - + @Override public String toString() { if (level < STARVING) { @@ -178,9 +179,9 @@ public class Hunger extends Buff implements Hero.Doom { @Override public void onDeath() { - + Badges.validateDeathFromHunger(); - + Dungeon.fail( ResultDescriptions.HUNGER ); GLog.n( TXT_DEATH ); } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java index e81056024..f9286e320 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java @@ -798,7 +798,7 @@ public class Hero extends Char { Hunger hunger = buff( Hunger.class ); if (hunger != null && !hunger.isStarving()) { - hunger.satisfy( -Hunger.STARVING / 10 ); + hunger.reduceHunger( -Hunger.STARVING / 10 ); } Buff buff = buff(TimekeepersHourglass.timeFreeze.class); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/glyphs/Metabolism.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/glyphs/Metabolism.java index 51096766b..96336565c 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/glyphs/Metabolism.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/glyphs/Metabolism.java @@ -48,7 +48,7 @@ public class Metabolism extends Glyph { if (hunger != null && !hunger.isStarving()) { - hunger.satisfy( -Hunger.STARVING / 10 ); + hunger.reduceHunger( -Hunger.STARVING / 10 ); BuffIndicator.refreshHero(); defender.HP += healing; diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/quest/Pickaxe.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/quest/Pickaxe.java index 680def9c6..d23133cbe 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/quest/Pickaxe.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/quest/Pickaxe.java @@ -109,7 +109,7 @@ public class Pickaxe extends Weapon { Hunger hunger = hero.buff( Hunger.class ); if (hunger != null && !hunger.isStarving()) { - hunger.satisfy( -Hunger.STARVING / 10 ); + hunger.reduceHunger( -Hunger.STARVING / 10 ); BuffIndicator.refreshHero(); }