v0.7.0: adjusted "owned by X" variable in pots/scrolls, now 'anonymized'

This commit is contained in:
Evan Debenham
2018-09-25 20:19:01 -04:00
parent 68831ed406
commit 8c1fa0b0ff
7 changed files with 31 additions and 16 deletions
@@ -123,7 +123,7 @@ public class UnstableSpellbook extends Artifact {
|| (scroll instanceof ScrollOfTeleportation && Dungeon.bossLevel()) || (scroll instanceof ScrollOfTeleportation && Dungeon.bossLevel())
|| (scroll instanceof ScrollOfTransmutation)); || (scroll instanceof ScrollOfTransmutation));
scroll.ownedByBook = true; scroll.anonymize();
curItem = scroll; curItem = scroll;
curUser = hero; curUser = hero;
@@ -137,7 +137,7 @@ public class Blandfruit extends Food {
public Item imbuePotion(Potion potion){ public Item imbuePotion(Potion potion){
potionAttrib = potion; potionAttrib = potion;
potionAttrib.ownedByFruit = true; potionAttrib.anonymize();
potionAttrib.image = ItemSpriteSheet.BLANDFRUIT; potionAttrib.image = ItemSpriteSheet.BLANDFRUIT;
@@ -152,8 +152,6 @@ public class Potion extends Item {
protected static ItemStatusHandler<Potion> handler; protected static ItemStatusHandler<Potion> handler;
protected String color; protected String color;
public boolean ownedByFruit = false;
{ {
stackable = true; stackable = true;
@@ -182,6 +180,15 @@ public class Potion extends Item {
super(); super();
reset(); 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 @Override
public void reset(){ public void reset(){
@@ -323,11 +330,11 @@ public class Potion extends Item {
} }
public boolean isKnown() { public boolean isKnown() {
return handler != null && handler.isKnown( this ); return anonymous || (handler != null && handler.isKnown( this ));
} }
public void setKnown() { public void setKnown() {
if (!ownedByFruit) { if (!anonymous) {
if (!isKnown()) { if (!isKnown()) {
handler.know(this); handler.know(this);
updateQuickslot(); updateQuickslot();
@@ -91,7 +91,7 @@ public class ExoticPotion extends Potion {
@Override @Override
public boolean isKnown() { public boolean isKnown() {
return handler != null && handler.isKnown( exoToReg.get(this.getClass()) ); return anonymous || (handler != null && handler.isKnown( exoToReg.get(this.getClass()) ));
} }
@Override @Override
@@ -88,11 +88,11 @@ public abstract class InventoryScroll extends Scroll {
Sample.INSTANCE.play( Assets.SND_READ ); Sample.INSTANCE.play( Assets.SND_READ );
Invisibility.dispel(); Invisibility.dispel();
} else if (identifiedByUse && !((Scroll)curItem).ownedByBook) { } else if (identifiedByUse && !((Scroll)curItem).anonymous) {
((InventoryScroll)curItem).confirmCancelation(); ((InventoryScroll)curItem).confirmCancelation();
} else if (!((Scroll)curItem).ownedByBook) { } else if (!((Scroll)curItem).anonymous) {
curItem.collect( curUser.belongings.backpack ); curItem.collect( curUser.belongings.backpack );
@@ -98,8 +98,6 @@ public abstract class Scroll extends Item {
protected static ItemStatusHandler<Scroll> handler; protected static ItemStatusHandler<Scroll> handler;
protected String rune; protected String rune;
public boolean ownedByBook = false;
{ {
stackable = true; stackable = true;
@@ -128,7 +126,17 @@ public abstract class Scroll extends Item {
super(); super();
reset(); 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 @Override
public void reset(){ public void reset(){
super.reset(); super.reset();
@@ -181,11 +189,11 @@ public abstract class Scroll extends Item {
} }
public boolean isKnown() { public boolean isKnown() {
return handler != null && handler.isKnown( this ); return anonymous || (handler != null && handler.isKnown( this ));
} }
public void setKnown() { public void setKnown() {
if (!ownedByBook) { if (!anonymous) {
if (!isKnown()) { if (!isKnown()) {
handler.know(this); handler.know(this);
updateQuickslot(); updateQuickslot();
@@ -90,12 +90,12 @@ public abstract class ExoticScroll extends Scroll {
@Override @Override
public boolean isKnown() { public boolean isKnown() {
return handler != null && handler.isKnown( exoToReg.get(this.getClass()) ); return anonymous || (handler != null && handler.isKnown( exoToReg.get(this.getClass()) ));
} }
@Override @Override
public void setKnown() { public void setKnown() {
if (!ownedByBook && !isKnown()) { if (isKnown()) {
handler.know(exoToReg.get(this.getClass())); handler.know(exoToReg.get(this.getClass()));
updateQuickslot(); updateQuickslot();
} }