コード例 #1
0
def test_multi_create_pickup_data_for_other(pickup_for_create_pickup_data):
    # Setup
    multi = ItemResourceInfo(10, "Multiworld", "Multiworld", 30, None)
    solo = pickup_exporter.PickupExporterSolo(
        pickup_exporter.GenericAcquiredMemo())
    creator = pickup_exporter.PickupExporterMulti(
        solo, multi, PlayersConfiguration(0, {
            0: "You",
            1: "Someone"
        }))
    model = MagicMock()
    resource_a = ItemResourceInfo(1, "A", "A", 10, None)
    resource_b = ItemResourceInfo(2, "B", "B", 10, None)

    # Run
    data = creator.create_details(
        PickupIndex(10), PickupTarget(pickup_for_create_pickup_data,
                                      1), pickup_for_create_pickup_data,
        PickupModelStyle.ALL_VISIBLE, "Scan Text", model)

    # Assert
    assert data == pickup_exporter.ExportedPickupDetails(
        index=PickupIndex(10),
        scan_text="Someone's Scan Text",
        hud_text=['Sent Cake to Someone!'],
        conditional_resources=[
            ConditionalResources(None, None, ((multi, 11), )),
        ],
        conversion=[],
        model=model,
    )
コード例 #2
0
def test_multi_create_pickup_data_for_self(pickup_for_create_pickup_data):
    # Setup
    solo = pickup_exporter.PickupExporterSolo(
        pickup_exporter.GenericAcquiredMemo())
    creator = pickup_exporter.PickupExporterMulti(
        solo, MagicMock(), PlayersConfiguration(0, {
            0: "You",
            1: "Someone"
        }))
    model = MagicMock()
    resource_a = ItemResourceInfo(1, "A", "A", 10, None)
    resource_b = ItemResourceInfo(2, "B", "B", 10, None)

    # Run
    data = creator.create_details(
        PickupIndex(10), PickupTarget(pickup_for_create_pickup_data,
                                      0), pickup_for_create_pickup_data,
        PickupModelStyle.ALL_VISIBLE, "Scan Text", model)

    # Assert
    assert data == pickup_exporter.ExportedPickupDetails(
        index=PickupIndex(10),
        scan_text="Your Scan Text",
        hud_text=['A acquired!', 'B acquired!'],
        conditional_resources=[
            ConditionalResources("A", None, ((resource_a, 1), )),
            ConditionalResources("B", resource_a, ((resource_b, 1), )),
        ],
        conversion=[],
        model=model,
    )
コード例 #3
0
def test_run_validated_hud_text(randomizer_data):
    # Setup
    rng = MagicMock()
    rng.randint.return_value = 0
    details = pickup_exporter.ExportedPickupDetails(
        index=PickupIndex(0),
        scan_text="scan",
        hud_text=["Energy Transfer Module acquired!"],
        conditional_resources=[
            ConditionalResources(None, None, ()),
        ],
        conversion=[],
        model=PickupModel(
            game=RandovaniaGame.PRIME2,
            name="EnergyTransferModule",
        ),
    )

    # Run
    data = claris_patcher_file.echoes_pickup_details_to_patcher(
        details, rng, claris_patcher_file._get_model_mapping(randomizer_data))

    # Assert
    assert data['hud_text'] == ['Run validated!']
