1
0
forked from metin2/web

Localized and coded character listing, view structure refactoring

This commit is contained in:
Exynox 2024-12-31 20:33:17 +02:00
parent 103d21b5ef
commit b81cdd512f
11 changed files with 233 additions and 49 deletions

View File

@ -0,0 +1,19 @@
<?php
namespace App\Http\Controllers\User;
use App\Http\Controllers\Controller;
use App\Models\Game\Player\Player;
use Illuminate\Support\Facades\Auth;
use Illuminate\View\View;
class CharactersController extends Controller
{
public function show(): View
{
$characters = Player::where('account_id', Auth::user()->id)->get();
return view('user/characters', [
'characters' => $characters
]);
}
}

View File

@ -3,8 +3,11 @@
namespace App\Models\Game\Player;
use App\Models\Account;
use App\Models\Enums\CharacterJobEnum;
use App\Models\Game\Highscore\HighscoreCache;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasOne;
class Player extends Model
{
@ -60,7 +63,7 @@ class Player extends Model
* @var array<string, string>
*/
protected $casts = [
'job' => CharacterJobEnum::class,
];
/**
@ -70,4 +73,20 @@ public function account(): BelongsTo
{
return $this->belongsTo(Account::class, 'account_id', 'id');
}
/**
* Get the index of this player's account
*/
public function index(): BelongsTo
{
return $this->belongsTo(PlayerIndex::class, 'account_id', 'id');
}
/**
* Get this player's ranking
*/
public function highscore(): HasOne
{
return $this->hasOne(HighscoreCache::class, 'name', 'name');
}
}

View File

@ -0,0 +1,75 @@
<?php
namespace App\Models\Game\Player;
use App\Models\Account;
use App\Models\Enums\CharacterJobEnum;
use App\Models\Enums\EmpireEnum;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class PlayerIndex extends Model
{
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = false;
/**
* The connection name for the model.
*
* @var string|null
*/
protected $connection = 'player';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'player_index';
/**
* The primary key for the model.
*
* @var string
*/
protected $primaryKey = 'id';
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
];
/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
*/
protected $hidden = [
];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'empire' => EmpireEnum::class,
];
/**
* Get the account that owns the player index.
*/
public function account(): BelongsTo
{
return $this->belongsTo(Account::class, 'id', 'id');
}
}

View File

@ -0,0 +1,12 @@
<?php
return [
'title' => 'Character list',
'rank' => 'Rank',
'class' => 'Class',
'time' => 'Playtime',
'level' => 'Level',
'exp' => 'Experience',
'empire' => 'Empire',
];

View File

@ -0,0 +1,12 @@
<?php
return [
'title' => 'Lista personajelor',
'rank' => 'Rang',
'class' => 'Clasă',
'time' => 'Timp de joc',
'level' => 'Nivel',
'exp' => 'Experiență',
'empire' => 'Regat',
];

View File

@ -8,7 +8,7 @@
<div class="content-bg-bottom">
<!-- character list -->
<div class="char-list-content">
<h2>Lista caracterelor</h2>
<h2>{{ __('app/user/characters.title') }}</h2>
{{--
Pagination reverse-engineering (incomplete)
@ -30,51 +30,50 @@
</div>
--}}
@foreach ($characters as $character)
<div class="charList">
<div class="charimg" rowspan="3">
<img src="{{ asset('assets/main/img/characters/0.png') }}" width="44" height="40" />
<img src="{{ asset("assets/main/img/characters/{$character->job->value}.png") }}" width="44" height="40" />
</div>
<div class="charuser">
<div class="charname">gigelfronescu</div>
<div class="charname">{{ $character->name }}</div>
<div class="charrank">
<span class="charlabel">Rang</span> <span class="chardata">#123</span>
<span class="charlabel">{{ __('app/user/characters.rank') }}</span>
@if ($character->highscore)
<span class="chardata">#{{ $character->highscore->id }}</span>
@else
<span class="chardata">N/A</span>
@endif
</div>
</div>
<div class="charrow">
<div class="charclass"><span class="charlabel">Clasă</span> <span class="chardata">Sura</span></div>
<div class="chartime"><span class="charlabel">Timp de joc</span> <span class="chardata">3h 20m</span></div>
<div class="charclass">
<span class="charlabel">{{ __('app/user/characters.class') }}</span>
<span class="chardata">{{ $character->job->name() }}</span>
</div>
<div class="chartime">
<span class="charlabel">{{ __('app/user/characters.time') }}</span>
<span class="chardata">{{ (int) ($character->playtime / 60) }}h {{ $character->playtime % 60 }}m</span>
</div>
</div>
<div class="charrow">
<div class="charlevel"><span class="charlabel">Nivel</span><span class="chardata">69</span></div>
<div class="charlevel"><span class="charlabel">Experiență</span> <span class="chardata">1.351.561</span></div>
<div class="charlevel">
<span class="charlabel">{{ __('app/user/characters.level') }}</span>
<span class="chardata">{{ $character->level }}</span>
</div>
<div class="charlevel">
<span class="charlabel">{{ __('app/user/characters.exp') }}</span>
<span class="chardata">{{ number_format($character->exp, 0, ',', '.') }}</span>
</div>
</div>
<div class="charrow charend">
<div class="charposition"><span class="charlabel">Regat</span> <span class="chardata">Shinsoo</span></div>
<div class="charposition">
<span class="charlabel">{{ __('app/user/characters.empire') }}</span>
<span class="chardata">{{ $character->index->empire->name() }}</span>
</div>
</div>
<div class="charList">
<div class="charimg" rowspan="3">
<img src="{{ asset('assets/main/img/characters/2.png') }}" width="44" height="40" />
</div>
<div class="charuser">
<div class="charname">gigelfronescu</div>
<div class="charrank">
<span class="charlabel">Rang</span> <span class="chardata">#123</span>
</div>
</div>
<div class="charrow">
<div class="charclass"><span class="charlabel">Clasă</span> <span class="chardata">Sura</span></div>
<div class="chartime"><span class="charlabel">Timp de joc</span> <span class="chardata">3h 20m</span></div>
</div>
<div class="charrow">
<div class="charlevel"><span class="charlabel">Nivel</span><span class="chardata">69</span></div>
<div class="charlevel"><span class="charlabel">Experiență</span> <span class="chardata">1.351.561</span></div>
</div>
<div class="charrow charend">
<div class="charposition"><span class="charlabel">Regat</span> <span class="chardata">Shinsoo</span></div>
</div>
</div>
@endforeach
</div>
</div>
</div>

