diff --git a/app/Models/Crime.php b/app/Models/Crime.php index 6a9194b..e22e64c 100644 --- a/app/Models/Crime.php +++ b/app/Models/Crime.php @@ -76,17 +76,22 @@ class Crime extends Model if ($this->requires_level && $character->level < $this->requires_level) { return false; } - + // Check energy if ($character->energy < $this->energy_cost) { return false; } - + + // Check nerve + if ($character->nerve < $this->nerve_cost) { + return false; + } + // Check location (if crime is location-specific) if ($this->location_id && $character->location_id !== $this->location_id) { return false; } - + return true; } diff --git a/app/Services/Game/CrimeService.php b/app/Services/Game/CrimeService.php index 1ad9324..c289f2a 100644 --- a/app/Services/Game/CrimeService.php +++ b/app/Services/Game/CrimeService.php @@ -7,16 +7,19 @@ use App\Models\Crime; use App\Models\CrimeAttempt; use App\Models\ActivityLog; use App\Enums\CharacterStatus; +use App\Services\Game\NerveService; class CrimeService { protected EnergyService $energyService; protected EconomyService $economyService; + protected NerveService $nerveService; public function __construct() { $this->energyService = new EnergyService(); $this->economyService = new EconomyService(); + $this->nerveService = new NerveService(); } /** @@ -38,7 +41,12 @@ class CrimeService if (!$this->energyService->consume($character, $crime->energy_cost, 'crime')) { throw new \Exception('Not enough energy to attempt this crime.'); } - + + // Consume nerve + if (!$this->nerveService->consume($character, $crime->nerve_cost)) { + throw new \Exception('Not enough nerve to attempt this crime.'); + } + // Calculate success rate $successRate = $crime->calculateSuccessRate($character); $isSuccess = random_int(0, 9999) / 10000 <= $successRate; @@ -77,6 +85,7 @@ class CrimeService 'success' => $isSuccess, 'reward' => $reward, 'experience_gained' => $experience, + 'nerve_cost' => $crime->nerve_cost, 'attempted_at' => now(), ]);