diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/ItemStatusHandler.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/ItemStatusHandler.java index 33666152e..d723913f0 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/ItemStatusHandler.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/ItemStatusHandler.java @@ -182,6 +182,10 @@ public class ItemStatusHandler { known.add( (Class)item.getClass() ); } + public void know( Class itemCls ){ + known.add( itemCls ); + } + public HashSet> known() { return known; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/Potion.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/Potion.java index 91b1d397b..bc493ee7f 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/Potion.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/Potion.java @@ -39,6 +39,8 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Generator; import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.ItemStatusHandler; import com.shatteredpixel.shatteredpixeldungeon.items.Recipe; +import com.shatteredpixel.shatteredpixeldungeon.items.bags.Bag; +import com.shatteredpixel.shatteredpixeldungeon.items.potions.exotic.ExoticPotion; import com.shatteredpixel.shatteredpixeldungeon.journal.Catalog; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; @@ -168,12 +170,26 @@ public class Potion extends Item { image = handler.image(this); color = handler.label(this); } - if (isKnown()){ - if (mustThrowPots.contains(this.getClass())) { - defaultAction = AC_THROW; - } else if (canThrowPots.contains(this.getClass())){ - defaultAction = AC_CHOOSE; - } + setAction(); + } + + @Override + public boolean collect( Bag container ) { + if (super.collect( container )){ + setAction(); + return true; + } else { + return false; + } + } + + public void setAction(){ + if (isKnown() && mustThrowPots.contains(this.getClass())) { + defaultAction = AC_THROW; + } else if (isKnown() &&canThrowPots.contains(this.getClass())){ + defaultAction = AC_CHOOSE; + } else { + defaultAction = AC_DRINK; } } @@ -295,11 +311,10 @@ public class Potion extends Item { if (!isKnown()) { handler.know(this); updateQuickslot(); - if (mustThrowPots.contains(this.getClass())){ - defaultAction = AC_THROW; - } else if (canThrowPots.contains(this.getClass())){ - defaultAction = AC_CHOOSE; - } + Potion p = Dungeon.hero.belongings.getItem(getClass()); + if (p != null) p.setAction(); + p = Dungeon.hero.belongings.getItem(ExoticPotion.regToExo.get(getClass())); + if (p != null) p.setAction(); } if (Dungeon.hero.isAlive()) { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/exotic/ExoticPotion.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/exotic/ExoticPotion.java index 12aef8069..5cbd41176 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/exotic/ExoticPotion.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/exotic/ExoticPotion.java @@ -21,6 +21,7 @@ package com.shatteredpixel.shatteredpixeldungeon.items.potions.exotic; +import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.Recipe; @@ -46,17 +47,35 @@ public class ExoticPotion extends Potion { @Override public boolean isKnown() { - //assume it is IDed as ided potions are needed for alchemy - return true; + return handler != null && handler.isKnown( exoToReg.get(this.getClass()) ); + } + + @Override + public void setKnown() { + if (!isKnown()) { + handler.know(exoToReg.get(this.getClass())); + updateQuickslot(); + Potion p = Dungeon.hero.belongings.getItem(getClass()); + if (p != null) p.setAction(); + p = Dungeon.hero.belongings.getItem(exoToReg.get(this.getClass())); + if (p != null) p.setAction(); + } } @Override public void reset() { + super.reset(); if (handler != null && handler.contains(exoToReg.get(this.getClass()))) { image = handler.image(exoToReg.get(this.getClass())) + 16; } } + //TODO + @Override + public int price() { + return super.price(); + } + public static class PotionToExotic extends Recipe{ @Override diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/exotic/ExoticScroll.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/exotic/ExoticScroll.java index ca41b2fd4..072166da3 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/exotic/ExoticScroll.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/exotic/ExoticScroll.java @@ -43,12 +43,20 @@ public abstract class ExoticScroll extends Scroll { @Override public boolean isKnown() { - //assume it is IDed as ided scrolls are needed for alchemy - return true; + return handler != null && handler.isKnown( exoToReg.get(this.getClass()) ); + } + + @Override + public void setKnown() { + if (!isKnown()) { + handler.know(exoToReg.get(this.getClass())); + updateQuickslot(); + } } @Override public void reset() { + super.reset(); if (handler != null && handler.contains(exoToReg.get(this.getClass()))) { image = handler.image(exoToReg.get(this.getClass())) + 16; } @@ -59,6 +67,12 @@ public abstract class ExoticScroll extends Scroll { } + //TODO + @Override + public int price() { + return super.price(); + } + public static class ScrollToExotic extends Recipe { @Override