def test_give_item_patch(powerup_address: all_prime_dol_patches.PowerupFunctionsAddresses):
    # Run
    patch = all_prime_dol_patches.adjust_item_amount_and_capacity_patch(powerup_address,
                                                                        RandovaniaGame.METROID_PRIME_ECHOES, 10, 5)
    data = bytes(assembler.assemble_instructions(0x80008020, patch))

    # Assert
    assert data == (b"\x80\x7f\x15\x0c\x38\x80\x00\x0a\x38\xa0\x00\x05\x48\x06\xd8\xc5\x80\x7f\x15\x0c"
                    b"\x38\x80\x00\x0a\x38\xa0\x00\x05\x48\x06\xd7\x25")
Exemple #2
0
    async def _patches_for_pickup(self, provider_name: str, pickup: PickupEntry, inventory: Inventory):
        item_name, resources_to_give = self._resources_to_give_for_pickup(pickup, inventory)

        self.logger.debug(f"Resource changes for {pickup.name} from {provider_name}: {resources_to_give}")
        patches = [
            all_prime_dol_patches.adjust_item_amount_and_capacity_patch(
                self.version.powerup_functions, self.game.game,
                item.extra["item_id"], delta,
            )
            for item, delta in resources_to_give.items()
        ]
        return patches, format_received_item(item_name, provider_name)
def test_create_remote_execution_body(string_display: all_prime_dol_patches.StringDisplayPatchAddresses,
                                      powerup_address: all_prime_dol_patches.PowerupFunctionsAddresses):
    # Run
    patch_address, patch_bytes = all_prime_dol_patches.create_remote_execution_body(string_display, [
        *all_prime_dol_patches.call_display_hud_patch(string_display),
        *all_prime_dol_patches.adjust_item_amount_and_capacity_patch(powerup_address,
                                                                     RandovaniaGame.METROID_PRIME_ECHOES, 3, 12),
    ])

    # Assert
    assert patch_address == string_display.update_hint_state + 0x58

    assert patch_bytes == (b'\x3c\xa0\x41\x00\x38\xc0\x00\x00\x38\xe0\x00\x01\x39\x20\x00\x09\x90\xa1\x00\x10'
                           b'\x98\xe1\x00\x14\x98\xc1\x00\x15\x98\xc1\x00\x16\x98\xe1\x00\x17\x91\x21\x00\x18'
                           b'\x38\x61\x00\x1c\x3c\x80\x00\x00\x60\x84\x90\x00\x48\x2c\x73\x31\x38\x81\x00\x10'
                           b'\x48\x03\x33\x15\x80\x7f\x15\x0c\x38\x80\x00\x03\x38\xa0\x00\x0c\x48\x03\xd8\x2d'
                           b'\x80\x7f\x15\x0c\x38\x80\x00\x03\x38\xa0\x00\x0c\x48\x03\xd6\x8d\x38\xc0\x00\x00'
                           b'\x98\xdf\x00\x02\xbb\xc1\x00\x2c\x80\x01\x00\x38\x7c\x08\x03\xa6\x38\x21\x00\x34'
                           b'\x4e\x80\x00\x20')
Exemple #4
0
async def test_update_inventory_label(executor: DebugExecutorWindow,
                                      echoes_resource_database):
    # Setup
    await executor._ensure_initialized_game_memory()
    connector = PrimeRemoteConnector(executor._used_version)

    await connector.execute_remote_patches(
        executor,
        [
            DolRemotePatch([],
                           all_prime_dol_patches.increment_item_capacity_patch(
                               executor._used_version.powerup_functions,
                               echoes_resource_database.game_enum,
                               echoes_resource_database.multiworld_magic_item.
                               extra["item_id"],
                               delta=2,
                           )),
            DolRemotePatch(
                [],
                all_prime_dol_patches.adjust_item_amount_and_capacity_patch(
                    executor._used_version.powerup_functions,
                    echoes_resource_database.game_enum,
                    echoes_resource_database.energy_tank.extra["item_id"],
                    delta=4,
                )),
        ],
    )
    executor._handle_remote_execution()

    # Run
    await executor._update_inventory_label()

    # Assert
    assert "Energy Tank x 4/4" in executor.inventory_label.text()
    assert "Multiworld Magic Identifier x 0/2" in executor.inventory_label.text(
    )