fix: address final review findings — nerve consume ordering, character init, seeder costs, dead column
- Consume nerve before energy in CrimeService so energy is never lost when nerve is insufficient - Initialize nerve/max_nerve from config in CharacterController::store (same pattern as energy/health) - Add nerve_cost to all CrimeSeeder entries proportional to difficulty (1-5 range) - Remove nerve_regen_at from Character $fillable/$casts/@property — column exists but is not yet wired up Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
439f6740c0
commit
3e6a84503d
@@ -74,6 +74,8 @@ class CharacterController extends Controller
|
||||
'max_energy' => config('game.energy.max', 100),
|
||||
'health' => config('game.health.start_amount', 100),
|
||||
'max_health' => config('game.health.max', 100),
|
||||
'nerve' => config('game.nerve.start_amount', 100),
|
||||
'max_nerve' => config('game.nerve.max', 100),
|
||||
'strength' => 5,
|
||||
'defense' => 5,
|
||||
'speed' => 5,
|
||||
|
||||
@@ -21,7 +21,6 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
* @property int $max_energy
|
||||
* @property int $nerve
|
||||
* @property int $max_nerve
|
||||
* @property \Illuminate\Support\Carbon|null $nerve_regen_at
|
||||
* @property int $health
|
||||
* @property int $max_health
|
||||
* @property int $strength
|
||||
@@ -53,7 +52,6 @@ class Character extends Model
|
||||
'max_energy',
|
||||
'nerve',
|
||||
'max_nerve',
|
||||
'nerve_regen_at',
|
||||
'health',
|
||||
'max_health',
|
||||
'strength',
|
||||
@@ -72,7 +70,6 @@ class Character extends Model
|
||||
'in_hospital_until' => 'datetime',
|
||||
'in_jail_until' => 'datetime',
|
||||
'last_action_at' => 'datetime',
|
||||
'nerve_regen_at' => 'datetime',
|
||||
'status' => CharacterStatus::class,
|
||||
];
|
||||
|
||||
|
||||
@@ -37,16 +37,16 @@ class CrimeService
|
||||
throw new \Exception('Character cannot perform actions right now.');
|
||||
}
|
||||
|
||||
// Consume nerve first so energy is never deducted if nerve is insufficient
|
||||
if (!$this->nerveService->consume($character, $crime->nerve_cost)) {
|
||||
throw new \Exception('Not enough nerve to attempt this crime.');
|
||||
}
|
||||
|
||||
// Consume energy
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user