Files
thecrimesynticate/app/Console/Commands/Game/ProcessHealthRegen.php
T
2026-06-27 14:38:18 +03:00

48 lines
1.1 KiB
PHP

<?php
namespace App\Console\Commands\Game;
use App\Models\Character;
use App\Services\Game\HealthService;
use Illuminate\Console\Command;
class ProcessHealthRegen extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'game:regen-health';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Regenerate health for all characters';
/**
* Execute the console command.
*/
public function handle(HealthService $healthService): void
{
$this->info('Starting health regeneration...');
$characters = Character::where('health', '<', \DB::raw('max_health'))
->where('status', 'active')
->where('health', '>', 0)
->get();
$count = $characters->count();
$this->info("Regenerating health for {$count} characters...");
foreach ($characters as $character) {
$healthService->regenerate($character);
}
$this->info('Health regeneration completed!');
}
}