def __init__(self, reader: ReplayReader) -> None: self.version = reader.read_string() reader.read(3) self.replay_version, self.map_name = reader.read_string().split( "\r\n", 1) reader.read(4) reader.read_uint() # mods_size self.mods = reader.read_lua() reader.read_uint() # scenario_size self.scenario = reader.read_lua() sources_number = reader.read_byte() self.players = {} for i in range(sources_number): name = reader.read_string() player_id = reader.read_uint() self.players[name] = str(player_id) self.cheats_enabled = reader.read_bool() self.numbers_of_armies = reader.read_byte() self.armies = {} for _ in range(self.numbers_of_armies): reader.read_uint() # player_data_size player_data = reader.read_lua() player_source = reader.read_byte() self.armies[player_source] = player_data if player_source != 255: reader.read(1) self.random_seed = reader.read_uint()
def command_set_command_type( reader: ReplayReader) -> Dict[str, Union[str, int]]: return { "type": "set_command_type", "command_id": reader.read_uint(), "target_id": reader.read_int() }
def command_set_command_target( reader: ReplayReader) -> Dict[str, Union[int, TYPE_TARGET]]: return { "type": "set_command_target", "command_id": reader.read_uint(), "target": _parse_target(reader) }
def command_command_count_decrease( reader: ReplayReader) -> Dict[str, Union[str, int]]: return { "type": "command_count_decrease", "command_id": reader.read_uint(), "delta": reader.read_int() }
def command_verify_checksum( reader: ReplayReader) -> Dict[str, Union[str, int]]: checksum = "".join("{:02X}".format(ord(reader.read(1))) for _ in range(16)) return { "type": "verify_checksum", "checksum": checksum, "tick": reader.read_uint() }
def command_set_command_cells( reader: ReplayReader) -> Dict[str, Union[str, int, TYPE_LUA]]: command_id = reader.read_uint() cells = reader.read_lua() if cells: reader.read(1) vector = (reader.read_float(), reader.read_float(), reader.read_float()) return { "type": "set_command_cells", "command_id": command_id, "cells": cells, "vector": vector }
def command_remove_from_queue(reader: ReplayReader) -> Dict[str, int]: return { "type": "remove_from_queue", "command_id": reader.read_uint(), "unit_id": reader.read_int() }
def command_advance(reader: ReplayReader) -> Dict[str, int]: return {"type": "advance", "advance": reader.read_uint()}
def _parse_entity_ids_set(reader: ReplayReader) -> TYPE_ENTITY_IDS_SET: units_number = reader.read_uint() unit_ids = [] for i in range(units_number): unit_ids.append(reader.read_uint()) return {"units_number": units_number, "unit_ids": unit_ids}