2026-06-27 14:38:18 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
use App\Http\Controllers\Game\CharacterController;
|
|
|
|
|
use App\Http\Controllers\Game\CrimeController;
|
|
|
|
|
use App\Http\Controllers\Game\DashboardController;
|
2026-06-28 16:45:24 +03:00
|
|
|
use App\Http\Controllers\Game\GymController;
|
2026-06-27 14:38:18 +03:00
|
|
|
use App\Http\Controllers\Game\InventoryController;
|
2026-06-28 22:49:59 +03:00
|
|
|
use App\Http\Controllers\Game\JailController;
|
2026-06-27 14:38:18 +03:00
|
|
|
use Illuminate\Support\Facades\Route;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| Game Routes
|
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
| These routes are for the game-specific functionality.
|
|
|
|
|
| All game routes require authentication and a character.
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// Redirect root to game dashboard if authenticated
|
|
|
|
|
Route::get('/', function () {
|
|
|
|
|
if (auth()->check() && auth()->user()->character) {
|
|
|
|
|
return redirect()->route('game.dashboard');
|
|
|
|
|
}
|
|
|
|
|
return view('welcome');
|
|
|
|
|
})->name('home');
|
|
|
|
|
|
|
|
|
|
// Game routes - require authentication and character
|
|
|
|
|
Route::middleware(['auth', 'verify.character'])->group(function () {
|
|
|
|
|
// Dashboard
|
|
|
|
|
Route::get('/game', [DashboardController::class, 'index'])->name('game.dashboard');
|
|
|
|
|
|
|
|
|
|
// Character routes
|
|
|
|
|
Route::prefix('game/character')->name('game.character.')->group(function () {
|
|
|
|
|
Route::get('/create', [CharacterController::class, 'create'])->name('create')->withoutMiddleware(['verify.character']);
|
|
|
|
|
Route::post('/', [CharacterController::class, 'store'])->name('store')->withoutMiddleware(['verify.character']);
|
|
|
|
|
Route::get('/', [CharacterController::class, 'show'])->name('show');
|
|
|
|
|
Route::get('/edit', [CharacterController::class, 'edit'])->name('edit');
|
|
|
|
|
Route::put('/', [CharacterController::class, 'update'])->name('update');
|
|
|
|
|
Route::post('/deposit', [CharacterController::class, 'deposit'])->name('deposit');
|
|
|
|
|
Route::post('/withdraw', [CharacterController::class, 'withdraw'])->name('withdraw');
|
|
|
|
|
Route::post('/revive', [CharacterController::class, 'revive'])->name('revive');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Crime routes
|
|
|
|
|
Route::prefix('game/crimes')->name('game.crimes.')->group(function () {
|
|
|
|
|
Route::get('/', [CrimeController::class, 'index'])->name('index');
|
|
|
|
|
Route::get('/{crime}', [CrimeController::class, 'show'])->name('show');
|
|
|
|
|
Route::post('/{crime}/attempt', [CrimeController::class, 'attempt'])->name('attempt')->middleware(['check.energy:crime']);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Inventory routes
|
|
|
|
|
Route::prefix('game/inventory')->name('game.inventory.')->group(function () {
|
|
|
|
|
Route::get('/', [InventoryController::class, 'index'])->name('index');
|
|
|
|
|
Route::post('/{inventory}/equip', [InventoryController::class, 'equip'])->name('equip');
|
|
|
|
|
Route::post('/{inventory}/unequip', [InventoryController::class, 'unequip'])->name('unequip');
|
|
|
|
|
Route::post('/{inventory}/use', [InventoryController::class, 'use'])->name('use');
|
|
|
|
|
Route::post('/{inventory}/drop', [InventoryController::class, 'drop'])->name('drop');
|
|
|
|
|
});
|
2026-06-28 16:45:24 +03:00
|
|
|
|
|
|
|
|
// Gym routes
|
|
|
|
|
Route::prefix('game/gym')->name('game.gym.')->group(function () {
|
|
|
|
|
Route::get('/', [GymController::class, 'index'])->name('index');
|
|
|
|
|
Route::post('/train', [GymController::class, 'train'])->name('train')->middleware(['check.energy:gym']);
|
|
|
|
|
});
|
2026-06-27 14:38:18 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Hospital route (for when character is in hospital)
|
|
|
|
|
Route::middleware(['auth'])->group(function () {
|
|
|
|
|
Route::get('/game/hospital', function () {
|
|
|
|
|
$character = auth()->user()->character;
|
|
|
|
|
if (!$character || (!$character->isInHospital() && !$character->isDead())) {
|
|
|
|
|
return redirect()->route('game.dashboard');
|
|
|
|
|
}
|
|
|
|
|
$reviveCost = config('game.health.hospital_cost', 1000);
|
|
|
|
|
$releaseTime = $character->in_hospital_until ? $character->in_hospital_until->diffForHumans() : 'unknown';
|
|
|
|
|
return view('game.hospital', compact('character', 'reviveCost', 'releaseTime'));
|
|
|
|
|
})->name('game.hospital');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Jail route (for when character is in jail)
|
|
|
|
|
Route::middleware(['auth'])->group(function () {
|
|
|
|
|
Route::get('/game/jail', function () {
|
|
|
|
|
$character = auth()->user()->character;
|
|
|
|
|
if (!$character || !$character->isInJail()) {
|
|
|
|
|
return redirect()->route('game.dashboard');
|
|
|
|
|
}
|
2026-06-28 22:49:59 +03:00
|
|
|
$releaseTime = $character->in_jail_until ? $character->in_jail_until->diffForHumans() : 'unknown';
|
|
|
|
|
$bustOutChance = (int) round((new \App\Services\Game\JailService())->calculateBustOutChance($character) * 100);
|
|
|
|
|
$bustOutCost = config('game.jail.breakout_cost', 1000);
|
|
|
|
|
return view('game.jail', compact('character', 'releaseTime', 'bustOutChance', 'bustOutCost'));
|
2026-06-27 14:38:18 +03:00
|
|
|
})->name('game.jail');
|
2026-06-28 22:49:59 +03:00
|
|
|
|
|
|
|
|
Route::post('/game/jail/bust-out', [JailController::class, 'bustOut'])
|
|
|
|
|
->name('game.jail.bust-out');
|
2026-06-27 14:38:18 +03:00
|
|
|
});
|