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 191a182ad..4db1fdf24 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 @@ -52,16 +52,16 @@ public class HornOfPlenty extends Artifact { { image = ItemSpriteSheet.ARTIFACT_HORN1; - levelCap = 30; + levelCap = 10; charge = 0; partialCharge = 0; - chargeCap = 10 + visiblyUpgraded(); + chargeCap = 10 + level(); defaultAction = AC_EAT; } - - private static final float TIME_TO_EAT = 3f; + + private int storedFoodEnergy = 0; public static final String AC_EAT = "EAT"; public static final String AC_STORE = "STORE"; @@ -73,7 +73,7 @@ public class HornOfPlenty extends Artifact { ArrayList actions = super.actions( hero ); if (isEquipped( hero ) && charge > 0) actions.add(AC_EAT); - if (isEquipped( hero ) && level() < 30 && !cursed) + if (isEquipped( hero ) && level() < levelCap && !cursed) actions.add(AC_STORE); return actions; } @@ -121,7 +121,7 @@ public class HornOfPlenty extends Artifact { Sample.INSTANCE.play(Assets.SND_EAT); GLog.i( Messages.get(this, "eat") ); - hero.spend(TIME_TO_EAT); + hero.spend(Food.TIME_TO_EAT); Badges.validateFoodEaten(); @@ -163,19 +163,58 @@ public class HornOfPlenty extends Artifact { @Override public void level(int value) { super.level(value); - chargeCap = 10 + visiblyUpgraded(); + chargeCap = 10 + level(); } @Override public Item upgrade() { super.upgrade(); - chargeCap = 10 + visiblyUpgraded(); + chargeCap = 10 + level(); return this; } - + + public void gainFoodValue( Food food ){ + if (level() >= 10) return; + + storedFoodEnergy += food.energy; + if (storedFoodEnergy >= Hunger.HUNGRY){ + int upgrades = storedFoodEnergy / (int)Hunger.HUNGRY; + upgrades = Math.min(upgrades, 10 - level()); + upgrade(upgrades); + storedFoodEnergy -= upgrades * Hunger.HUNGRY; + if (level() == 10){ + storedFoodEnergy = 0; + GLog.p( Messages.get(this, "maxlevel") ); + } else { + GLog.p( Messages.get(this, "levelup") ); + } + } else { + GLog.i( Messages.get(this, "feed") ); + } + } + + private static final String STORED = "stored"; + + @Override + public void storeInBundle(Bundle bundle) { + super.storeInBundle(bundle); + bundle.put( STORED, storedFoodEnergy ); + } + @Override public void restoreFromBundle(Bundle bundle) { super.restoreFromBundle(bundle); + + if (bundle.contains(STORED)){ + storedFoodEnergy = bundle.getInt(STORED); + + //logic for pre-0.6.1 saves + } else { + //keep partial levels + storedFoodEnergy = (int)(level()%3 * Hunger.HUNGRY/3); + level(level()/3); + } + if (charge >= 15) image = ItemSpriteSheet.ARTIFACT_HORN4; else if (charge >= 10) image = ItemSpriteSheet.ARTIFACT_HORN3; else if (charge >= 5) image = ItemSpriteSheet.ARTIFACT_HORN2; @@ -186,10 +225,10 @@ public class HornOfPlenty extends Artifact { public void gainCharge(float levelPortion) { if (charge < chargeCap) { - //generates 0.25x max hunger value every hero level, +0.035x max value per horn level - //to a max of 1.3x max hunger value per hero level - //This means that a standard ration will be recovered in ~7.15 hero levels - partialCharge += Hunger.STARVING * levelPortion * (0.25f + (0.035f*level())); + //generates 0.2x max hunger value every hero level, +0.1x max value per horn level + //to a max of 1.2x max hunger value per hero level + //This means that a standard ration will be recovered in 6.67 hero levels + partialCharge += Hunger.STARVING * levelPortion * (0.2f + (0.1f*level())); //charge is in increments of 1/10 max hunger value. while (partialCharge >= Hunger.STARVING/10) { @@ -224,14 +263,9 @@ public class HornOfPlenty extends Artifact { Hero hero = Dungeon.hero; hero.sprite.operate( hero.pos ); hero.busy(); - hero.spend( TIME_TO_EAT ); + hero.spend( Food.TIME_TO_EAT ); - curItem.upgrade(((Food)item).hornValue); - if (curItem.level() >= 30){ - curItem.level(30); - GLog.p( Messages.get(HornOfPlenty.class, "maxlevel") ); - } else - GLog.p( Messages.get(HornOfPlenty.class, "levelup") ); + ((HornOfPlenty)curItem).gainFoodValue(((Food)item)); item.detach(hero.belongings.backpack); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/food/Blandfruit.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/food/Blandfruit.java index 7d64e36a6..6dea26aea 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/food/Blandfruit.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/food/Blandfruit.java @@ -59,7 +59,6 @@ public class Blandfruit extends Food { //only applies when blandfruit is cooked energy = Hunger.STARVING; - hornValue = 6; bones = true; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/food/ChargrilledMeat.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/food/ChargrilledMeat.java index e7b79ee67..dbfe21b78 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/food/ChargrilledMeat.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/food/ChargrilledMeat.java @@ -29,7 +29,6 @@ public class ChargrilledMeat extends Food { { image = ItemSpriteSheet.STEAK; energy = Hunger.HUNGRY/2f; - hornValue = 1; } @Override 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 048c65395..951db5234 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 @@ -41,14 +41,12 @@ import java.util.ArrayList; public class Food extends Item { - private static final float TIME_TO_EAT = 3f; + public static final float TIME_TO_EAT = 3f; public static final String AC_EAT = "EAT"; public float energy = Hunger.HUNGRY; public String message = Messages.get(this, "eat_msg"); - - public int hornValue = 3; { stackable = true; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/food/FrozenCarpaccio.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/food/FrozenCarpaccio.java index 1748f089c..297244787 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/food/FrozenCarpaccio.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/food/FrozenCarpaccio.java @@ -44,7 +44,6 @@ public class FrozenCarpaccio extends Food { { image = ItemSpriteSheet.CARPACCIO; energy = Hunger.HUNGRY/2f; - hornValue = 1; } @Override diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/food/MysteryMeat.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/food/MysteryMeat.java index 8fa822c62..9a71122e7 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/food/MysteryMeat.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/food/MysteryMeat.java @@ -39,7 +39,6 @@ public class MysteryMeat extends Food { { image = ItemSpriteSheet.MEAT; energy = Hunger.HUNGRY/2f; - hornValue = 1; } @Override diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/food/Pasty.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/food/Pasty.java index f7e690312..b73a539a4 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/food/Pasty.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/food/Pasty.java @@ -88,7 +88,6 @@ public class Pasty extends Food { } energy = Hunger.STARVING; - hornValue = 5; bones = true; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/food/SmallRation.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/food/SmallRation.java index 474bca4c3..0b8b521fb 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/food/SmallRation.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/food/SmallRation.java @@ -29,7 +29,6 @@ public class SmallRation extends Food { { image = ItemSpriteSheet.OVERPRICED; energy = Hunger.HUNGRY/2f; - hornValue = 1; } @Override diff --git a/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties b/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties index cc53997ca..58a3f1ee7 100644 --- a/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties +++ b/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties @@ -212,6 +212,7 @@ items.artifacts.hornofplenty.full=Your horn is full of food! items.artifacts.hornofplenty.reject=Your horn rejects the uncooked blandfruit. items.artifacts.hornofplenty.maxlevel=Your horn has consumed all the food it can! items.artifacts.hornofplenty.levelup=The horn consumes your food offering and grows in strength! +items.artifacts.hornofplenty.feed=The horn consumes your food offering. items.artifacts.hornofplenty.desc=This horn can't be blown into, but instead seems to fill up with food over time when equipped. items.artifacts.hornofplenty.desc_hint=Perhaps there is a way to increase the horn's power by giving it food energy. items.artifacts.hornofplenty.desc_cursed=The cursed horn has bound itself to your side, it seems to be eager to take food rather than produce it.