feat(city): add player marketplace, mission journal, character customization and presence
- Player-to-player marketplace with listings, buying and selling - Mission system with progress tracking and money rewards - Character appearance customization (skin, hair, face, beard, accessory) - Multiplayer presence feed showing nearby citizens in near-real-time - Admin world dashboard with live platform metrics - Bus and train transportation with temporary ride state - Mobile joystick controls and minimap HUD - Education bonus applied to work salary
This commit is contained in:
@@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
/**
|
||||
@@ -19,7 +20,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
'user_id', 'city_id', 'name', 'skin', 'hair', 'shirt',
|
||||
'pos_x', 'pos_y', 'pos_z', 'money', 'energy', 'hunger', 'thirst', 'health',
|
||||
'state', 'job_id', 'house_id', 'education', 'exercise_count', 'is_online', 'last_tick_at',
|
||||
'hospitalized_until',
|
||||
'hospitalized_until', 'face', 'beard', 'accessory', 'ride_kind', 'ride_until',
|
||||
])]
|
||||
class Character extends Model
|
||||
{
|
||||
@@ -116,6 +117,28 @@ class Character extends Model
|
||||
return $this->hasMany(Building::class, 'owner_character_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Marketplace listings published by this character.
|
||||
*
|
||||
* @return HasMany<MarketListing, $this>
|
||||
*/
|
||||
public function listings(): HasMany
|
||||
{
|
||||
return $this->hasMany(MarketListing::class, 'seller_character_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Missions this character is tracking.
|
||||
*
|
||||
* @return BelongsToMany<Mission, $this>
|
||||
*/
|
||||
public function missions(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Mission::class, 'character_missions')
|
||||
->withPivot(['progress', 'is_completed', 'completed_at'])
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
/**
|
||||
* Inventory stacks owned by this character.
|
||||
*
|
||||
@@ -168,6 +191,9 @@ class Character extends Model
|
||||
'education' => 0,
|
||||
'exercise_count' => 0,
|
||||
'is_online' => false,
|
||||
'face' => random_int(1, 3),
|
||||
'beard' => random_int(0, 2),
|
||||
'accessory' => random_int(0, 2),
|
||||
]);
|
||||
|
||||
// Starter kit so new citizens can eat, drink and build immediately.
|
||||
@@ -207,6 +233,10 @@ class Character extends Model
|
||||
'is_online' => 'boolean',
|
||||
'last_tick_at' => 'datetime',
|
||||
'hospitalized_until' => 'datetime',
|
||||
'face' => 'integer',
|
||||
'beard' => 'integer',
|
||||
'accessory' => 'integer',
|
||||
'ride_until' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* Player-to-player marketplace listing.
|
||||
*/
|
||||
#[Fillable(['seller_character_id', 'city_id', 'item', 'qty', 'unit_price', 'is_active'])]
|
||||
class MarketListing extends Model
|
||||
{
|
||||
/**
|
||||
* Listing seller.
|
||||
*
|
||||
* @return BelongsTo<Character, $this>
|
||||
*/
|
||||
public function seller(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Character::class, 'seller_character_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* City where the listing is visible.
|
||||
*
|
||||
* @return BelongsTo<City, $this>
|
||||
*/
|
||||
public function city(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(City::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'unit_price' => 'float',
|
||||
'qty' => 'integer',
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
|
||||
/**
|
||||
* Catalog mission that citizens can complete for a reward.
|
||||
*/
|
||||
#[Fillable(['city_id', 'code', 'title', 'description', 'metric', 'target', 'reward', 'is_active'])]
|
||||
class Mission extends Model
|
||||
{
|
||||
/**
|
||||
* Characters tracking this mission.
|
||||
*
|
||||
* @return BelongsToMany<Character, $this>
|
||||
*/
|
||||
public function characters(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Character::class, 'character_missions')
|
||||
->withPivot(['progress', 'is_completed', 'completed_at'])
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'reward' => 'float',
|
||||
'target' => 'integer',
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user