def _parse_options_object(self):
        object_piece = self.parsed_data['OptionsPiece']
        # ppnd: Per Player Number of Disabled
        ppnd_techs = get_retriever_by_name(
            object_piece.retrievers,
            "Per player number of disabled techs").data
        ppnd_units = get_retriever_by_name(
            object_piece.retrievers,
            "Per player number of disabled units").data
        ppnd_buildings = get_retriever_by_name(
            object_piece.retrievers,
            "Per player number of disabled buildings").data
        disabled_techs = generator.create_generator(
            get_retriever_by_name(
                object_piece.retrievers,
                "Disabled technology IDs in player order").data, 1)
        disabled_units = generator.create_generator(
            get_retriever_by_name(object_piece.retrievers,
                                  "Disabled unit IDs in player order").data, 1)
        disabled_buildings = generator.create_generator(
            get_retriever_by_name(
                object_piece.retrievers,
                "Disabled building IDs in player order").data, 1)

        disables = list()
        for player_id in range(0, 8):  # 0-7 Players
            nd_techs = ppnd_techs[player_id]
            nd_units = ppnd_units[player_id]
            nd_buildings = ppnd_buildings[player_id]
            player_disabled_techs = generator.repeat_generator(
                disabled_techs, nd_techs, return_bytes=False)
            player_disabled_units = generator.repeat_generator(
                disabled_units, nd_units, return_bytes=False)
            player_disabled_buildings = generator.repeat_generator(
                disabled_buildings, nd_buildings, return_bytes=False)

            disables.append({
                'techs': player_disabled_techs,
                'units': player_disabled_units,
                'buildings': player_disabled_buildings,
            })

        return OptionsObject(
            disables,
            get_retriever_by_name(object_piece.retrievers, "All techs").data)
Ejemplo n.º 2
0
    def __init__(self,
                 piece_type,
                 retrievers,
                 parser_obj=None,
                 data=None,
                 pieces=None):
        super().__init__(piece_type, retrievers, parser_obj, data, pieces)

        if data and parser_obj:
            gen = create_generator(data, 1)
            super().set_data_from_generator(gen)
Ejemplo n.º 3
0
 def _create_file_generator(self, chunk_size):
     return generator.create_generator(self._file, chunk_size)
Ejemplo n.º 4
0
 def _create_data_generator(self, chunk_size):
     return generator.create_generator(self._decompressed_file_data,
                                       chunk_size)