feat: add NerveService and nerve regen scheduled commands

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Doar Mihai
2026-06-28 16:10:26 +03:00
co-authored by Claude Sonnet 4.6
parent e7940d31f6
commit 6e2ea7bcc7
4 changed files with 91 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
<?php
namespace App\Services\Game;
use App\Models\Character;
class NerveService
{
public function consume(Character $character, int $amount): bool
{
if (!$character->canAct()) {
return false;
}
return $character->consumeNerve($amount);
}
public function regenerate(Character $character): void
{
$regenRate = config('game.nerve.regen_rate', 1);
if ($character->max_nerve <= 0) {
$character->max_nerve = config('game.nerve.max', 100);
}
$character->addNerve($regenRate);
}
public function refillAll(): int
{
return Character::where('nerve', '<', \DB::raw('max_nerve'))
->where('status', 'active')
->update(['nerve' => \DB::raw('max_nerve')]);
}
}