add item classes

This commit is contained in:
Ramtin Jafari
2026-07-07 18:11:38 +03:30
parent 43ee0c1562
commit 7f41ccf7b5
2 changed files with 37 additions and 0 deletions
@@ -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;
};
}
}