# 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 ObjGameDataRace(PrettyPrint):
    def __init__(
            self,
            best_time: int = 0,
            precision: int = 0,
            race_flags: int = 0
    ) -> None:
        self.item_name: str = 'connless.game_data_race'
        self.type_id: int = 24
        self.id: int = 0
        self.size: int = 3

        self.best_time: int = best_time
        self.precision: int = precision
        self.race_flags: int = race_flags

    # 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.best_time = unpacker.get_int()
        self.precision = unpacker.get_int()
        self.race_flags = unpacker.get_int() # TODO: this is a flag
        return True

    def pack(self) -> bytes:
        return pack_int(self.best_time) + \
            pack_int(self.precision) + \
            pack_int(self.race_flags)