first commit
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
use App\Http\Controllers\Game\CharacterController;
|
||||
use App\Http\Controllers\Game\CrimeController;
|
||||
use App\Http\Controllers\Game\DashboardController;
|
||||
use App\Http\Controllers\Game\InventoryController;
|
||||
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');
|
||||
});
|
||||
});
|
||||
|
||||
// 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');
|
||||
}
|
||||
$releaseTime = $character->in_jail_until ? $character->in_jail_until->diffForHumans() : 'unknown';
|
||||
return view('game.jail', compact('character', 'releaseTime'));
|
||||
})->name('game.jail');
|
||||
});
|
||||
Reference in New Issue
Block a user