From 7109ce995c158bd3f4c1279a186e2b173e7566b9 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Fri, 13 Feb 2015 03:21:55 -0500 Subject: [PATCH] v0.2.4: added support for heaps exploding, freezing/exploding potions now shatter in heaps. --- .../shatteredpixeldungeon/items/Heap.java | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/Heap.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/Heap.java index 8534459a4..c2f2351f2 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/Heap.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/Heap.java @@ -38,6 +38,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.food.Blandfruit; import com.shatteredpixel.shatteredpixeldungeon.items.food.ChargrilledMeat; import com.shatteredpixel.shatteredpixeldungeon.items.food.FrozenCarpaccio; import com.shatteredpixel.shatteredpixeldungeon.items.food.MysteryMeat; +import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion; import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfExperience; import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfHealing; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll; @@ -227,6 +228,9 @@ public class Heap implements Bundlable { } else if (item instanceof MysteryMeat) { replace( item, ChargrilledMeat.cook( (MysteryMeat)item ) ); burnt = true; + } else if (item instanceof Bomb) { + explode(); + return; } } @@ -248,6 +252,45 @@ public class Heap implements Bundlable { } } + + //bombs! + public void explode() { + + //breaks open most standard containers + if (type == Type.MIMIC || type == Type.CHEST || type == Type.SKELETON) { + type = Type.HEAP; + sprite.link(); + sprite.drop(); + return; + } + + if (type != Type.HEAP) { + + return; + + } else { + + for (Item item : items.toArray( new Item[0] )) { + + if (item instanceof Potion) { + items.remove( item ); + ((Potion) item).shatter(pos); + + } else if (item instanceof Bomb) { + items.remove( item ); + ((Bomb) item).explode(pos); + return; + + //unique and upgraded items can endure the blast + } else if (!(item.level > 0 || item.unique)) + items.remove( item ); + + } + + if (items.isEmpty()) + destroy(); + } + } public void freeze() { @@ -268,6 +311,9 @@ public class Heap implements Bundlable { if (item instanceof MysteryMeat) { replace( item, FrozenCarpaccio.cook( (MysteryMeat)item ) ); frozen = true; + } else if (item instanceof Potion) { + ((Potion) item).shatter(pos); + frozen = true; } }