extend(TestCase::class)->use(RefreshDatabase::class) ->beforeEach(fn () => config(['game.world.map.barbarians.count' => 0])) ->in('Feature'); /** The default game config without booting Laravel, so unit tests stay pure. */ function gameConfig(array $overrides = []): WorldConfig { $dir = __DIR__.'/../config/game'; return WorldConfig::make([ 'world' => require "$dir/world.php", 'economy' => require "$dir/economy.php", 'buildings' => require "$dir/buildings.php", 'units' => require "$dir/units.php", ], $overrides); } function building(int $id, string $type, int $level = 0, int $priority = 5): BuildingState { return new BuildingState($id, $type, $level, $priority); } /** A user with a fresh start village in World 1 (speed 1). */ function startVillage(?User $user = null): Village { (new WorldSeeder)->run(); return app(JoinWorld::class)($user ?? User::factory()->create(), World::where('slug', 'w1')->value('id')); } function owner(Village $village): User { return $village->player->user; } /** The client payload, as `village.show` would send it now. */ function shown(Village $village): array { return VillagePresenter::present(app(ShowVillage::class)(owner($village), $village->id), now()->toImmutable()); } function rule(Closure $intent): string { try { $intent(); } catch (GameRuleViolation $e) { return $e->reason; } throw new RuntimeException('Expected a GameRuleViolation.'); }