feat(world): add persistent citizen simulation with needs, jobs, and social features
- 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
This commit is contained in:
Executable
+52
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Character;
|
||||
use App\Models\City;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<Character>
|
||||
*/
|
||||
class CharacterFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'user_id' => User::factory(),
|
||||
'city_id' => City::factory(),
|
||||
'name' => fake()->firstName(),
|
||||
'skin' => fake()->numberBetween(1, 4),
|
||||
'hair' => fake()->numberBetween(1, 4),
|
||||
'shirt' => fake()->numberBetween(1, 5),
|
||||
'pos_x' => 0,
|
||||
'pos_y' => 0,
|
||||
'pos_z' => 25,
|
||||
'money' => 100,
|
||||
'energy' => 100,
|
||||
'hunger' => 100,
|
||||
'thirst' => 100,
|
||||
'state' => Character::STATE_AWAKE,
|
||||
'education' => 0,
|
||||
'is_online' => false,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Character without an account (NPC child).
|
||||
*/
|
||||
public function npc(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'user_id' => null,
|
||||
'name' => fake()->firstName(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Executable
+34
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\City;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends Factory<City>
|
||||
*/
|
||||
class CityFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$name = fake()->unique()->city();
|
||||
|
||||
return [
|
||||
'name' => $name,
|
||||
'slug' => Str::slug($name).'-'.fake()->unique()->numberBetween(1, 9999),
|
||||
'bounds_min_x' => -80,
|
||||
'bounds_max_x' => 80,
|
||||
'bounds_min_z' => -80,
|
||||
'bounds_max_z' => 80,
|
||||
'is_active' => false,
|
||||
'expansions' => 0,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,7 @@ class UserFactory extends Factory
|
||||
'password' => static::$password ??= Hash::make('password'),
|
||||
'remember_token' => Str::random(10),
|
||||
'role' => 'user',
|
||||
'status' => 'active',
|
||||
'locale' => 'pt_BR',
|
||||
'is_active' => true,
|
||||
];
|
||||
@@ -56,12 +57,24 @@ class UserFactory extends Factory
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the account awaits administrator approval.
|
||||
*/
|
||||
public function pending(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'status' => 'pending',
|
||||
'is_active' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the account has been deactivated.
|
||||
*/
|
||||
public function inactive(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'status' => 'banned',
|
||||
'is_active' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user