async def _emit_collection(self):
        multiworld_magic_item = self.game.resource_database.multiworld_magic_item
        magic_address = 0xA00000 + _powerup_offset(multiworld_magic_item.index)
        new_magic_value = self.collect_location_combo.currentData() + 1

        magic_amount, magic_capacity = self._read_memory_format(
            ">II", magic_address)
        magic_amount += new_magic_value
        magic_capacity += new_magic_value
        self._write_memory(magic_address,
                           struct.pack(">II", magic_amount, magic_capacity))
async def test_update_inventory_with_change(backend, item):
    # Setup
    backend.patches = dol_patcher.ALL_VERSIONS_PATCHES[0]
    backend._perform_memory_operations = AsyncMock()
    backend._inventory = {
        item: InventoryItem(0, 0)
        for item in backend.game.resource_database.item
    }
    new_inventory = copy.copy(backend._inventory)
    new_inventory[backend.game.resource_database.multiworld_magic_item] = InventoryItem(1, 15)

    # Run
    await backend._update_inventory(new_inventory)

    # Assert
    backend._perform_memory_operations.assert_awaited_once_with([
        MemoryOperation(
            address=backend._get_player_state_pointer(),
            write_bytes=struct.pack(">II", 1, 15),
            read_byte_count=8,
            offset=connection_backend._powerup_offset(backend.game.resource_database.multiworld_magic_item.index),
        )
    ])
 def _get_magic_address(self):
     multiworld_magic_item = self.game.resource_database.multiworld_magic_item
     magic_address = 0xA00000 + _powerup_offset(multiworld_magic_item.index)
     return magic_address