23 lines
548 B
PHP
23 lines
548 B
PHP
<?php
|
|
|
|
namespace App\Actions;
|
|
|
|
use App\Game\GameRuleViolation;
|
|
use App\Models\User;
|
|
use App\Models\Village;
|
|
|
|
final class ShowVillage extends VillageAction
|
|
{
|
|
public function __invoke(User $user, int $villageId): Village
|
|
{
|
|
$this->engine->catchUp($villageId, now()->toImmutable());
|
|
|
|
$village = Village::with('player')->find($villageId);
|
|
if (! $village || $village->player?->user_id !== $user->id) {
|
|
throw new GameRuleViolation('not_found', 'Village not found.');
|
|
}
|
|
|
|
return $village;
|
|
}
|
|
}
|