コード例 #1
0
def test_create_string_patches(mock_stk_create_hints: MagicMock,
                               mock_stk_hide_hints: MagicMock,
                               mock_item_create_hints: MagicMock,
                               stk_mode: SkyTempleKeyHintMode,
                               ):
    # Setup
    game = MagicMock()
    patches = MagicMock()
    rng = MagicMock()
    mock_item_create_hints.return_value = ["item", "hints"]
    mock_stk_create_hints.return_value = ["show", "hints"]
    mock_stk_hide_hints.return_value = ["hide", "hints"]

    # Run
    result = patcher_file._create_string_patches(HintConfiguration(sky_temple_keys=stk_mode),
                                                 game,
                                                 patches,
                                                 rng)

    # Assert
    expected_result = ["item", "hints"]
    mock_item_create_hints.assert_called_once_with(patches, game.world_list, rng)

    if stk_mode == SkyTempleKeyHintMode.DISABLED:
        mock_stk_hide_hints.assert_called_once_with()
        mock_stk_create_hints.assert_not_called()
        expected_result.extend(["hide", "hints"])

    else:
        mock_stk_create_hints.assert_called_once_with(patches, game.world_list,
                                                      stk_mode == SkyTempleKeyHintMode.HIDE_AREA)
        mock_stk_hide_hints.assert_not_called()
        expected_result.extend(["show", "hints"])

    assert result == expected_result
コード例 #2
0
 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"],
     )
コード例 #3
0
def test_create_string_patches(
    mock_stk_create_hints: MagicMock,
    mock_stk_hide_hints: MagicMock,
    mock_item_create_hints: MagicMock,
    mock_logbook_title_string_patches: MagicMock,
    stk_mode: SkyTempleKeyHintMode,
    mocker,
):
    # Setup
    game = MagicMock()
    all_patches = MagicMock()
    rng = MagicMock()
    mock_item_create_hints.return_value = ["item", "hints"]
    mock_stk_create_hints.return_value = ["show", "hints"]
    mock_stk_hide_hints.return_value = ["hide", "hints"]
    player_config = PlayersConfiguration(0, {0: "you"})
    mock_logbook_title_string_patches.return_values = []
    mock_area_namer: MagicMock = mocker.patch(
        "randovania.games.prime.patcher_file_lib.hint_lib.AreaNamer")

    # Run
    result = claris_patcher_file._create_string_patches(
        HintConfiguration(sky_temple_keys=stk_mode),
        game,
        all_patches,
        {0: RandovaniaGame.PRIME2},
        player_config,
        rng,
    )

    # Assert
    expected_result = ["item", "hints"]
    mock_item_create_hints.assert_called_once_with(all_patches, player_config,
                                                   game.world_list, rng)
    mock_logbook_title_string_patches.assert_called_once_with()

    if stk_mode == SkyTempleKeyHintMode.DISABLED:
        mock_stk_hide_hints.assert_called_once_with()
        mock_stk_create_hints.assert_not_called()
        expected_result.extend(["hide", "hints"])

    else:
        mock_stk_create_hints.assert_called_once_with(
            all_patches, player_config, game.resource_database,
            {0: mock_area_namer.return_value},
            stk_mode == SkyTempleKeyHintMode.HIDE_AREA)
        mock_stk_hide_hints.assert_not_called()
        mock_area_namer.assert_called_once_with(ANY)
        expected_result.extend(["show", "hints"])

    assert result == expected_result
コード例 #4
0
def test_create_string_patches(
    mock_stk_create_hints: MagicMock,
    mock_stk_hide_hints: MagicMock,
    mock_item_create_hints: MagicMock,
    mock_logbook_title_string_patches: MagicMock,
    stk_mode: SkyTempleKeyHintMode,
):
    # Setup
    game = MagicMock()
    all_patches = MagicMock()
    rng = MagicMock()
    mock_item_create_hints.return_value = ["item", "hints"]
    mock_stk_create_hints.return_value = ["show", "hints"]
    mock_stk_hide_hints.return_value = ["hide", "hints"]
    player_config = PlayersConfiguration(0, {0: "you"})
    mock_logbook_title_string_patches.return_values = []

    # Run
    result = patcher_file._create_string_patches(
        HintConfiguration(sky_temple_keys=stk_mode),
        game,
        all_patches,
        player_config,
        rng,
    )

    # Assert
    expected_result = ["item", "hints"]
    mock_item_create_hints.assert_called_once_with(
        all_patches[player_config.player_index], game.world_list, rng)
    mock_logbook_title_string_patches.assert_called_once_with()

    if stk_mode == SkyTempleKeyHintMode.DISABLED:
        mock_stk_hide_hints.assert_called_once_with()
        mock_stk_create_hints.assert_not_called()
        expected_result.extend(["hide", "hints"])

    else:
        mock_stk_create_hints.assert_called_once_with(
            all_patches, player_config, game.world_list,
            stk_mode == SkyTempleKeyHintMode.HIDE_AREA)
        mock_stk_hide_hints.assert_not_called()
        expected_result.extend(["show", "hints"])

    assert result == expected_result
コード例 #5
0
 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"],
     )