- 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
56 lines
1.6 KiB
PHP
56 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Web;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Character;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
|
|
/**
|
|
* Character appearance customization.
|
|
*/
|
|
class CharacterCustomizeController extends Controller
|
|
{
|
|
/**
|
|
* Show current appearance slots.
|
|
*/
|
|
public function show(Request $request): JsonResponse
|
|
{
|
|
$me = Character::ensureForUser($request->user());
|
|
|
|
return response()->json([
|
|
'name' => $me->name,
|
|
'skin' => (int) $me->skin,
|
|
'hair' => (int) $me->hair,
|
|
'shirt' => (int) $me->shirt,
|
|
'face' => (int) $me->face,
|
|
'beard' => (int) $me->beard,
|
|
'accessory' => (int) $me->accessory,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Persist appearance choices (1-based slots within safe ranges).
|
|
*/
|
|
public function update(Request $request): JsonResponse
|
|
{
|
|
$me = Character::ensureForUser($request->user());
|
|
$data = $request->validate([
|
|
'skin' => ['required', 'integer', 'min:1', 'max:4'],
|
|
'hair' => ['required', 'integer', 'min:1', 'max:4'],
|
|
'shirt' => ['required', 'integer', 'min:1', 'max:5'],
|
|
'face' => ['required', 'integer', 'min:1', 'max:3'],
|
|
'beard' => ['required', 'integer', 'min:0', 'max:2'],
|
|
'accessory' => ['required', 'integer', 'min:0', 'max:2'],
|
|
]);
|
|
|
|
$me->forceFill($data)->save();
|
|
|
|
return response()->json([
|
|
'message' => __('city.customize_saved'),
|
|
'appearance' => $data,
|
|
]);
|
|
}
|
|
}
|