feat: add nerve config and Character nerve methods

Add nerve system configuration to config/game.php with start_amount,
max, regen_rate, regen_interval, and midnight_refill settings. Add gym
configuration with energy_cost, daily_cap, and stat_gain. Add nerve
methods to Character model: hasNerve(), consumeNerve(), addNerve(), and
getNervePercentageAttribute(). Update levelUp() to increment max_nerve
by 2. Add nerve_cost to fillable arrays in Crime and CrimeAttempt models.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Doar Mihai
2026-06-28 15:52:41 +03:00
co-authored by Claude Sonnet 4.6
parent 536269cbb5
commit 6182563fa7
4 changed files with 68 additions and 0 deletions
+48
View File
@@ -50,6 +50,9 @@ class Character extends Model
'max_energy',
'health',
'max_health',
'nerve',
'max_nerve',
'nerve_regen_at',
'strength',
'defense',
'speed',
@@ -66,6 +69,7 @@ class Character extends Model
'in_hospital_until' => 'datetime',
'in_jail_until' => 'datetime',
'last_action_at' => 'datetime',
'nerve_regen_at' => 'datetime',
'status' => CharacterStatus::class,
];
@@ -251,6 +255,49 @@ class Character extends Model
$this->save();
}
/**
* Check if character has enough nerve for an action
*/
public function hasNerve(int $amount): bool
{
return $this->nerve >= $amount;
}
/**
* Consume nerve
*/
public function consumeNerve(int $amount): bool
{
if (!$this->hasNerve($amount)) {
return false;
}
$this->nerve -= $amount;
$this->save();
return true;
}
/**
* Add nerve (up to max)
*/
public function addNerve(int $amount): void
{
$this->nerve = min($this->max_nerve, $this->nerve + $amount);
$this->save();
}
/**
* Get nerve percentage
*/
public function getNervePercentageAttribute(): float
{
if ($this->max_nerve <= 0) {
return 0;
}
return min(100, ($this->nerve / $this->max_nerve) * 100);
}
/**
* Set energy to max
*/
@@ -317,6 +364,7 @@ class Character extends Model
$this->experience -= $this->experience_for_next_level;
$this->max_health += 5;
$this->max_energy += 5;
$this->max_nerve += 2;
$this->health = $this->max_health;
$this->energy = $this->max_energy;
$this->money += 1000;