first commit
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum CrimeDifficulty: string
|
||||
{
|
||||
case EASY = 'easy';
|
||||
case MEDIUM = 'medium';
|
||||
case HARD = 'hard';
|
||||
case VERY_HARD = 'very_hard';
|
||||
|
||||
/**
|
||||
* Get all difficulty values as an array
|
||||
*/
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the display name for a difficulty
|
||||
*/
|
||||
public function label(): string
|
||||
{
|
||||
return match($this) {
|
||||
self::EASY => 'Easy',
|
||||
self::MEDIUM => 'Medium',
|
||||
self::HARD => 'Hard',
|
||||
self::VERY_HARD => 'Very Hard',
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the success rate modifier for this difficulty
|
||||
*/
|
||||
public function successModifier(): float
|
||||
{
|
||||
return match($this) {
|
||||
self::EASY => 0.20, // +20% success rate
|
||||
self::MEDIUM => 0.00, // Base success rate
|
||||
self::HARD => -0.20, // -20% success rate
|
||||
self::VERY_HARD => -0.40,// -40% success rate
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the reward multiplier for this difficulty
|
||||
*/
|
||||
public function rewardMultiplier(): float
|
||||
{
|
||||
return match($this) {
|
||||
self::EASY => 0.5,
|
||||
self::MEDIUM => 1.0,
|
||||
self::HARD => 2.0,
|
||||
self::VERY_HARD => 3.0,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the color class for the difficulty badge
|
||||
*/
|
||||
public function color(): string
|
||||
{
|
||||
return match($this) {
|
||||
self::EASY => 'bg-green-500',
|
||||
self::MEDIUM => 'bg-yellow-500',
|
||||
self::HARD => 'bg-orange-500',
|
||||
self::VERY_HARD => 'bg-red-500',
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user