# generated by scripts/generate_messages.py

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

class ObjDeGameInfo(PrettyPrint):
    def __init__(
            self,
            game_flags: int = 0,
            score_limit: int = 0,
            time_limit: int = 0,
            match_num: int = 0,
            match_current: int = 0
    ) -> None:
        self.item_name: str = 'connless.de_game_info'
        self.type_id: int = 14
        self.id: int = 0
        self.size: int = 5

        self.game_flags: int = game_flags
        self.score_limit: int = score_limit
        self.time_limit: int = time_limit
        self.match_num: int = match_num
        self.match_current: int = match_current

    # 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:
        self.game_flags = unpacker.get_int() # TODO: this is a flag
        self.score_limit = unpacker.get_int()
        self.time_limit = unpacker.get_int()
        self.match_num = unpacker.get_int()
        self.match_current = unpacker.get_int()
        return True

    def pack(self) -> bytes:
        return pack_int(self.game_flags) + \
            pack_int(self.score_limit) + \
            pack_int(self.time_limit) + \
            pack_int(self.match_num) + \
            pack_int(self.match_current)