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:
co-authored by
Claude Sonnet 4.6
parent
536269cbb5
commit
6182563fa7
@@ -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;
|
||||
|
||||
@@ -19,6 +19,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
* @property int $reward_max
|
||||
* @property int $experience
|
||||
* @property int $energy_cost
|
||||
* @property int $nerve_cost
|
||||
* @property int $cooldown
|
||||
* @property int|null $requires_level
|
||||
* @property int|null $location_id
|
||||
@@ -39,6 +40,7 @@ class Crime extends Model
|
||||
'reward_max',
|
||||
'experience',
|
||||
'energy_cost',
|
||||
'nerve_cost',
|
||||
'cooldown',
|
||||
'requires_level',
|
||||
'location_id',
|
||||
|
||||
@@ -25,6 +25,7 @@ class CrimeAttempt extends Model
|
||||
'success',
|
||||
'reward',
|
||||
'experience_gained',
|
||||
'nerve_cost',
|
||||
'attempted_at',
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user