Exemple #1
0
    def bit_pack_unpack(cls, decoder: BitPackDecoder, metadata) -> "GeneratorParameters":
        games = decode_game_list(decoder)
        seed_number = decoder.decode_single(_PERMALINK_MAX_SEED)
        spoiler = bitpacking.decode_bool(decoder)

        manager = PresetManager(None)
        presets = [
            Preset.bit_pack_unpack(decoder, {"manager": manager, "game": game})
            for game in games
        ]
        for game in _get_unique_games(presets):
            included_data_hash = decoder.decode_single(256)
            expected_data_hash = _game_db_hash(game)
            if included_data_hash != expected_data_hash:
                raise ValueError("Given permalink is for a Randovania {} database with hash '{}', "
                                 "but current database has hash '{}'.".format(game.long_name,
                                                                              included_data_hash,
                                                                              expected_data_hash))

        return GeneratorParameters(seed_number, spoiler, presets)
Exemple #2
0
    def bit_pack_unpack(cls, decoder: BitPackDecoder, metadata) -> "Permalink":
        version, seed_number = decoder.decode(_PERMALINK_MAX_VERSION, _PERMALINK_MAX_SEED)
        cls._raise_if_different_version(version)

        spoiler = bitpacking.decode_bool(decoder)
        player_count = bitpacking.decode_int_with_limits(decoder, _PERMALINK_PLAYER_COUNT_LIMITS)
        manager = PresetManager(None)

        previous_unique_presets = []
        presets = {}

        for index in range(player_count):
            in_previous_presets = bitpacking.decode_bool(decoder)
            if in_previous_presets:
                preset = decoder.decode_element(previous_unique_presets)
            else:
                preset = Preset.bit_pack_unpack(decoder, {"manager": manager})
                previous_unique_presets.append(preset)
            presets[index] = preset

        return Permalink(seed_number, spoiler, presets)