V0.2.0: Implemented storing food in Horn of Plenty (needs testing)

This commit is contained in:
Evan Debenham
2014-08-27 11:44:25 -04:00
parent f033a2b872
commit b54680f78b
9 changed files with 48 additions and 11 deletions
@@ -2,15 +2,21 @@ package com.shatteredpixel.shatteredpixeldungeon.items.artifacts;
import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Badges; import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.Statistics; import com.shatteredpixel.shatteredpixeldungeon.Statistics;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Hunger; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Hunger;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck; import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.effects.SpellSprite; import com.shatteredpixel.shatteredpixeldungeon.effects.SpellSprite;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.food.Blandfruit;
import com.shatteredpixel.shatteredpixeldungeon.items.food.Food;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRecharging; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRecharging;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils; import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
import com.watabou.noosa.audio.Sample; import com.watabou.noosa.audio.Sample;
import java.util.ArrayList; import java.util.ArrayList;
@@ -20,7 +26,7 @@ import java.util.ArrayList;
*/ */
public class HornOfPlenty extends Artifact { public class HornOfPlenty extends Artifact {
//TODO: test for bugs, tune numbers. //TODO: test for bugs, tune numbers, add sprite switching.
{ {
name = "Horn of Plenty"; name = "Horn of Plenty";
@@ -37,6 +43,9 @@ public class HornOfPlenty extends Artifact {
public static final String AC_EAT = "EAT"; public static final String AC_EAT = "EAT";
public static final String AC_STORE = "STORE"; public static final String AC_STORE = "STORE";
protected String inventoryTitle = "Select a piece of food";
protected WndBag.Mode mode = WndBag.Mode.FOOD;
private static final String TXT_STATUS = "%d/%d"; private static final String TXT_STATUS = "%d/%d";
@Override @Override
@@ -51,6 +60,8 @@ public class HornOfPlenty extends Artifact {
@Override @Override
public void execute( Hero hero, String action ) { public void execute( Hero hero, String action ) {
super.execute(hero, action);
if (action.equals(AC_EAT)){ if (action.equals(AC_EAT)){
((Hunger)hero.buff( Hunger.class )).satisfy( energy*charge ); ((Hunger)hero.buff( Hunger.class )).satisfy( energy*charge );
@@ -88,15 +99,9 @@ public class HornOfPlenty extends Artifact {
image = ItemSpriteSheet.ARTIFACT_HORN; image = ItemSpriteSheet.ARTIFACT_HORN;
} else if (action.equals(AC_STORE)){ } else if (action.equals(AC_STORE)){
//TODO: gamescreen to select food item to store. can store anything that is isntanceof Food.
/*currently thinking: GameScene.selectItem(itemSelector, mode, inventoryTitle);
blandFruit = 1; }
snack-tier = 5;
hungry-tier = 15;
starving-tier = 25;
*/
} else
super.execute(hero, action);
} }
@Override @Override
@@ -148,4 +153,24 @@ public class HornOfPlenty extends Artifact {
} }
protected static WndBag.Listener itemSelector = new WndBag.Listener() {
@Override
public void onSelect( Item item ) {
if (item != null && item instanceof Food) {
if (item instanceof Blandfruit && ((Blandfruit) item).potionAttrib == null){
GLog.w("the horn rejects your unprepared blandfruit.");
} else {
curItem.level += ((Food)item).hornValue;
if (curItem.level >= 150){
curItem.level = 150;
GLog.p("your horn has consumed all the food it can!");
} else
GLog.p("the horn consumes your food offering and grows in strength!");
item.detach(Dungeon.hero.belongings.backpack);
}
}
}
};
} }
@@ -37,6 +37,7 @@ public class Blandfruit extends Food {
stackable = false; stackable = false;
image = ItemSpriteSheet.BLANDFRUIT; image = ItemSpriteSheet.BLANDFRUIT;
energy = (Hunger.STARVING - Hunger.HUNGRY)/2; energy = (Hunger.STARVING - Hunger.HUNGRY)/2;
hornValue = 15;
} }
@Override @Override
@@ -26,6 +26,7 @@ public class ChargrilledMeat extends Food {
name = "chargrilled meat"; name = "chargrilled meat";
image = ItemSpriteSheet.STEAK; image = ItemSpriteSheet.STEAK;
energy = Hunger.STARVING - Hunger.HUNGRY; energy = Hunger.STARVING - Hunger.HUNGRY;
hornValue = 5;
} }
@Override @Override
@@ -41,6 +41,8 @@ public class Food extends Item {
public float energy = Hunger.HUNGRY; public float energy = Hunger.HUNGRY;
public String message = "That food tasted delicious!"; public String message = "That food tasted delicious!";
public int hornValue = 15;
{ {
stackable = true; stackable = true;
name = "ration of food"; name = "ration of food";
@@ -37,6 +37,7 @@ public class FrozenCarpaccio extends Food {
name = "frozen carpaccio"; name = "frozen carpaccio";
image = ItemSpriteSheet.CARPACCIO; image = ItemSpriteSheet.CARPACCIO;
energy = Hunger.STARVING - Hunger.HUNGRY; energy = Hunger.STARVING - Hunger.HUNGRY;
hornValue = 5;
} }
@Override @Override
@@ -36,6 +36,7 @@ public class MysteryMeat extends Food {
image = ItemSpriteSheet.MEAT; image = ItemSpriteSheet.MEAT;
energy = Hunger.STARVING - Hunger.HUNGRY; energy = Hunger.STARVING - Hunger.HUNGRY;
message = "That food tasted... strange."; message = "That food tasted... strange.";
hornValue = 5;
} }
@Override @Override
@@ -27,6 +27,7 @@ public class OverpricedRation extends Food {
image = ItemSpriteSheet.OVERPRICED; image = ItemSpriteSheet.OVERPRICED;
energy = Hunger.STARVING - Hunger.HUNGRY; energy = Hunger.STARVING - Hunger.HUNGRY;
message = "That food tasted ok."; message = "That food tasted ok.";
hornValue = 5;
} }
@Override @Override
@@ -26,6 +26,7 @@ public class Pasty extends Food {
name = "pasty"; name = "pasty";
image = ItemSpriteSheet.PASTY; image = ItemSpriteSheet.PASTY;
energy = Hunger.STARVING; energy = Hunger.STARVING;
hornValue = 25;
} }
@Override @Override
@@ -19,6 +19,7 @@ package com.shatteredpixel.shatteredpixeldungeon.windows;
import android.graphics.RectF; import android.graphics.RectF;
import com.shatteredpixel.shatteredpixeldungeon.items.food.Food;
import com.watabou.gltextures.TextureCache; import com.watabou.gltextures.TextureCache;
import com.watabou.noosa.BitmapText; import com.watabou.noosa.BitmapText;
import com.watabou.noosa.ColorBlock; import com.watabou.noosa.ColorBlock;
@@ -58,7 +59,9 @@ public class WndBag extends WndTabbed {
WEAPON, WEAPON,
ARMOR, ARMOR,
WAND, WAND,
SEED SEED,
FOOD,
} }
protected static final int COLS = 4; protected static final int COLS = 4;
@@ -348,6 +351,7 @@ public class WndBag extends WndTabbed {
mode == Mode.ARMOR && (item instanceof Armor) || mode == Mode.ARMOR && (item instanceof Armor) ||
mode == Mode.WAND && (item instanceof Wand) || mode == Mode.WAND && (item instanceof Wand) ||
mode == Mode.SEED && (item instanceof Seed) || mode == Mode.SEED && (item instanceof Seed) ||
mode == Mode.FOOD && (item instanceof Food) ||
mode == Mode.ALL mode == Mode.ALL
); );
} }