2026-10-28 18:17:34 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Database\Seeders;
|
|
|
|
|
|
2026-10-29 00:51:37 +00:00
|
|
|
use App\Actions\SpawnBarbarians;
|
2026-10-28 18:17:34 +00:00
|
|
|
use App\Models\World;
|
|
|
|
|
use Illuminate\Database\Seeder;
|
|
|
|
|
|
2026-10-29 00:51:37 +00:00
|
|
|
/**
|
|
|
|
|
* The default world and a fast dev world. They start empty: villages, barbarian ones
|
|
|
|
|
* included, come with the players who join. Safe to run on every deploy.
|
|
|
|
|
*/
|
2026-10-28 18:17:34 +00:00
|
|
|
class WorldSeeder extends Seeder
|
|
|
|
|
{
|
|
|
|
|
public function run(): void
|
|
|
|
|
{
|
2026-10-28 18:45:03 +00:00
|
|
|
$worlds = [
|
|
|
|
|
World::firstOrCreate(['slug' => 'w1'], ['name' => 'World 1', 'started_at' => now()]),
|
|
|
|
|
World::firstOrCreate(['slug' => 'dev'], [
|
|
|
|
|
'name' => 'Dev world',
|
|
|
|
|
'config' => ['world' => ['speed' => 100]],
|
|
|
|
|
'started_at' => now(),
|
|
|
|
|
]),
|
|
|
|
|
];
|
2026-10-29 00:51:37 +00:00
|
|
|
// Barbarian villages that lost their growth event get it back.
|
2026-10-28 18:45:03 +00:00
|
|
|
foreach ($worlds as $world) {
|
2026-10-29 00:51:37 +00:00
|
|
|
app(SpawnBarbarians::class)->scheduleGrowth($world);
|
2026-10-28 18:45:03 +00:00
|
|
|
}
|
2026-10-28 18:17:34 +00:00
|
|
|
}
|
|
|
|
|
}
|