first commit
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Game;
|
||||
|
||||
use App\Models\Character;
|
||||
use App\Services\Game\EnergyService;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class ProcessEnergyRegen extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'game:regen-energy';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Regenerate energy for all characters';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(EnergyService $energyService): void
|
||||
{
|
||||
$this->info('Starting energy regeneration...');
|
||||
|
||||
$characters = Character::where('energy', '<', \DB::raw('max_energy'))
|
||||
->where('status', 'active')
|
||||
->get();
|
||||
|
||||
$count = $characters->count();
|
||||
|
||||
$this->info("Regenerating energy for {$count} characters...");
|
||||
|
||||
foreach ($characters as $character) {
|
||||
$energyService->regenerate($character);
|
||||
}
|
||||
|
||||
$this->info('Energy regeneration completed!');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?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!');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user