From 832df0324fbf1d6be6c5e5ce75cc7048299fb55c Mon Sep 17 00:00:00 2001
From: Evan Debenham <Evan@ShatteredPixel.com>
Date: Sat, 5 Sep 2020 15:10:56 -0400
Subject: [PATCH] v0.9.0: reworked the 'on diet' challenge, now makes food less
 effective

---
 .../main/assets/messages/misc/misc.properties |  2 +-
 .../shatteredpixeldungeon/Challenges.java     | 10 --------
 .../actors/hero/HeroClass.java                |  5 ----
 .../items/artifacts/HornOfPlenty.java         | 10 ++++++--
 .../items/food/Food.java                      |  8 ++++++-
 .../shatteredpixeldungeon/levels/Level.java   |  7 +-----
 .../levels/rooms/secret/SecretLarderRoom.java |  5 +---
 .../levels/rooms/special/GardenRoom.java      | 24 +++++++------------
 8 files changed, 26 insertions(+), 45 deletions(-)

diff --git a/core/src/main/assets/messages/misc/misc.properties b/core/src/main/assets/messages/misc/misc.properties
index 668417ac6..7fa8f93ce 100644
--- a/core/src/main/assets/messages/misc/misc.properties
+++ b/core/src/main/assets/messages/misc/misc.properties
@@ -70,7 +70,7 @@ badges$badge.unlock_rogue=Unlocked the Rogue
 badges$badge.unlock_huntress=Unlocked the Huntress
 
 challenges.no_food=On diet
-challenges.no_food_desc=Food is scarce, so make every bite count!\n\n- Regular rations and pasties are replaced with small rations\n- Mystery meat and blandfruit are removed\n- Horn of Plenty is removed
+challenges.no_food_desc=Food's already scarce, but you have to watch your portions as welL!\n\n- Food and the horn of plenty are one third as effective at satisfying hunger\n- Other sources of satiety are unaffected
 challenges.no_armor=Faith is my armor
 challenges.no_armor_desc=Take on the dungeon with nothing but some cloth to protect you!\n\n- All armor except starting cloth is removed
 challenges.no_healing=Pharmacophobia
diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Challenges.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Challenges.java
index fcf10e868..ad3e5409f 100644
--- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Challenges.java
+++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Challenges.java
@@ -26,10 +26,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Item;
 import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
 import com.shatteredpixel.shatteredpixeldungeon.items.armor.ClassArmor;
 import com.shatteredpixel.shatteredpixeldungeon.items.armor.ClothArmor;
-import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.HornOfPlenty;
 import com.shatteredpixel.shatteredpixeldungeon.items.food.Blandfruit;