コード例 #4
0
def test_create_pickup_list_random_data_source(has_memo_data: bool,
                                               empty_patches):
    # Setup
    rng = Random(5000)
    resource_b = ItemResourceInfo(2, "B", "B", 10, None)

    model_1 = MagicMock(spec=PickupModel)
    model_2 = MagicMock(spec=PickupModel)
    useless_model = PickupModel(game=RandovaniaGame.PRIME3, name="Useless")

    pickup_a = PickupEntry("A",
                           model_1,
                           ItemCategory.TEMPLE_KEY,
                           ItemCategory.KEY,
                           progression=tuple())
    pickup_b = PickupEntry("B",
                           model_2,
                           ItemCategory.SUIT,
                           ItemCategory.LIFE_SUPPORT,
                           progression=((resource_b, 1), (resource_b, 1)))
    pickup_c = PickupEntry("C",
                           model_2,
                           ItemCategory.EXPANSION,
                           ItemCategory.MISSILE_RELATED,
                           progression=tuple())
    useless_pickup = PickupEntry("Useless",
                                 useless_model,
                                 ItemCategory.ETM,
                                 ItemCategory.ETM,
                                 progression=tuple())

    patches = empty_patches.assign_pickup_assignment({
        PickupIndex(0):
        PickupTarget(pickup_a, 0),
        PickupIndex(2):
        PickupTarget(pickup_b, 0),
        PickupIndex(3):
        PickupTarget(pickup_a, 0),
        PickupIndex(4):
        PickupTarget(pickup_c, 0),
    })

    if has_memo_data:
        memo_data = {
            "A": "This is an awesome item A",
            "B": "This is B. It is good.",
            "C": "What a nice day to have a C",
            "Useless": "Try again next time",
        }
    else:
        memo_data = {
            name: "{} acquired!".format(name)
            for name in ("A", "B", "C", "Useless")
        }

    creator = pickup_exporter.PickupExporterSolo(memo_data)

    # Run
    result = pickup_exporter.export_all_indices(
        patches,
        PickupTarget(useless_pickup, 0),
        5,
        rng,
        PickupModelStyle.HIDE_ALL,
        PickupModelDataSource.RANDOM,
        creator,
        pickup_creator.create_visual_etm(),
    )

    # Assert
    assert len(result) == 5
    assert result[0] == pickup_exporter.ExportedPickupDetails(
        index=PickupIndex(0),
        scan_text="A",
        hud_text=[memo_data["A"]],
        conditional_resources=[ConditionalResources("A", None, ())],
        conversion=[],
        model=model_1,
    )
    assert result[1] == pickup_exporter.ExportedPickupDetails(
        index=PickupIndex(1),
        scan_text="A",
        hud_text=[memo_data["A"]],
        conditional_resources=[ConditionalResources("Useless", None, ())],
        conversion=[],
        model=model_1,
    )
    assert result[2] == pickup_exporter.ExportedPickupDetails(
        index=PickupIndex(2),
        scan_text="C",
        hud_text=[memo_data["C"], memo_data["C"]],
        conditional_resources=[
            ConditionalResources("B", None, ((resource_b, 1), )),
            ConditionalResources("B", resource_b, ((resource_b, 1), )),
        ],
        conversion=[],
        model=model_2,
    )
    assert result[3] == pickup_exporter.ExportedPickupDetails(
        index=PickupIndex(3),
        scan_text="B",
        hud_text=[memo_data["B"]],
        conditional_resources=[ConditionalResources("A", None, ())],
        conversion=[],
        model=model_2,
    )
    assert result[4] == pickup_exporter.ExportedPickupDetails(
        index=PickupIndex(4),
        scan_text="A",
        hud_text=[memo_data["A"]],
        conditional_resources=[ConditionalResources("C", None, ())],
        conversion=[],
        model=model_1,
    )
