first commit
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user