-import com.shatteredpixel.shatteredpixeldungeon.items.food.Food;
-import com.shatteredpixel.shatteredpixeldungeon.items.food.SmallRation;
 import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfHealing;
 
 public class Challenges {
@@ -60,13 +57,6 @@ public class Challenges {
 	};
 
 	public static boolean isItemBlocked( Item item ){
-		if (Dungeon.isChallenged(NO_FOOD)){
-			if (item instanceof Food && !(item instanceof SmallRation)) {
-				return true;
-			} else if (item instanceof HornOfPlenty){
-				return true;
-			}
-		}
 
 		if (Dungeon.isChallenged(NO_ARMOR)){
 			if (item instanceof Armor && !(item instanceof ClothArmor || item instanceof ClassArmor)) {
diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/HeroClass.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/HeroClass.java
index d244c4e0b..4290b3bee 100644
--- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/HeroClass.java
+++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/HeroClass.java
@@ -33,7 +33,6 @@ import com.shatteredpixel.shatteredpixeldungeon.items.bags.PotionBandolier;
 import com.shatteredpixel.shatteredpixeldungeon.items.bags.ScrollHolder;
 import com.shatteredpixel.shatteredpixeldungeon.items.bags.VelvetPouch;
 import com.shatteredpixel.shatteredpixeldungeon.items.food.Food;
-import com.shatteredpixel.shatteredpixeldungeon.items.food.SmallRation;
 import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfHealing;
 import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfInvisibility;
 import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfLiquidFlame;
@@ -103,10 +102,6 @@ public enum HeroClass {
 		i = new Food();
 		if (!Challenges.isItemBlocked(i)) i.collect();
 
-		if (Dungeon.isChallenged(Challenges.NO_FOOD)){
-			new SmallRation().collect();
-		}
-
 		new ScrollOfIdentify().identify();
 
 	}
diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/HornOfPlenty.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/HornOfPlenty.java
index e85cd80aa..10cb0e0be 100644
--- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/HornOfPlenty.java
+++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/HornOfPlenty.java
@@ -23,6 +23,7 @@ package com.shatteredpixel.shatteredpixeldungeon.items.artifacts;
 
 import com.shatteredpixel.shatteredpixeldungeon.Assets;
 import com.shatteredpixel.shatteredpixeldungeon.Badges;
+import com.shatteredpixel.shatteredpixeldungeon.Challenges;
 import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
 import com.shatteredpixel.shatteredpixeldungeon.Statistics;
 import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
@@ -86,10 +87,15 @@ public class HornOfPlenty extends Artifact {
 			else if (charge == 0)  GLog.i( Messages.get(this, "no_food") );
 			else {
 				//consume as much food as it takes to be full, to a minimum of 1
+				int satietyPerCharge = (int) (Hunger.STARVING/10f);
+				if (Dungeon.isChallenged(Challenges.NO_FOOD)){
+					satietyPerCharge /= 3;
+				}
+
 				Hunger hunger = Buff.affect(Dungeon.hero, Hunger.class);
-				int chargesToUse = Math.max( 1, hunger.hunger() / (int)(Hunger.STARVING/10));
+				int chargesToUse = Math.max( 1, hunger.hunger() / satietyPerCharge);
 				if (chargesToUse > charge) chargesToUse = charge;
-				hunger.satisfy((Hunger.STARVING/10) * chargesToUse);
+				hunger.satisfy(satietyPerCharge * chargesToUse);
 
 				Food.foodProc( hero );
 
diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/food/Food.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/food/Food.java
index 55a046b39..44dd2dbd7 100644
--- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/food/Food.java
+++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/food/Food.java
@@ -23,6 +23,8 @@ package com.shatteredpixel.shatteredpixeldungeon.items.food;
 
 import com.shatteredpixel.shatteredpixeldungeon.Assets;
 import com.shatteredpixel.shatteredpixeldungeon.Badges;
+import com.shatteredpixel.shatteredpixeldungeon.Challenges;
+import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
 import com.shatteredpixel.shatteredpixeldungeon.Statistics;
 import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
 import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Hunger;
@@ -90,7 +92,11 @@ public class Food extends Item {
 	}
 	
 	protected void satisfy( Hero hero ){
-		Buff.affect(hero, Hunger.class).satisfy( energy );
+		if (Dungeon.isChallenged(Challenges.NO_FOOD)){
+			Buff.affect(hero, Hunger.class).satisfy(energy/3f);
+		} else {
+			Buff.affect(hero, Hunger.class).satisfy(energy);
+		}
 	}
 	
 	public static void foodProc( Hero hero ){
diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java
index 9e6cb15fa..1c91682cf 100644
--- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java
+++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java
@@ -56,7 +56,6 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Stylus;
 import com.shatteredpixel.shatteredpixeldungeon.items.Torch;
 import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TalismanOfForesight;
 import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TimekeepersHourglass;
-import com.shatteredpixel.shatteredpixeldungeon.items.food.SmallRation;
 import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfStrength;
 import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfUpgrade;
 import com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfEnchantment;
@@ -179,11 +178,7 @@ public abstract class Level implements Bundlable {
 		
 		if (!(Dungeon.bossLevel())) {
 
-			if (Dungeon.isChallenged(Challenges.NO_FOOD)){
-				addItemToSpawn( new SmallRation() );
-			} else {
-				addItemToSpawn(Generator.random(Generator.Category.FOOD));
-			}
+			addItemToSpawn(Generator.random(Generator.Category.FOOD));
 
 			if (Dungeon.isChallenged(Challenges.DARKNESS)){
 				addItemToSpawn( new Torch() );
diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/secret/SecretLarderRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/secret/SecretLarderRoom.java
index 8f669314b..5041eefce 100644
--- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/secret/SecretLarderRoom.java
+++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/secret/SecretLarderRoom.java
@@ -21,7 +21,6 @@
 
 package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.secret;
 
-import com.shatteredpixel.shatteredpixeldungeon.Challenges;
 import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
 import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Hunger;
 import com.shatteredpixel.shatteredpixeldungeon.items.food.ChargrilledMeat;
@@ -55,9 +54,7 @@ public class SecretLarderRoom extends SecretRoom {
 		Painter.fill(level, c.x-1, c.y-1, 3, 3, Terrain.WATER);
 		Painter.set(level, c, Terrain.GRASS);
 		
-		if (!Dungeon.isChallenged(Challenges.NO_FOOD)) {
-			level.plant(new BlandfruitBush.Seed(), level.pointToCell(c));
-		}
+		level.plant(new BlandfruitBush.Seed(), level.pointToCell(c));
 		
 		int extraFood = (int)(Hunger.STARVING - Hunger.HUNGRY) * (1 + Dungeon.depth / 5);
 		
diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/GardenRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/GardenRoom.java
index dca2908b3..a12b083e6 100644
--- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/GardenRoom.java
+++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/GardenRoom.java
@@ -21,8 +21,6 @@
 
 package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special;
 
-import com.shatteredpixel.shatteredpixeldungeon.Challenges;
-import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
 import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Foliage;
 import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
 import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
@@ -41,20 +39,14 @@ public class GardenRoom extends SpecialRoom {
 		
 		entrance().set( Door.Type.REGULAR );
 
-		if (Dungeon.isChallenged(Challenges.NO_FOOD)) {
-			if (Random.Int(2) == 0){
-				level.plant(new Sungrass.Seed(), plantPos( level ));
-			}
-		} else {
-			int bushes = Random.Int(3);
-			if (bushes == 0) {
-				level.plant(new Sungrass.Seed(), plantPos( level ));
-			} else if (bushes == 1) {
-				level.plant(new BlandfruitBush.Seed(), plantPos( level ));
-			} else if (Random.Int(5) == 0) {
-				level.plant(new Sungrass.Seed(), plantPos( level ));
-				level.plant(new BlandfruitBush.Seed(), plantPos( level ));
-			}
+		int bushes = Random.Int(3);
+		if (bushes == 0) {
+			level.plant(new Sungrass.Seed(), plantPos( level ));
+		} else if (bushes == 1) {
+			level.plant(new BlandfruitBush.Seed(), plantPos( level ));
+		} else if (Random.Int(5) == 0) {
+			level.plant(new Sungrass.Seed(), plantPos( level ));
+			level.plant(new BlandfruitBush.Seed(), plantPos( level ));
 		}
 		
 		Foliage light = (Foliage)level.blobs.get( Foliage.class );