v0.4.1a: buffs to the horn of plenty

This commit is contained in:
Evan Debenham
2016-08-08 14:57:07 -04:00
parent 686dd6e8a6
commit 7f8a66b78f
2 changed files with 49 additions and 34 deletions
@@ -148,6 +148,10 @@ public class Hunger extends Buff implements Hero.Doom {
return level >= STARVING; return level >= STARVING;
} }
public int hunger() {
return (int)Math.ceil(level);
}
@Override @Override
public int icon() { public int icon() {
if (level < HUNGRY) { if (level < HUNGRY) {
@@ -54,7 +54,7 @@ public class HornOfPlenty extends Artifact {
charge = 0; charge = 0;
partialCharge = 0; partialCharge = 0;
chargeCap = 10; chargeCap = 10 + visiblyUpgraded();
defaultAction = AC_EAT; defaultAction = AC_EAT;
} }
@@ -86,10 +86,12 @@ public class HornOfPlenty extends Artifact {
if (!isEquipped(hero)) GLog.i( Messages.get(Artifact.class, "need_to_equip") ); if (!isEquipped(hero)) GLog.i( Messages.get(Artifact.class, "need_to_equip") );
else if (charge == 0) GLog.i( Messages.get(this, "no_food") ); else if (charge == 0) GLog.i( Messages.get(this, "no_food") );
else { else {
hero.buff(Hunger.class).satisfy((Hunger.STARVING/10) * charge); //consume as many
int chargesToUse = Math.max( 1, hero.buff(Hunger.class).hunger() / (int)(Hunger.STARVING/10));
if (chargesToUse > charge) chargesToUse = charge;
hero.buff(Hunger.class).satisfy((Hunger.STARVING/10) * chargesToUse);
//if you get at least 100 food energy from the horn //if you get at least 80 food energy from the horn
if (charge >= 3) {
switch (hero.heroClass) { switch (hero.heroClass) {
case WARRIOR: case WARRIOR:
if (hero.HP < hero.HT) { if (hero.HP < hero.HT) {
@@ -108,8 +110,8 @@ public class HornOfPlenty extends Artifact {
} }
Statistics.foodEaten++; Statistics.foodEaten++;
}
charge = 0; charge -= chargesToUse;
hero.sprite.operate(hero.pos); hero.sprite.operate(hero.pos);
hero.busy(); hero.busy();
@@ -121,7 +123,9 @@ public class HornOfPlenty extends Artifact {
Badges.validateFoodEaten(); Badges.validateFoodEaten();
image = ItemSpriteSheet.ARTIFACT_HORN1; if (charge >= 15) image = ItemSpriteSheet.ARTIFACT_HORN4;
else if (charge >= 10) image = ItemSpriteSheet.ARTIFACT_HORN3;
else if (charge >= 5) image = ItemSpriteSheet.ARTIFACT_HORN2;
updateQuickslot(); updateQuickslot();
} }
@@ -154,12 +158,19 @@ public class HornOfPlenty extends Artifact {
return desc; return desc;
} }
@Override
public Item upgrade() {
super.upgrade();
chargeCap = 10 + visiblyUpgraded();
return this;
}
@Override @Override
public void restoreFromBundle(Bundle bundle) { public void restoreFromBundle(Bundle bundle) {
super.restoreFromBundle(bundle); super.restoreFromBundle(bundle);
if (charge == chargeCap)image = ItemSpriteSheet.ARTIFACT_HORN4; if (charge >= 15) image = ItemSpriteSheet.ARTIFACT_HORN4;
else if (charge >= 7) image = ItemSpriteSheet.ARTIFACT_HORN3; else if (charge >= 10) image = ItemSpriteSheet.ARTIFACT_HORN3;
else if (charge >= 3) image = ItemSpriteSheet.ARTIFACT_HORN2; else if (charge >= 5) image = ItemSpriteSheet.ARTIFACT_HORN2;
} }
public class hornRecharge extends ArtifactBuff{ public class hornRecharge extends ArtifactBuff{
@@ -167,19 +178,19 @@ public class HornOfPlenty extends Artifact {
public void gainCharge(float levelPortion) { public void gainCharge(float levelPortion) {
if (charge < chargeCap) { if (charge < chargeCap) {
//generates 0.25x max hunger value every hero level, +0.025x max value per horn level //generates 0.25x max hunger value every hero level, +0.035x max value per horn level
//to a max of exactly max hunger value per hero level (0.25+0.75, at horn level 30) //to a max of 1.3x max hunger value per hero level
//This means that a standard ration will be recovered in 10 hero levels //This means that a standard ration will be recovered in ~7.15 hero levels
partialCharge += Hunger.STARVING * levelPortion * (0.25f + (0.025f*level())); partialCharge += Hunger.STARVING * levelPortion * (0.25f + (0.035f*level()));
//charge is in increments of 1/10 max hunger value. //charge is in increments of 1/10 max hunger value.
while (partialCharge >= Hunger.STARVING/10) { while (partialCharge >= Hunger.STARVING/10) {
charge++; charge++;
partialCharge -= Hunger.STARVING/10; partialCharge -= Hunger.STARVING/10;
if (charge == chargeCap)image = ItemSpriteSheet.ARTIFACT_HORN4; if (charge >= 15) image = ItemSpriteSheet.ARTIFACT_HORN4;
else if (charge >= 7) image = ItemSpriteSheet.ARTIFACT_HORN3; else if (charge >= 10) image = ItemSpriteSheet.ARTIFACT_HORN3;
else if (charge >= 3) image = ItemSpriteSheet.ARTIFACT_HORN2; else if (charge >= 5) image = ItemSpriteSheet.ARTIFACT_HORN2;
else image = ItemSpriteSheet.ARTIFACT_HORN1; else image = ItemSpriteSheet.ARTIFACT_HORN1;
if (charge == chargeCap){ if (charge == chargeCap){