a bit of progress

This commit is contained in:
2026-07-04 17:09:55 +03:00
parent f6e7d37428
commit 082b532d52
29 changed files with 2734 additions and 47 deletions
@@ -3,9 +3,11 @@
namespace App\Http\Controllers\Game;
use App\Http\Controllers\Controller;
use App\Http\Requests\Game\CharacterDepositRequest;
use App\Http\Requests\Game\CharacterWithdrawRequest;
use App\Models\Character;
use App\Models\Location;
use App\Models\ActivityLog;
use App\Services\Game\ActivityLogService;
use App\Services\Game\EconomyService;
use App\Services\Game\EnergyService;
use App\Services\Game\HealthService;
@@ -21,13 +23,20 @@ class CharacterController extends Controller
protected EnergyService $energyService;
protected HealthService $healthService;
protected NotificationService $notificationService;
protected ActivityLogService $activityLogService;
public function __construct()
{
$this->economyService = new EconomyService();
$this->energyService = new EnergyService();
$this->healthService = new HealthService();
$this->notificationService = new NotificationService();
public function __construct(
EconomyService $economyService,
EnergyService $energyService,
HealthService $healthService,
NotificationService $notificationService,
ActivityLogService $activityLogService
) {
$this->economyService = $economyService;
$this->energyService = $energyService;
$this->healthService = $healthService;
$this->notificationService = $notificationService;
$this->activityLogService = $activityLogService;
}
/**
@@ -85,7 +94,7 @@ class CharacterController extends Controller
]);
// Log character creation
ActivityLog::logCharacterCreated($character);
$this->activityLogService->logCharacterCreated($character);
return redirect()->route('game.dashboard')
->with('success', 'Character created successfully! Welcome to the game.');
@@ -144,15 +153,11 @@ class CharacterController extends Controller
/**
* Deposit money to bank
*/
public function deposit(Request $request): RedirectResponse
public function deposit(CharacterDepositRequest $request): RedirectResponse
{
$character = $request->user()->character;
$validated = $request->validate([
'amount' => ['required', 'integer', 'min:1'],
]);
if ($this->economyService->depositToBank($character, $validated['amount'])) {
if ($this->economyService->depositToBank($character, $request->amount)) {
return redirect()->back()
->with('success', 'Money deposited to bank successfully!');
}
@@ -164,15 +169,11 @@ class CharacterController extends Controller
/**
* Withdraw money from bank
*/
public function withdraw(Request $request): RedirectResponse
public function withdraw(CharacterWithdrawRequest $request): RedirectResponse
{
$character = $request->user()->character;
$validated = $request->validate([
'amount' => ['required', 'integer', 'min:1'],
]);
if ($this->economyService->withdrawFromBank($character, $validated['amount'])) {
if ($this->economyService->withdrawFromBank($character, $request->amount)) {
return redirect()->back()
->with('success', 'Money withdrawn from bank successfully!');
}