From 6abfa988f2430ea2634d2fe9b5c82997c1a032f7 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Wed, 30 May 2018 19:49:16 -0400 Subject: [PATCH] v0.7.0: added a recipe for scrolls to runestones --- .../shatteredpixeldungeon/items/Recipe.java | 3 +- .../items/scrolls/Scroll.java | 60 +++++++++++++++++++ .../shatteredpixeldungeon/windows/WndBag.java | 5 +- 3 files changed, 63 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Recipe.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Recipe.java index 7881cccfc..6cac6ca95 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Recipe.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Recipe.java @@ -24,6 +24,7 @@ package com.shatteredpixel.shatteredpixeldungeon.items; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.items.food.Blandfruit; import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion; +import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.darts.TippedDart; import java.util.ArrayList; @@ -111,7 +112,7 @@ public abstract class Recipe { //******* private static Recipe[] oneIngredientRecipes = new Recipe[]{ - + new Scroll.ScrollToStone() }; private static Recipe[] twoIngredientRecipes = new Recipe[]{ diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/Scroll.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/Scroll.java index 6ec48ff39..55c420949 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/Scroll.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/Scroll.java @@ -22,11 +22,15 @@ package com.shatteredpixel.shatteredpixeldungeon.items.scrolls; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; +import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Blindness; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.ItemStatusHandler; +import com.shatteredpixel.shatteredpixeldungeon.items.Recipe; import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.UnstableSpellbook; +import com.shatteredpixel.shatteredpixeldungeon.items.stones.Runestone; +import com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfIntuition; import com.shatteredpixel.shatteredpixeldungeon.journal.Catalog; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.sprites.HeroSprite; @@ -226,4 +230,60 @@ public abstract class Scroll extends Item { public int price() { return 30 * quantity; } + + public static class ScrollToStone extends Recipe { + + private static HashMap, Class> stones = new HashMap<>(); + private static HashMap, Integer> amnts = new HashMap<>(); + //TODO add more stones as they are implemented + static { + stones.put(ScrollOfIdentify.class, StoneOfIntuition.class); + amnts.put(ScrollOfIdentify.class, 2); + } + + @Override + public boolean testIngredients(ArrayList ingredients) { + if (ingredients.size() != 1 + || !(ingredients.get(0) instanceof Scroll) + || !stones.containsKey(ingredients.get(0).getClass())){ + return false; + } + + return true; + } + + @Override + public int cost(ArrayList ingredients) { + return 0; + } + + @Override + public Item brew(ArrayList ingredients) { + if (!testIngredients(ingredients)) return null; + + Scroll s = (Scroll) ingredients.get(0); + + s.quantity(s.quantity() - 1); + + try{ + return stones.get(s.getClass()).newInstance().quantity(amnts.get(s.getClass())); + } catch (Exception e) { + ShatteredPixelDungeon.reportException(e); + return null; + } + } + + @Override + public Item sampleOutput(ArrayList ingredients) { + if (!testIngredients(ingredients)) return null; + + try{ + Scroll s = (Scroll) ingredients.get(0); + return stones.get(s.getClass()).newInstance().quantity(amnts.get(s.getClass())); + } catch (Exception e) { + ShatteredPixelDungeon.reportException(e); + return null; + } + } + } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java index ea4a15fdd..692a6cd5b3 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java @@ -35,7 +35,6 @@ import com.shatteredpixel.shatteredpixeldungeon.items.bags.MagicalHolster; 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.Blandfruit; import com.shatteredpixel.shatteredpixeldungeon.items.food.Food; import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll; @@ -43,9 +42,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MeleeWeapon; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Boomerang; -import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.darts.Dart; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; -import com.shatteredpixel.shatteredpixeldungeon.plants.BlandfruitBush; import com.shatteredpixel.shatteredpixeldungeon.plants.Plant.Seed; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; @@ -399,7 +396,7 @@ public class WndBag extends WndTabbed { mode == Mode.SCROLL && (item instanceof Scroll) || mode == Mode.UNIDED_POTION_OR_SCROLL && (!item.isIdentified() && (item instanceof Scroll || item instanceof Potion)) || mode == Mode.EQUIPMENT && (item instanceof EquipableItem) || - mode == Mode.ALCHEMY && ((item instanceof Seed && !(item instanceof BlandfruitBush.Seed)) || (item instanceof Blandfruit && ((Blandfruit) item).potionAttrib == null) || (item.getClass() == Dart.class)) || + mode == Mode.ALCHEMY && (!(item instanceof EquipableItem) && item.isIdentified()) || mode == Mode.ALL ); //extra logic for cursed weapons or armor