# Function: exchangeItems
▸ exchangeItems(params: ExchangeItemsParams): Promise‹ExchangeItemsRes›
根据指定的兑换方案和物品,进行兑换
example
import { backpackSystem, synthesisSystem } from '@timi/mogs-sdk';
const exchangeOptions = await synthesisSystem.exchangeOptions;
const someExchangeOptionId = exchangeOptions.length && exchangeOptions[0].id;
const backpacks = await backpackSystem.backpacks;
const someBackpackItemId = backpacks.length && backpacks[0]?.items.get(0)?.itemUid;
const someOtherBackpackItemId = backpacks.length && backpacks[0]?.items.get(1)?.itemUid;
await synthesisSystem.exchangeItems({
exchangeOptionId: someExchangeOptionId,
itemsToExchange: [
{ backpackItemId: someBackpackItemId as Long, count: 2 },
{ backpackItemId: someOtherBackpackItemId as Long, count: 3 },
],
});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
throws {@link MogsError}
# 参数:
| 属性 | 类型 |
|---|---|
params | ExchangeItemsParams |
ExchangeItemsParams
| 属性 | 类型 | 描述 |
|---|---|---|
exchangeOptionId | number | 要使用的物品兑换方案 ID |
itemsToExchange | Readonly‹object›[] | 要被兑换的物品列表 |
complete? | Method | 操作完成时(成功或失败),均会调用该回调函数 |
fail? | Method | 操作失败时,调用该回调函数 |
success? | Method | 操作成功时,调用该回调函数 |
# 返回值:
Promise‹ExchangeItemsRes›