コード例 #5
0
def test_create_pickup_list(model_style: PickupModelStyle, empty_patches):
    # Setup
    has_scan_text = model_style in {
        PickupModelStyle.ALL_VISIBLE, PickupModelStyle.HIDE_MODEL
    }
    rng = Random(5000)

    model_0 = MagicMock(spec=PickupModel)
    model_1 = MagicMock(spec=PickupModel)
    model_2 = MagicMock(spec=PickupModel)
    useless_model = PickupModel(
        game=RandovaniaGame.PRIME2,
        name="EnergyTransferModule",
    )

    useless_resource = ItemResourceInfo(0, "Useless", "Useless", 10, None)
    resource_a = ItemResourceInfo(1, "A", "A", 10, None)
    resource_b = ItemResourceInfo(2, "B", "B", 10, None)
    pickup_a = PickupEntry(
        "P-A",
        model_1,
        ItemCategory.TEMPLE_KEY,
        ItemCategory.KEY,
        progression=((resource_a, 1), ),
    )
    pickup_b = PickupEntry(
        "P-B",
        model_2,
        ItemCategory.SUIT,
        ItemCategory.LIFE_SUPPORT,
        progression=((resource_b, 1), (resource_a, 5)),
    )
    pickup_c = PickupEntry("P-C",
                           model_2,
                           ItemCategory.EXPANSION,
                           ItemCategory.MISSILE_RELATED,
                           progression=tuple(),
                           extra_resources=((resource_b, 2), (resource_a, 1)),
                           unlocks_resource=True,
                           resource_lock=ResourceLock(resource_a, resource_a,
                                                      useless_resource))

    useless_pickup = PickupEntry("P-Useless",
                                 model_0,
                                 ItemCategory.ETM,
                                 ItemCategory.ETM,
                                 progression=((useless_resource, 1), ))
    patches = empty_patches.assign_pickup_assignment({
        PickupIndex(0):
        PickupTarget(pickup_a, 0),
        PickupIndex(2):
        PickupTarget(pickup_b, 0),
        PickupIndex(3):
        PickupTarget(pickup_a, 0),
        PickupIndex(4):
        PickupTarget(pickup_c, 0),
    })
    creator = pickup_exporter.PickupExporterSolo(
        pickup_exporter.GenericAcquiredMemo())

    # Run
    result = pickup_exporter.export_all_indices(
        patches,
        PickupTarget(useless_pickup, 0),
        5,
        rng,
        model_style,
        PickupModelDataSource.ETM,
        creator,
        pickup_creator.create_visual_etm(),
    )

    # Assert
    assert len(result) == 5
    assert result[0] == pickup_exporter.ExportedPickupDetails(
        index=PickupIndex(0),
        scan_text="P-A" if has_scan_text else "Unknown item",
        hud_text=["A acquired!"] if model_style != PickupModelStyle.HIDE_ALL
        else ['Unknown item acquired!'],
        conditional_resources=[
            ConditionalResources("A", None, ((resource_a, 1), ))
        ],
        conversion=[],
        model=model_1
        if model_style == PickupModelStyle.ALL_VISIBLE else useless_model,
    )
    assert result[1] == pickup_exporter.ExportedPickupDetails(
        index=PickupIndex(1),
        scan_text="P-Useless" if has_scan_text else "Unknown item",
        hud_text=["Useless acquired!"]
        if model_style != PickupModelStyle.HIDE_ALL else
        ['Unknown item acquired!'],
        conditional_resources=[
            ConditionalResources("Useless", None, ((useless_resource, 1), ))
        ],
        conversion=[],
        model=model_0
        if model_style == PickupModelStyle.ALL_VISIBLE else useless_model,
    )
    assert result[2] == pickup_exporter.ExportedPickupDetails(
        index=PickupIndex(2),
        scan_text="P-B. Provides the following in order: B, A"
        if has_scan_text else "Unknown item",
        hud_text=["B acquired!", "A acquired!"]
        if model_style != PickupModelStyle.HIDE_ALL else
        ['Unknown item acquired!', 'Unknown item acquired!'],
        conditional_resources=[
            ConditionalResources("B", None, ((resource_b, 1), )),
            ConditionalResources("A", resource_b, ((resource_a, 5), )),
        ],
        conversion=[],
        model=model_2
        if model_style == PickupModelStyle.ALL_VISIBLE else useless_model,
    )
    assert result[3] == pickup_exporter.ExportedPickupDetails(
        index=PickupIndex(3),
        scan_text="P-A" if has_scan_text else "Unknown item",
        hud_text=["A acquired!"] if model_style != PickupModelStyle.HIDE_ALL
        else ['Unknown item acquired!'],
        conditional_resources=[
            ConditionalResources("A", None, ((resource_a, 1), ))
        ],
        conversion=[],
        model=model_1
        if model_style == PickupModelStyle.ALL_VISIBLE else useless_model,
    )
    assert result[4] == pickup_exporter.ExportedPickupDetails(
        index=PickupIndex(4),
        scan_text="P-C. Provides 2 B and 1 A"
        if has_scan_text else "Unknown item",
        hud_text=["P-C acquired!"] if model_style != PickupModelStyle.HIDE_ALL
        else ['Unknown item acquired!'],
        conditional_resources=[
            ConditionalResources("P-C", None, (
                (resource_b, 2),
                (resource_a, 1),
            ))
        ],
        conversion=[
            ResourceConversion(source=useless_resource, target=resource_a)
        ],
        model=model_2
        if model_style == PickupModelStyle.ALL_VISIBLE else useless_model,
    )