- Adds Character model with survival needs (hunger, thirst, energy) and state machine - Implements city:tick world ticker for offline progression every minute - Adds city territory expansion and building construction system - Introduces job economy, inventory, and transaction audit trail - Adds social graph (friends, marriage, children) and character chat - Implements admin approval workflow for new registrations - Adds hospital admission system for traffic accidents - Includes comprehensive feature tests and world seeders
88 lines
2.8 KiB
PHP
Executable File
88 lines
2.8 KiB
PHP
Executable File
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use App\Models\Building;
|
|
use App\Models\Character;
|
|
use App\Models\City;
|
|
use App\Models\Job;
|
|
use App\Models\Store;
|
|
use App\Models\User;
|
|
use Illuminate\Database\Seeder;
|
|
|
|
/**
|
|
* Seeds the persistent world: default city, jobs and citizen characters.
|
|
*
|
|
* Backfills users.status for pre-existing accounts and ensures every active
|
|
* user has a character so the platform works after the status migration.
|
|
*/
|
|
class CityWorldSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Seed the world tables.
|
|
*/
|
|
public function run(): void
|
|
{
|
|
$city = City::updateOrCreate(
|
|
['slug' => 'city10'],
|
|
[
|
|
'name' => 'City10',
|
|
'bounds_min_x' => -80,
|
|
'bounds_max_x' => 80,
|
|
'bounds_min_z' => -80,
|
|
'bounds_max_z' => 80,
|
|
'is_active' => true,
|
|
'expansions' => 0,
|
|
],
|
|
);
|
|
|
|
$bakery = Store::where('type', 'bakery')->orderBy('id')->first();
|
|
$market = Store::where('type', 'market')->orderBy('id')->first();
|
|
|
|
Job::updateOrCreate(
|
|
['city_id' => $city->id, 'title' => 'Padeiro'],
|
|
['store_id' => $bakery?->id, 'salary' => 12, 'requires_education' => 0],
|
|
);
|
|
Job::updateOrCreate(
|
|
['city_id' => $city->id, 'title' => 'Operador de mercado'],
|
|
['store_id' => $market?->id, 'salary' => 10, 'requires_education' => 0],
|
|
);
|
|
Job::updateOrCreate(
|
|
['city_id' => $city->id, 'title' => 'Servidor público'],
|
|
['salary' => 15, 'requires_education' => 30],
|
|
);
|
|
Job::updateOrCreate(
|
|
['city_id' => $city->id, 'title' => 'Professor'],
|
|
['salary' => 14, 'requires_education' => 60],
|
|
);
|
|
|
|
// City hospital: accident victims are admitted here for two game days.
|
|
Building::updateOrCreate(
|
|
[
|
|
'city_id' => $city->id,
|
|
'type' => Building::TYPE_HOSPITAL,
|
|
],
|
|
[
|
|
'owner_character_id' => null,
|
|
'name' => 'Hospital Municipal',
|
|
'pos_x' => 60,
|
|
'pos_z' => -60,
|
|
'width' => 14,
|
|
'depth' => 12,
|
|
'height' => 8,
|
|
'is_complete' => true,
|
|
'build_progress' => 100,
|
|
],
|
|
);
|
|
|
|
User::query()->where('is_active', true)->where('status', '!=', User::STATUS_ACTIVE)
|
|
->update(['status' => User::STATUS_ACTIVE]);
|
|
User::query()->where('is_active', false)->where('status', User::STATUS_PENDING)
|
|
->update(['status' => User::STATUS_BANNED]);
|
|
|
|
User::query()->where('status', User::STATUS_ACTIVE)->each(function (User $user) use ($city): void {
|
|
Character::ensureForUser($user, $city);
|
|
});
|
|
}
|
|
}
|