Exemple #1
0
def test_run_filler(mock_retcon_playthrough_filler: MagicMock,
                    echoes_game_description,
                    pickup
                    ):
    # Setup
    configuration = LayoutConfiguration.default()
    rng = Random(5000)
    status_update = MagicMock()
    item_pool = [pickup]
    patches = GamePatches.with_game(echoes_game_description)

    logbook_nodes = [node for node in echoes_game_description.world_list.all_nodes if isinstance(node, LogbookNode)]

    mock_retcon_playthrough_filler.return_value = patches.assign_hint(
        logbook_nodes[0].resource(), Hint(HintType.LOCATION, None, PickupIndex(0))
    ).assign_pickup_assignment({PickupIndex(1): pickup})

    # Run
    result_patches, remaining_items = runner.run_filler(configuration, echoes_game_description,
                                                        item_pool, patches,
                                                        rng, status_update)

    # Assert
    assert len(result_patches.hints) == len(logbook_nodes)
    assert [hint for hint in patches.hints.values()
            if hint.item_precision is None or hint.location_precision is None] == []
    assert remaining_items == [pickup]
Exemple #2
0
 def default(cls) -> "Permalink":
     return Permalink(
         seed_number=0,
         spoiler=True,
         patcher_configuration=PatcherConfiguration.default(),
         layout_configuration=LayoutConfiguration.default(),
     )
Exemple #3
0
def test_add_elevator_connections_to_patches_random(echoes_game_data):
    # Setup
    game = data_reader.decode_data(echoes_game_data)
    permalink = dataclasses.replace(Permalink.default(),
                                    layout_configuration=dataclasses.replace(
                                        LayoutConfiguration.default(),
                                        elevators=LayoutElevators.RANDOMIZED))
    expected = dataclasses.replace(GamePatches.with_game(game),
                                   elevator_connection={
                                       589851:
                                       AreaLocation(1039999561, 1868895730),
                                       1572998:
                                       AreaLocation(1039999561, 3479543630),
                                       1966093:
                                       AreaLocation(2252328306, 408633584),
                                       2097251:
                                       AreaLocation(1119434212, 3331021649),
                                       136970379:
                                       AreaLocation(2252328306, 2068511343),
                                       3342446:
                                       AreaLocation(1039999561, 3205424168),
                                       3538975:
                                       AreaLocation(1119434212, 2806956034),
                                       152:
                                       AreaLocation(1006255871, 2889020216),
                                       393260:
                                       AreaLocation(464164546, 3145160350),
                                       524321:
                                       AreaLocation(464164546, 900285955),
                                       589949:
                                       AreaLocation(1006255871, 2278776548),
                                       122:
                                       AreaLocation(464164546, 3528156989),
                                       1245307:
                                       AreaLocation(1006255871, 1345979968),
                                       2949235:
                                       AreaLocation(1006255871, 1287880522),
                                       129:
                                       AreaLocation(1006255871, 2918020398),
                                       2162826:
                                       AreaLocation(1006255871, 1660916974),
                                       4522032:
                                       AreaLocation(1006255871, 3455543403),
                                       38:
                                       AreaLocation(1119434212, 1473133138),
                                       1245332:
                                       AreaLocation(2252328306, 2399252740),
                                       1638535:
                                       AreaLocation(2252328306, 2556480432),
                                   })

    # Run
    result = base_patches_factory.add_elevator_connections_to_patches(
        permalink.layout_configuration,
        Random(permalink.seed_number),
        GamePatches.with_game(game),
    )

    # Assert
    assert result == expected
def test_decode(patches_with_data):
    encoded, expected = patches_with_data

    # Run
    decoded = game_patches_serializer.decode(encoded,
                                             LayoutConfiguration.default())

    # Assert
    assert decoded == expected
Exemple #5
0
def test_encode(mock_dictionary_byte_hash: MagicMock):
    # Setup
    mock_dictionary_byte_hash.return_value = 120
    link = Permalink(
        seed_number=1000,
        spoiler=True,
        patcher_configuration=PatcherConfiguration.default(),
        layout_configuration=LayoutConfiguration.default(),
    )

    # Run
    encoded = link.as_str

    # Assert
    mock_dictionary_byte_hash.assert_called_once_with(
        link.layout_configuration.game_data)
    assert encoded == "MAAAfReMYADv"
