Esempio n. 1
0
    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)

        mods_size = reader.read_int()
        self.mods = reader.read_lua()
        scenario_size = reader.read_int()
        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_int()
            self.players[name] = str(player_id)

        self.cheats_enabled = reader.read_bool()
        self.numbers_of_armies = reader.read_byte()

        self.armies = {}
        for i in range(self.numbers_of_armies):
            player_data_size = reader.read_int()
            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_float()
def _parse_command_data(reader: ReplayReader) -> TYPE_COMMAND_DATA:
    command_id = reader.read_int()
    arg1 = reader.read(4)
    command_type = reader.read_byte()
    arg2 = reader.read(4)

    target = _parse_target(reader)

    arg3 = reader.read(1)
    formation = _parse_formation(reader)

    blueprint_id = reader.read_string()

    arg4 = reader.read(12)
    arg5 = None
    cells = reader.read_lua()
    if cells:
        arg5 = reader.read(1)

    return {
        "command_id": command_id,
        "command_type": command_type,
        "target": target,
        "formation": formation,
        "blueprint_id": blueprint_id,
        "cells": cells,
        "arg1": arg1,
        "arg2": arg2,
        "arg3": arg3,
        "arg4": arg4,
        "arg5": arg5
    }
Esempio n. 3
0
def command_create_unit(reader: ReplayReader) -> Dict[str, Union[int, str, TYPE_VECTOR]]:
    army_index = reader.read_byte()
    blueprint_id = reader.read_string()
    x, y, heading = _read_vector(reader)
    return {"type": "create_unit",
            "army_index": army_index,
            "blueprint_id": blueprint_id,
            "vector": (x, y, heading)}
def _parse_target(reader: ReplayReader) -> TYPE_TARGET:
    target = reader.read_byte()
    entity_id = None
    position = None
    if target == TargetType.Entity:
        entity_id = reader.read_int()
    elif target == TargetType.Position:
        position = _read_vector(reader)
    return {"target": target, "entity_id": entity_id, "position": position}
Esempio n. 5
0
def command_debug_command(reader: ReplayReader) -> Dict[str, Union[str, TYPE_VECTOR, int, TYPE_ENTITY_IDS_SET]]:
    debug_command = reader.read_string()
    vector = _read_vector(reader)
    focus_army_index = reader.read_byte()
    unit_ids = _parse_entity_ids_set(reader)
    return {"type": "debug_command",
            "debug_command": debug_command,
            "vector": vector,
            "focus_army_index": focus_army_index,
            "entity_ids_set": unit_ids}
def command_set_command_source(reader: ReplayReader) -> Dict[str, int]:
    return {"type": "set_command_source", "player_id": reader.read_byte()}