View File

@ -0,0 +1,42 @@
@extends('layouts.app')
@section('content')
<!-- center column -->
<div class="col-2">
<div class="content content-last">
<div class="content-bg">
<div class="content-bg-bottom">
<h2>Your Account</h2>
<div class="register-inner-content">
<div class="input-data-box">
<div class="box-img"></div>
<h4>Change Password</h4>
<p>Change your password here.</p>
<div class="pass-lost-box-small" style="margin-top: 0;">
<form action="{{ url('user/passwordchangerequest') }}" method="POST" name="registerForm">
<div class="pass-lost-box-inner-content">
<label>Old Password</label>
<div class="input-data-input">
<input type="password" name="old-password" maxlength="16" value="" />
</div>
<label>New Password</label>
<div class="input-data-input">
<input type="password" name="new-password" maxlength="16" value="" />
</div>
<input class="button btn-login btn-center-input" type="submit" onclick="document.forms['registerForm'].submit();return false;" value="Send"/>
</div>
</form>
</div>
</div>
<br class="clearfloat">
<a class="btn back-btn" href="{{ url('user/administration') }}">Back</a>
</div>
</div>
</div>
</div>
<div class="shadow">&nbsp;</div>
</div>
@endsection

View File

@ -3,12 +3,15 @@
use App\Http\Controllers\Auth\LoginController;
use App\Http\Controllers\Auth\RegisterController;
use App\Http\Controllers\Auth\VerificationController;
use App\Http\Controllers\Highscore\GuildHighscoreController;
use App\Http\Controllers\Highscore\HighscoreController;
use App\Http\Controllers\Mall\AuthController;
use App\Http\Controllers\Mall\CategoryController;
use App\Http\Controllers\Mall\HomeController;
use App\Http\Controllers\Mall\ItemController;
use App\Http\Controllers\Patch\PatchConfigController;
use App\Http\Controllers\Patch\PatchLandingController;
use App\Http\Controllers\User\CharactersController;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Route;
@ -68,6 +71,7 @@
# Registration
Route::get('/register', [RegisterController::class, 'showRegistrationForm'])->middleware('guest');
Route::post('/register', [RegisterController::class, 'register'])->middleware('guest');
Route::post('/register-from-header', [RegisterController::class, 'registerFromHeader'])->middleware('guest');
Route::get('/verification/notice', [VerificationController::class, 'show'])->name('verification.notice');
Route::get('/verification/verify/{id}/{hash}', [VerificationController::class, 'verify'])->name('verification.verify');
Route::get('/verification/resend', [VerificationController::class, 'resend'])->name('verification.resend');
@ -79,14 +83,16 @@
});
Route::get('/logout', [LoginController::class, 'logout']);
Route::get('/passwordlostrequest', fn () => view('user/passwordlostrequest'));
Route::get('/passwordlost/{username}/{hash}', fn ($username, $hash) => view('user/passwordlost-expired'));
Route::get('/passwordlostrequest', fn () => view('user/password-lost/password-lost-request'));
Route::get('/passwordlost/{username}/{hash}', fn ($username, $hash) => view('user/password-lost/password-lost-expired'));
# User administration
Route::middleware(['auth', 'verified'])->group(function() {
Route::get('/administration', fn () => view('user/administration'));
Route::get('/characters', fn () => view('user/characters'));
Route::get('/characters', [CharactersController::class, 'show']);
Route::get('/passwordchangerequest', fn () => view('user/password-change/password-change-request'));
Route::get('/emailchangeaccept/{username}/{hash}', fn ($username, $hash) => view('user/emailchangeaccept'));
Route::get('/emailchangecancel/{username}/{hash}', fn ($username, $hash) => view('user/emailchangecancel'));
@ -95,7 +101,7 @@
Route::get('/generatecode/{userId}/{hash}', fn ($userId, $hash) => view('user/generatecode'));
Route::get('/lostpasswordcode/{userId}/{hash}', fn ($userId, $hash) => view('user/lostpasswordcode'));
Route::get('/lostpasswordcode/{userId}/{hash}', fn ($userId, $hash) => view('user/password-lost/password-lost-code'));
});
});