2026-10-28 20:39:48 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Actions;
|
|
|
|
|
|
|
|
|
|
use App\Engine\Military;
|
2026-10-29 09:05:55 +00:00
|
|
|
use App\Engine\Quests;
|
2026-10-28 20:39:48 +00:00
|
|
|
use App\Engine\Simulation;
|
|
|
|
|
use App\Models\User;
|
|
|
|
|
use App\Models\Village;
|
|
|
|
|
use Carbon\CarbonImmutable;
|
|
|
|
|
|
|
|
|
|
/** Train units at one military building; its queue runs on its own. */
|
|
|
|
|
final class Recruit extends VillageAction
|
|
|
|
|
{
|
|
|
|
|
public function __invoke(User $user, int $villageId, int $buildingId, string $unit, int $count): Village
|
|
|
|
|
{
|
|
|
|
|
return $this->mutate($user, $villageId, function (Simulation $sim, Village $village, CarbonImmutable $now) use ($buildingId, $unit, $count) {
|
|
|
|
|
Military::of($village, $sim)->recruit($this->building($village, $buildingId), $unit, $count, $now);
|
2026-10-29 09:05:55 +00:00
|
|
|
Quests::bump($village->player_id, "recruited.$unit", $count);
|
2026-10-28 20:39:48 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|