add item classes
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
package org.project.constants.gameConstant;
|
||||
|
||||
public enum ItemClass {
|
||||
KEY,
|
||||
SELLABLE,
|
||||
UNNECESSARY,
|
||||
ACCESSORY,
|
||||
SHIELD,
|
||||
WEAPON,
|
||||
COSTUME,
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package org.project.constants.gameConstant;
|
||||
|
||||
import org.project.item.Accessory.Accessory;
|
||||
import org.project.item.Accessory.Costume;
|
||||
import org.project.item.Accessory.Shield;
|
||||
import org.project.item.Accessory.Weapon;
|
||||
import org.project.item.KeyItem;
|
||||
import org.project.item.SellableItem;
|
||||
|
||||
public final class ItemClassExt {
|
||||
private ItemClassExt() {}
|
||||
|
||||
public static boolean Matches(ItemClass itemClass, Object subject) {
|
||||
return switch (itemClass) {
|
||||
case KEY -> subject instanceof KeyItem;
|
||||
case SELLABLE -> subject instanceof SellableItem;
|
||||
case UNNECESSARY -> subject.getClass() == SellableItem.class;
|
||||
case ACCESSORY -> subject instanceof Accessory;
|
||||
case WEAPON -> subject instanceof Weapon;
|
||||
case COSTUME -> subject instanceof Costume;
|
||||
case SHIELD -> subject instanceof Shield;
|
||||
case null, default -> false;
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user