v0.7.0: made reset functionality less brittle for potions/scrolls/rings

This commit is contained in:
Evan Debenham 2018-06-24 21:20:30 -04:00
parent be2fcf0a72
commit 5f615bb178
4 changed files with 12 additions and 3 deletions

View File

@ -136,6 +136,15 @@ public class ItemStatusHandler<T extends Item> {
}
}
public boolean contains( T item ){
for (Class<?extends Item> i : items){
if (item.getClass().equals(i)){
return true;
}
}
return false;
}
public int image( T item ) {
return labelImages.get(label(item));
}

View File

@ -146,7 +146,7 @@ public class Potion extends Item {
@Override
public void reset(){
super.reset();
if (handler != null) {
if (handler != null && handler.contains(this)) {
image = handler.image(this);
color = handler.label(this);
}

View File

@ -108,7 +108,7 @@ public class Ring extends KindofMisc {
public void reset() {
super.reset();
if (handler != null){
if (handler != null && handler.contains(this)){
image = handler.image(this);
gem = handler.label(this);
}

View File

@ -130,7 +130,7 @@ public abstract class Scroll extends Item {
@Override
public void reset(){
super.reset();
if (handler != null) {
if (handler != null && handler.contains(this)) {
image = handler.image(this);
rune = handler.label(this);
}