<?php

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;

/**
 * @property int $id
 * @property int $account_id
 * @property string $name
 * @property CharacterJobEnum $job
 * @property int $voice
 * @property int $dir
 * @property int $x
 * @property int $y
 * @property int $z
 * @property int $map_index
 * @property int $exit_x
 * @property int $exit_y
 * @property int $exit_map_index
 * @property int $hp
 * @property int $mp
 * @property int $stamina
 * @property int $random_hp
 * @property int $random_sp
 * @property int $playtime
 * @property int $level
 * @property int $level_step
 * @property int $st
 * @property int $ht
 * @property int $dx
 * @property int $iq
 * @property int $exp
 * @property int $gold
 * @property int $stat_point
 * @property int $skill_point
 * @property string|null $quickslot
 * @property string|null $ip
 * @property int $part_main
 * @property int $part_base
 * @property int $part_hair
 * @property int $part_acce
 * @property int $skill_group
 * @property string|null $skill_level
 * @property int $alignment
 * @property string $last_play
 * @property int $change_name
 * @property int $sub_skill_point
 * @property int $stat_reset_count
 * @property int $horse_hp
 * @property int $horse_stamina
 * @property int $horse_level
 * @property int $horse_hp_droptime
 * @property int $horse_riding
 * @property int $horse_skill_point
 * @property int $bank_value
 * @property-read Account $account
 * @property-read HighscoreCache|null $highscore
 * @property-read \App\Models\Game\Player\PlayerIndex $index
 *
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player query()
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player whereAccountId($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player whereAlignment($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player whereBankValue($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player whereChangeName($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player whereDir($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player whereDx($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player whereExitMapIndex($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player whereExitX($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player whereExitY($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player whereExp($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player whereGold($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player whereHorseHp($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player whereHorseHpDroptime($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player whereHorseLevel($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player whereHorseRiding($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player whereHorseSkillPoint($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player whereHorseStamina($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player whereHp($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player whereHt($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player whereIp($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player whereIq($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player whereJob($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player whereLastPlay($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player whereLevel($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player whereLevelStep($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player whereMapIndex($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player whereMp($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player whereName($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player wherePartBase($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player wherePartHair($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player wherePartMain($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player wherePartAcce($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player wherePlaytime($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player whereQuickslot($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player whereRandomHp($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player whereRandomSp($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player whereSkillGroup($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player whereSkillLevel($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player whereSkillPoint($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player whereSt($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player whereStamina($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player whereStatPoint($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player whereStatResetCount($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player whereSubSkillPoint($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player whereVoice($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player whereX($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player whereY($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|Player whereZ($value)
 *
 * @mixin \Eloquent
 */
class Player extends Model
{
    /**
     * Indicates if the model should be timestamped.
     *
     * @var bool
     */
    public $timestamps = false;

    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'player';

    /**
     * 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 = [
        'job' => CharacterJobEnum::class,
    ];

    /**
     * Get the account that owns the player.
     */
    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');
    }
}
