$world) { $worlds[] = World::firstOrCreate(['slug' => $slug], [ 'name' => $world['name'], 'config' => ($world['config'] ?? []) ?: null, 'started_at' => now(), ]); } // Barbarian villages that lost their growth event get it back, and their garrison; // player villages get a raid planned. foreach ($worlds as $world) { app(SpawnBarbarians::class)->scheduleGrowth($world); app(SpawnBarbarians::class)->scheduleGarrisons($world); app(SpawnBarbarians::class)->scheduleRaids($world); } // Every open world without a barbarian wave planned gets one an interval from now. foreach (World::whereNull('ended_at')->whereNull('barbarians_at')->get() as $world) { Waves::start($world, now()->toImmutable()); } } }