diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/UnstableSpellbook.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/UnstableSpellbook.java index 0154c21f3..2ec28a1b6 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/UnstableSpellbook.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/UnstableSpellbook.java @@ -123,7 +123,7 @@ public class UnstableSpellbook extends Artifact { || (scroll instanceof ScrollOfTeleportation && Dungeon.bossLevel()) || (scroll instanceof ScrollOfTransmutation)); - scroll.ownedByBook = true; + scroll.anonymize(); curItem = scroll; curUser = hero; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/food/Blandfruit.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/food/Blandfruit.java index 439b77302..96d8ef5e7 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/food/Blandfruit.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/food/Blandfruit.java @@ -137,7 +137,7 @@ public class Blandfruit extends Food { public Item imbuePotion(Potion potion){ potionAttrib = potion; - potionAttrib.ownedByFruit = true; + potionAttrib.anonymize(); potionAttrib.image = ItemSpriteSheet.BLANDFRUIT; 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 6e768334c..8b7f8c224 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 @@ -152,8 +152,6 @@ public class Potion extends Item { protected static ItemStatusHandler handler; protected String color; - - public boolean ownedByFruit = false; { stackable = true; @@ -182,6 +180,15 @@ public class Potion extends Item { super(); reset(); } + + //anonymous potions are always IDed, do not affect ID status, + //and their sprite is replaced by a placeholder if they are not known, + //useful for items that appear in UIs, or which are only spawned for their effects + protected boolean anonymous = false; + public void anonymize(){ + if (!isKnown()) image = ItemSpriteSheet.POTION_HOLDER; + anonymous = true; + } @Override public void reset(){ @@ -323,11 +330,11 @@ public class Potion extends Item { } public boolean isKnown() { - return handler != null && handler.isKnown( this ); + return anonymous || (handler != null && handler.isKnown( this )); } public void setKnown() { - if (!ownedByFruit) { + if (!anonymous) { if (!isKnown()) { handler.know(this); updateQuickslot(); 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 dd922d259..e7a14bd47 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 @@ -91,7 +91,7 @@ public class ExoticPotion extends Potion { @Override public boolean isKnown() { - return handler != null && handler.isKnown( exoToReg.get(this.getClass()) ); + return anonymous || (handler != null && handler.isKnown( exoToReg.get(this.getClass()) )); } @Override diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/InventoryScroll.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/InventoryScroll.java index f18281816..18a677685 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/InventoryScroll.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/InventoryScroll.java @@ -88,11 +88,11 @@ public abstract class InventoryScroll extends Scroll { Sample.INSTANCE.play( Assets.SND_READ ); Invisibility.dispel(); - } else if (identifiedByUse && !((Scroll)curItem).ownedByBook) { + } else if (identifiedByUse && !((Scroll)curItem).anonymous) { ((InventoryScroll)curItem).confirmCancelation(); - } else if (!((Scroll)curItem).ownedByBook) { + } else if (!((Scroll)curItem).anonymous) { curItem.collect( curUser.belongings.backpack ); 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 e7e84ca2c..55bd29ec8 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 @@ -98,8 +98,6 @@ public abstract class Scroll extends Item { protected static ItemStatusHandler handler; protected String rune; - - public boolean ownedByBook = false; { stackable = true; @@ -128,7 +126,17 @@ public abstract class Scroll extends Item { super(); reset(); } - + + //anonymous scrolls are always IDed, do not affect ID status, + //and their sprite is replaced by a placeholder if they are not known, + //useful for items that appear in UIs, or which are only spawned for their effects + protected boolean anonymous = false; + public void anonymize(){ + if (!isKnown()) image = ItemSpriteSheet.SCROLL_HOLDER; + anonymous = true; + } + + @Override public void reset(){ super.reset(); @@ -181,11 +189,11 @@ public abstract class Scroll extends Item { } public boolean isKnown() { - return handler != null && handler.isKnown( this ); + return anonymous || (handler != null && handler.isKnown( this )); } public void setKnown() { - if (!ownedByBook) { + if (!anonymous) { if (!isKnown()) { handler.know(this); updateQuickslot(); 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 c60de44d2..e85660973 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 @@ -90,12 +90,12 @@ public abstract class ExoticScroll extends Scroll { @Override public boolean isKnown() { - return handler != null && handler.isKnown( exoToReg.get(this.getClass()) ); + return anonymous || (handler != null && handler.isKnown( exoToReg.get(this.getClass()) )); } @Override public void setKnown() { - if (!ownedByBook && !isKnown()) { + if (isKnown()) { handler.know(exoToReg.get(this.getClass())); updateQuickslot(); }