- 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
74 lines
2.0 KiB
PHP
Executable File
74 lines
2.0 KiB
PHP
Executable File
<?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'));
|
|
}
|
|
}
|