def from_json_dict(cls, json_dict: dict) -> "LayoutConfiguration": return LayoutConfiguration( trick_level_configuration=TrickLevelConfiguration.from_json( json_dict["trick_level"]), damage_strictness=LayoutDamageStrictness( json_dict["damage_strictness"]), sky_temple_keys=LayoutSkyTempleKeyMode( json_dict["sky_temple_keys"]), elevators=LayoutElevators(json_dict["elevators"]), starting_location=StartingLocation.from_json( json_dict["starting_location"]), available_locations=AvailableLocationsConfiguration.from_json( json_dict["available_locations"]), major_items_configuration=MajorItemsConfiguration.from_json( json_dict["major_items_configuration"], default_prime2_item_database(), ), ammo_configuration=AmmoConfiguration.from_json( json_dict["ammo_configuration"], default_prime2_item_database(), ), translator_configuration=TranslatorConfiguration.from_json( json_dict["translator_configuration"]), hints=HintConfiguration.from_json(json_dict["hints"]), beam_configuration=BeamConfiguration.from_json( json_dict["beam_configuration"]), skip_final_bosses=json_dict["skip_final_bosses"], energy_per_tank=json_dict["energy_per_tank"], split_beam_ammo=json_dict["split_beam_ammo"], )
def from_json_dict(cls, json_dict: dict) -> "LayoutConfiguration": return cls.from_params( trick_level_configuration=TrickLevelConfiguration.from_json(json_dict["trick_level"]), sky_temple_keys=LayoutSkyTempleKeyMode(json_dict["sky_temple_keys"]), elevators=LayoutElevators(json_dict["elevators"]), starting_location=StartingLocation.from_json(json_dict["starting_location"]), randomization_mode=RandomizationMode(json_dict["randomization_mode"]), major_items_configuration=MajorItemsConfiguration.from_json( json_dict["major_items_configuration"], default_prime2_item_database(), ), ammo_configuration=AmmoConfiguration.from_json( json_dict["ammo_configuration"], default_prime2_item_database(), ), translator_configuration=TranslatorConfiguration.from_json(json_dict["translator_configuration"]), hints=HintConfiguration.from_json(json_dict["hints"]), split_beam_ammo=json_dict["split_beam_ammo"], )
def test_encode_no_tricks_are_removed(): from_json = TrickLevelConfiguration.from_json({ "minimal_logic": False, "specific_levels": { "Dash": "no-tricks" } }) encoded = bitpacking._pack_encode_results([ (value_argument, value_format) for value_argument, value_format in from_json.bit_pack_encode({}) ]) assert encoded == b'\x00\x00\x00\x00' decoder = BitPackDecoder(encoded) decoded = TrickLevelConfiguration.bit_pack_unpack(decoder, {}) assert decoded.specific_levels == {}
def test_encode_no_tricks_are_removed(): from_json = TrickLevelConfiguration.from_json( { "minimal_logic": False, "specific_levels": { "Dash": "disabled" } }, game=RandovaniaGame.PRIME2) encoded = bitpacking._pack_encode_results([ (value_argument, value_format) for value_argument, value_format in from_json.bit_pack_encode({}) ]) assert encoded == b'\x00\x00\x00\x00' decoder = BitPackDecoder(encoded) decoded = TrickLevelConfiguration.bit_pack_unpack(decoder, { "reference": TrickLevelConfiguration(False, {}, RandovaniaGame.PRIME2), }) assert decoded.specific_levels == {}
def _configuration_with_data(request): return request.param["encoded"], TrickLevelConfiguration.from_json(request.param["json"])
def _configuration_with_data(request, mocker, echoes_game_description): tricks = echoes_game_description.resource_database.trick[:14] mocker.patch("randovania.layout.trick_level._all_tricks", return_value=tricks) return request.param["encoded"], TrickLevelConfiguration.from_json( request.param["json"])
def _configuration_with_data(request, mocker): mocker.patch("randovania.layout.trick_level._all_trick_indices", return_value=set(range(14))) return request.param["encoded"], TrickLevelConfiguration.from_json( request.param["json"])