game-village-politics-backend/database/seeders/WorldSeeder.php

31 lines
894 B
PHP
Raw Normal View History

<?php
namespace Database\Seeders;
use App\Actions\SpawnBarbarians;
use App\Models\World;
use Illuminate\Database\Seeder;
/**
* 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.
*/
class WorldSeeder extends Seeder
{
public function run(): void
{
$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(),
]),
];
// Barbarian villages that lost their growth event get it back.
foreach ($worlds as $world) {
app(SpawnBarbarians::class)->scheduleGrowth($world);
}
}
}