# generated by scripts/generate_messages.py

from typing import Any, Dict

from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.packer import pack_int
from typing import Annotated

class ObjClientInfo(PrettyPrint):
    def __init__(
            self,
            name: Annotated[list[int], 4] = \
                [0, 0, 0, 0],
            clan: Annotated[list[int], 3] = \
                [0, 0, 0],
            country: int = 0,
            skin: Annotated[list[int], 6] = \
                [0, 0, 0, 0, 0, 0],
            use_custom_color: int = 0,
            color_body: int = 0,
            color_feet: int = 0
    ) -> None:
        self.item_name: str = 'item.client_info'
        self.type_id: int = 11
        self.id: int = 0
        self.size: int = 7

        self.name = name
        self.clan = clan
        self.country: int = country
        self.skin = skin
        self.use_custom_color: int = use_custom_color
        self.color_body: int = color_body
        self.color_feet: int = color_feet

    def __iter__(self):
        yield 'item_name', self.item_name
        yield 'type_id', self.type_id
        yield 'id', self.id
        yield 'size', self.size

        yield 'name', self.name
        yield 'clan', self.clan
        yield 'country', self.country
        yield 'skin', self.skin
        yield 'use_custom_color', self.use_custom_color
        yield 'color_body', self.color_body
        yield 'color_feet', self.color_feet

    def to_dict_payload_only(self) -> Dict[str, Any]:
        return {
            'name': self.name,
            'clan': self.clan,
            'country': self.country,
            'skin': self.skin,
            'use_custom_color': self.use_custom_color,
            'color_body': self.color_body,
            'color_feet': self.color_feet
        }

    # first byte of data
    # has to be the first byte of the message payload
    # NOT the chunk header and NOT the message id
    def unpack(self, unpacker: Unpacker) -> bool:
        for i in range(0, 4):
            self.name[i] = unpacker.get_int()
        for i in range(0, 3):
            self.clan[i] = unpacker.get_int()
        self.country = unpacker.get_int()
        for i in range(0, 6):
            self.skin[i] = unpacker.get_int()
        self.use_custom_color = unpacker.get_int()
        self.color_body = unpacker.get_int()
        self.color_feet = unpacker.get_int()
        return True

    def pack(self) -> bytes:
        return b''.join([pack_int(x) for x in self.name]) + \
            b''.join([pack_int(x) for x in self.clan]) + \
            pack_int(self.country) + \
            b''.join([pack_int(x) for x in self.skin]) + \
            pack_int(self.use_custom_color) + \
            pack_int(self.color_body) + \
            pack_int(self.color_feet)