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:
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Web\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Character;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
/**
|
||||
* Administrator management of citizen accounts.
|
||||
*
|
||||
* Lists registered users, approves pending registrations (which creates the
|
||||
* in-world character) and bans accounts that must not enter the platform.
|
||||
*/
|
||||
class CitizenAdminController extends Controller
|
||||
{
|
||||
/**
|
||||
* List all citizens with their approval status.
|
||||
*/
|
||||
public function index(Request $request): View
|
||||
{
|
||||
abort_unless($request->user()?->isAdmin(), 403);
|
||||
|
||||
$users = User::query()
|
||||
->with('character:id,user_id,name,city_id')
|
||||
->orderByDesc('created_at')
|
||||
->paginate(20);
|
||||
|
||||
return view('admin.citizens.index', [
|
||||
'users' => $users,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Approve a pending citizen and ensure their character exists.
|
||||
*/
|
||||
public function approve(Request $request, User $user): RedirectResponse
|
||||
{
|
||||
abort_unless($request->user()?->isAdmin(), 403);
|
||||
|
||||
$user->forceFill(['status' => User::STATUS_ACTIVE, 'is_active' => true])->save();
|
||||
Character::ensureForUser($user);
|
||||
|
||||
return redirect()->route('admin.citizens.index')
|
||||
->with('status', __('admin.citizens.approved'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Ban a citizen so they can no longer authenticate.
|
||||
*/
|
||||
public function ban(Request $request, User $user): RedirectResponse
|
||||
{
|
||||
abort_unless($request->user()?->isAdmin(), 403);
|
||||
|
||||
abort_if((int) $user->id === (int) $request->user()->id, 422, __('admin.citizens.cannot_ban_self'));
|
||||
|
||||
$user->forceFill(['status' => User::STATUS_BANNED, 'is_active' => false])->save();
|
||||
|
||||
return redirect()->route('admin.citizens.index')
|
||||
->with('status', __('admin.citizens.banned'));
|
||||
}
|
||||
}
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Web\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\City;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\View\View;
|
||||
|
||||
/**
|
||||
* Administrator management of city territories.
|
||||
*
|
||||
* Supports creating new cities and expanding the bounds of existing ones
|
||||
* so the playable map can grow over time.
|
||||
*/
|
||||
class CityAdminController extends Controller
|
||||
{
|
||||
/**
|
||||
* List all cities with expansion controls.
|
||||
*/
|
||||
public function index(Request $request): View
|
||||
{
|
||||
abort_unless($request->user()?->isAdmin(), 403);
|
||||
|
||||
return view('admin.cities.index', [
|
||||
'cities' => City::query()->orderBy('id')->get(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new city territory.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
abort_unless($request->user()?->isAdmin(), 403);
|
||||
|
||||
$data = $request->validate([
|
||||
'name' => ['required', 'string', 'max:120'],
|
||||
]);
|
||||
|
||||
City::create([
|
||||
'name' => $data['name'],
|
||||
'slug' => Str::slug($data['name']).'-'.uniqid(),
|
||||
'bounds_min_x' => -80,
|
||||
'bounds_max_x' => 80,
|
||||
'bounds_min_z' => -80,
|
||||
'bounds_max_z' => 80,
|
||||
'is_active' => false,
|
||||
'expansions' => 0,
|
||||
]);
|
||||
|
||||
return redirect()->route('admin.cities.index')
|
||||
->with('status', __('admin.cities.created'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Expand a city's territory by one grid step.
|
||||
*/
|
||||
public function expand(Request $request, City $city): RedirectResponse
|
||||
{
|
||||
abort_unless($request->user()?->isAdmin(), 403);
|
||||
|
||||
if (! $city->expand()) {
|
||||
return redirect()->route('admin.cities.index')
|
||||
->withErrors(['city' => __('admin.cities.max_expansions')]);
|
||||
}
|
||||
|
||||
return redirect()->route('admin.cities.index')
|
||||
->with('status', __('admin.cities.expanded'));
|
||||
}
|
||||
}
|
||||
Regular → Executable
Reference in New Issue
Block a user