Files
City10/database/migrations/2026_10_18_000300_create_characters_table.php
T
marcocosta10000 79ce2a1825 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
2026-10-17 21:46:23 -03:00

56 lines
2.0 KiB
PHP
Executable File

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* Creates the "characters" table.
*
* A character is the in-world avatar of a user (user_id nullable for NPC
* children). It stores position, survival needs, employment and family-relevant
* state that the world ticker updates continuously.
*/
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('characters', function (Blueprint $table): void {
$table->id();
$table->foreignId('user_id')->nullable()->unique()->constrained('users')->nullOnDelete();
$table->foreignId('city_id')->constrained('cities')->cascadeOnDelete();
$table->string('name', 120);
$table->unsignedTinyInteger('skin')->default(1);
$table->unsignedTinyInteger('hair')->default(1);
$table->unsignedTinyInteger('shirt')->default(1);
$table->decimal('pos_x', 10, 2)->default(0);
$table->decimal('pos_y', 10, 2)->default(0);
$table->decimal('pos_z', 10, 2)->default(0);
$table->decimal('money', 12, 2)->default(100);
$table->unsignedTinyInteger('energy')->default(100);
$table->unsignedTinyInteger('hunger')->default(100);
$table->unsignedTinyInteger('thirst')->default(100);
$table->string('state', 20)->default('awake')->index();
$table->foreignId('job_id')->nullable()->constrained('job_positions')->nullOnDelete();
$table->foreignId('house_id')->nullable();
$table->unsignedTinyInteger('education')->default(0);
$table->boolean('is_online')->default(false);
$table->timestamp('last_tick_at')->nullable();
$table->timestamps();
$table->index(['city_id', 'state']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('characters');
}
};