51 lines
1.0 KiB
PHP
51 lines
1.0 KiB
PHP
<?php
|
|||
|
|
|
||
|
|
namespace App\Enums;
|
||
|
|
|
||
|
|
enum ItemType: string
|
||
|
|
{
|
||
|
|
case WEAPON = 'weapon';
|
||
|
|
case ARMOR = 'armor';
|
||
|
|
case CONSUMABLE = 'consumable';
|
||
|
|
case MISC = 'misc';
|
||
|
|
case CURRENCY = 'currency';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Get all item type values as an array
|
||
|
|
*/
|
||
|
|
public static function values(): array
|
||
|
|
{
|
||
|
|
return array_column(self::cases(), 'value');
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Get the display name for an item type
|
||
|
|
*/
|
||
|
|
public function label(): string
|
||
|
|
{
|
||
|
|
return match($this) {
|
||
|
|
self::WEAPON => 'Weapon',
|
||
|
|
self::ARMOR => 'Armor',
|
||
|
|
self::CONSUMABLE => 'Consumable',
|
||
|
|
self::MISC => 'Miscellaneous',
|
||
|
|
self::CURRENCY => 'Currency',
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Check if this item type can be equipped
|
||
|
|
*/
|
||
|
|
public function canEquip(): bool
|
||
|
|
{
|
||
|
|
return in_array($this, [self::WEAPON, self::ARMOR]);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Check if this item type can be used/consumed
|
||
|
|
*/
|
||
|
|
public function canUse(): bool
|
||
|
|
{
|
||
|
|
return $this === self::CONSUMABLE;
|
||
|
|
}
|
||
|
|
}
|