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',
|
'max_energy',
|
||||||
'health',
|
'health',
|
||||||
'max_health',
|
'max_health',
|
||||||
|
'nerve',
|
||||||
|
'max_nerve',
|
||||||
|
'nerve_regen_at',
|
||||||
'strength',
|
'strength',
|
||||||
'defense',
|
'defense',
|
||||||
'speed',
|
'speed',
|
||||||
@@ -66,6 +69,7 @@ class Character extends Model
|
|||||||
'in_hospital_until' => 'datetime',
|
'in_hospital_until' => 'datetime',
|
||||||
'in_jail_until' => 'datetime',
|
'in_jail_until' => 'datetime',
|
||||||
'last_action_at' => 'datetime',
|
'last_action_at' => 'datetime',
|
||||||
|
'nerve_regen_at' => 'datetime',
|
||||||
'status' => CharacterStatus::class,
|
'status' => CharacterStatus::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -251,6 +255,49 @@ class Character extends Model
|
|||||||
$this->save();
|
$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
|
* Set energy to max
|
||||||
*/
|
*/
|
||||||
@@ -317,6 +364,7 @@ class Character extends Model
|
|||||||
$this->experience -= $this->experience_for_next_level;
|
$this->experience -= $this->experience_for_next_level;
|
||||||
$this->max_health += 5;
|
$this->max_health += 5;
|
||||||
$this->max_energy += 5;
|
$this->max_energy += 5;
|
||||||
|
$this->max_nerve += 2;
|
||||||
$this->health = $this->max_health;
|
$this->health = $this->max_health;
|
||||||
$this->energy = $this->max_energy;
|
$this->energy = $this->max_energy;
|
||||||
$this->money += 1000;
|
$this->money += 1000;
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
|||||||
* @property int $reward_max
|
* @property int $reward_max
|
||||||
* @property int $experience
|
* @property int $experience
|
||||||
* @property int $energy_cost
|
* @property int $energy_cost
|
||||||
|
* @property int $nerve_cost
|
||||||
* @property int $cooldown
|
* @property int $cooldown
|
||||||
* @property int|null $requires_level
|
* @property int|null $requires_level
|
||||||
* @property int|null $location_id
|
* @property int|null $location_id
|
||||||
@@ -39,6 +40,7 @@ class Crime extends Model
|
|||||||
'reward_max',
|
'reward_max',
|
||||||
'experience',
|
'experience',
|
||||||
'energy_cost',
|
'energy_cost',
|
||||||
|
'nerve_cost',
|
||||||
'cooldown',
|
'cooldown',
|
||||||
'requires_level',
|
'requires_level',
|
||||||
'location_id',
|
'location_id',
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ class CrimeAttempt extends Model
|
|||||||
'success',
|
'success',
|
||||||
'reward',
|
'reward',
|
||||||
'experience_gained',
|
'experience_gained',
|
||||||
|
'nerve_cost',
|
||||||
'attempted_at',
|
'attempted_at',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ return [
|
|||||||
'attack' => 15,
|
'attack' => 15,
|
||||||
'travel' => 5,
|
'travel' => 5,
|
||||||
'train' => 20,
|
'train' => 20,
|
||||||
|
'gym' => 20,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
@@ -40,6 +41,22 @@ return [
|
|||||||
'death_threshold' => 0, // Health <= 0 = dead
|
'death_threshold' => 0, // Health <= 0 = dead
|
||||||
],
|
],
|
||||||
|
|
||||||
|
// Nerve system configuration
|
||||||
|
'nerve' => [
|
||||||
|
'start_amount' => 100,
|
||||||
|
'max' => 100,
|
||||||
|
'regen_rate' => 1, // nerve per tick
|
||||||
|
'regen_interval' => 300, // seconds (5 minutes)
|
||||||
|
'midnight_refill' => true,
|
||||||
|
],
|
||||||
|
|
||||||
|
// Gym training configuration
|
||||||
|
'gym' => [
|
||||||
|
'energy_cost' => 20,
|
||||||
|
'daily_cap' => 5, // sessions per stat per day
|
||||||
|
'stat_gain' => 1, // stat points per session
|
||||||
|
],
|
||||||
|
|
||||||
// Combat system configuration
|
// Combat system configuration
|
||||||
'combat' => [
|
'combat' => [
|
||||||
'base_damage' => 5,
|
'base_damage' => 5,
|
||||||
|
|||||||
Reference in New Issue
Block a user