Exemple #6
0
def test_retcon_filler_integration():
    layout_configuration = LayoutConfiguration.default()

    rng = Random("fixed-seed!")
    status_update = MagicMock()

    game = data_reader.decode_data(layout_configuration.game_data)
    patches = GamePatches.with_game(game)
    available_pickups = game.pickup_database.all_useful_pickups

    logic, state = logic_bootstrap(layout_configuration, game, patches)
    logic.game.simplify_connections(state.resources)

    filler_patches = retcon.retcon_playthrough_filler(logic, state,
                                                      tuple(available_pickups),
                                                      rng, status_update)
    assert filler_patches == patches
Exemple #7
0
def validate_command_logic(args):
    debug._DEBUG_LEVEL = args.debug
    data = prime_database.decode_data_file(args)
    game = data_reader.decode_data(data)

    if args.layout_file is not None:
        description = LayoutDescription.from_file(Path(args.layout_file))
        configuration = description.permalink.layout_configuration
        patches = description.patches
    else:
        configuration = LayoutConfiguration.default()
        patches = GamePatches.with_game(game).assign_pickup_assignment(
            game.pickup_database.original_pickup_mapping)

    final_state_by_resolve = resolver.resolve(configuration=configuration,
                                              game=game,
                                              patches=patches)
    print(final_state_by_resolve)
def test_output_name_for(mock_shareable_hash: PropertyMock, empty_patches):
    # Setup
    permalink_mock = MagicMock(spec=Permalink(
        seed_number=15000,
        spoiler=True,
        patcher_configuration=PatcherConfiguration.default(),
        layout_configuration=LayoutConfiguration.default(),
    ))
    layout = LayoutDescription(version="0.15.0",
                               permalink=permalink_mock,
                               patches=empty_patches,
                               solver_path=())
    mock_shareable_hash.return_value = "PermalinkStr"

    # Run
    result = simplified_patcher._output_name_for(layout)

    # Assert
    assert result == "Echoes Randomizer - PermalinkStr"
from randovania.layout.layout_description import LayoutDescription, SolverPath, _item_locations_to_pickup_assignment
from randovania.layout.patcher_configuration import PatcherConfiguration
from randovania.layout.permalink import Permalink


@pytest.mark.parametrize("value", LayoutTrickLevel)
def test_pickle_trick_level(value: LayoutTrickLevel):
    assert pickle.loads(pickle.dumps(value)) == value


@pytest.mark.parametrize("permalink", [
    Permalink(
        seed_number=1000,
        spoiler=True,
        patcher_configuration=PatcherConfiguration.default(),
        layout_configuration=LayoutConfiguration.default(),
    )
])
@pytest.mark.parametrize("item_locations", [{}])
@pytest.mark.parametrize("solver_path", [tuple()])
def test_round_trip_default(permalink: Permalink,
                            item_locations: Dict[str, Dict[str, str]],
                            solver_path: Tuple[SolverPath, ...]):

    game = data_reader.decode_data(permalink.layout_configuration.game_data)
    original = LayoutDescription(
        version=randovania.VERSION,
        permalink=permalink,
        patches=GamePatches(
            _item_locations_to_pickup_assignment(game, item_locations),
            claris_randomizer.elevator_connections_for_seed_number(
Exemple #10
0
    ["", "a", "x", "zz", "AAAAfRxALWmCI50gIQD", "AAAAfRxALxmCI50gIQDy"])
def test_decode_invalid(invalid: str):
    with pytest.raises(ValueError):
        Permalink.from_str(invalid)


@pytest.mark.parametrize("spoiler", [False, True])
@pytest.mark.parametrize("patcher", [
    PatcherConfiguration.default(),
    PatcherConfiguration(
        menu_mod=True,
        warp_to_start=False,
    ),
])
@pytest.mark.parametrize("layout", [
    LayoutConfiguration.default(),
    LayoutConfiguration.from_params(
        trick_level=LayoutTrickLevel.HARD,
        sky_temple_keys=LayoutSkyTempleKeyMode.FULLY_RANDOM,
        elevators=LayoutRandomizedFlag.RANDOMIZED,
        pickup_quantities={
            "Missile Expansion": 10,
            "Light Suit": 9,
        },
        starting_location=StartingLocation.default(),
        starting_resources=StartingResources.default(),
    ),
])
def test_round_trip(spoiler: bool, patcher: PatcherConfiguration,
                    layout: LayoutConfiguration):
    # Setup
Exemple #11
0
def _layout_config():
    return LayoutConfiguration.default()