2026-10-28 18:17:34 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Actions;
|
|
|
|
|
|
2026-10-29 09:05:55 +00:00
|
|
|
use App\Engine\Quests;
|
2026-10-28 18:17:34 +00:00
|
|
|
use App\Engine\Simulation;
|
|
|
|
|
use App\Models\User;
|
|
|
|
|
use App\Models\Village;
|
|
|
|
|
use Carbon\CarbonImmutable;
|
|
|
|
|
|
|
|
|
|
/** Workers go to higher priorities first (0..9). Settled first, since rates change. */
|
|
|
|
|
final class SetPriority extends VillageAction
|
|
|
|
|
{
|
|
|
|
|
public function __invoke(User $user, int $villageId, int $buildingId, int $priority): Village
|
|
|
|
|
{
|
|
|
|
|
return $this->mutate($user, $villageId, function (Simulation $sim, Village $village, CarbonImmutable $now) use ($buildingId, $priority) {
|
|
|
|
|
$building = $this->building($village, $buildingId);
|
|
|
|
|
$building->update(['priority' => max(0, min(9, $priority))]);
|
2026-10-29 09:05:55 +00:00
|
|
|
Quests::bump($village->player_id, 'priority.set');
|
2026-10-28 18:17:34 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|