<?php

namespace App\FiveM\DTOs;

/**
 * Normalized shape every FrameworkAdapter returns a character as, regardless
 * of whether the underlying row came from QBCore's `players`, Qbox's
 * `players`, or ESX's `users` table. Controllers and React pages only ever
 * deal with this shape — framework-specific column names stay inside the
 * adapters.
 */
final class CharacterData
{
    /**
     * @param  array<string, int>  $money  e.g. ['cash' => 500, 'bank' => 12000]
     * @param  array{name: string, label: string, grade: int, grade_label: string}  $job
     * @param  array{name: string, label: string, grade: int, grade_label: string}|null  $gang
     * @param  array<int, array{name: string, label: string, amount: int, slot: int}>  $inventory
     */
    public function __construct(
        public readonly string $citizenId,
        public readonly string $license,
        public readonly string $name,
        public readonly array $money,
        public readonly array $job,
        public readonly ?array $gang,
        public readonly array $inventory,
        public readonly array $metadata,
    ) {}

    public function toArray(): array
    {
        return [
            'citizen_id' => $this->citizenId,
            'license' => $this->license,
            'name' => $this->name,
            'money' => $this->money,
            'job' => $this->job,
            'gang' => $this->gang,
            'inventory' => $this->inventory,
            'metadata' => $this->metadata,
        ];
    }
}
