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>
71 lines
1.4 KiB
PHP
71 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
/**
|
|
* @property int $id
|
|
* @property int $character_id
|
|
* @property int $crime_id
|
|
* @property bool $success
|
|
* @property int $reward
|
|
* @property int $experience_gained
|
|
* @property \Illuminate\Support\Carbon $attempted_at
|
|
*/
|
|
class CrimeAttempt extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'character_id',
|
|
'crime_id',
|
|
'success',
|
|
'reward',
|
|
'experience_gained',
|
|
'nerve_cost',
|
|
'attempted_at',
|
|
];
|
|
|
|
protected $casts = [
|
|
'success' => 'boolean',
|
|
'attempted_at' => 'datetime',
|
|
];
|
|
|
|
public $timestamps = false;
|
|
|
|
/**
|
|
* Get the character who attempted this crime.
|
|
*/
|
|
public function character(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Character::class);
|
|
}
|
|
|
|
/**
|
|
* Get the crime that was attempted.
|
|
*/
|
|
public function crime(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Crime::class);
|
|
}
|
|
|
|
/**
|
|
* Check if the crime was successful
|
|
*/
|
|
public function isSuccessful(): bool
|
|
{
|
|
return $this->success;
|
|
}
|
|
|
|
/**
|
|
* Check if the crime failed
|
|
*/
|
|
public function isFailed(): bool
|
|
{
|
|
return !$this->success;
|
|
}
|
|
}
|