feat(city): add plaza exercise system with health tracking

- Adds CityPlazas support class for deterministic public plaza generation with outdoor gym equipment
- Implements exercise and stop-exercise actions with proximity validation to equipment
- Introduces health (0-100) and exercise_count attributes to Character model
- Reduces hospital stay duration from two game days to one game hour
- Adds 3D gym equipment rendering (bench, bars, bike, treadmill) in city viewer
- Includes exercise state machine handling in world ticker with energy drain
- Adds comprehensive PlazaExerciseTest and updates HospitalAdmissionTest
- Provides localized UI strings for health HUD and exercise prompts
This commit is contained in:
2026-10-17 22:10:50 -03:00
parent 79ce2a1825
commit 090b530481
18 changed files with 848 additions and 21 deletions
@@ -7,7 +7,7 @@ use Illuminate\Support\Facades\Schema;
/**
* Adds hospital admission tracking to characters.
*
* When a character is hit by a vehicle they are admitted for two game days
* When a character is hit by a vehicle they are admitted for one game hour
* (hospitalized_until). The world ticker releases them automatically.
*/
return new class extends Migration
@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* Adds fitness tracking to characters.
*
* health is 0-100 and rises while the character exercises on public plaza
* equipment; exercise_count is a lifetime counter for progress display.
*/
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('characters', function (Blueprint $table): void {
$table->unsignedTinyInteger('health')->default(100)->after('thirst');
$table->unsignedInteger('exercise_count')->default(0)->after('education');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('characters', function (Blueprint $table): void {
$table->dropColumn(['health', 'exercise_count']);
});
}
};
+5 -1
View File
@@ -56,7 +56,7 @@ class CityWorldSeeder extends Seeder
['salary' => 14, 'requires_education' => 60],
);
// City hospital: accident victims are admitted here for two game days.
// City hospital: accident victims are admitted here for one game hour.
Building::updateOrCreate(
[
'city_id' => $city->id,
@@ -83,5 +83,9 @@ class CityWorldSeeder extends Seeder
User::query()->where('status', User::STATUS_ACTIVE)->each(function (User $user) use ($city): void {
Character::ensureForUser($user, $city);
});
// Backfill fitness columns for characters created before the migration.
Character::query()->whereNull('health')->update(['health' => 100]);
Character::query()->whereNull('exercise_count')->update(['exercise_count' => 0]);
}
}