ZEPETO.Multiplay.Inventory
11 分
类型 说明 inventoryerror /#inventoryerror 表示库存相关请求失败原因的错误代码。 inventoryrecord /#inventoryrecord 库存商品信息。 inventory /#inventory inventory 用于管理与玩家的 world 内商品库存相关的操作。 inventoryerror enum 表示库存相关请求失败原因的错误代码。 名称 值 说明 unknown 1 错误:未知错误。 networkerror 0 错误:与网络问题相关的错误,包括连接中断或连接不稳定。 inventoryrecord interface 库存商品信息。 属性 名称 类型 说明 productid string 商品 id。 quantity number 商品数量。 createdat date 商品被添加到库存的日期和时间。 updatedat date 商品信息最后一次更新的日期和时间。 inventory interface inventory 用于管理与玩家的 world 内商品库存相关的操作。 方法 use use(productid string, quantity? number, reason? string) → promise\<boolean> 使用玩家库存中的 world 内商品。会抛出 inventoryerror 。 参数 类型 说明 productid string 要使用的商品 id。 quantity (可选) number 要使用的商品数量。默认值为 1 。 reason (可选) string 可选择性地说明使用原因。 返回值: promise\<boolean> — 处理完成时兑现的 promise ,表示成功( true )或失败( false )。 add add(productid string, quantity? number, reason? string) → promise\<boolean> 向玩家库存中添加 world 内商品。会抛出 inventoryerror 。 参数 类型 说明 productid string 要添加的商品 id。 quantity (可选) number 要添加的商品数量。默认值为 1 。 reason (可选) string 可选择性地说明添加原因。 返回值: promise\<boolean> — 处理完成时兑现的 promise ,表示成功( true )或失败( false )。 madd madd(products { productid string; quantity number; reason? string }\[]) → promise\<boolean> 向玩家库存中批量添加 world 内商品。会抛出 inventoryerror 。 参数 类型 说明 products { productid string; quantity number; reason? string }\[] 要添加的商品数组。 返回值: promise\<boolean> — 处理完成时兑现的 promise ,表示成功( true )或失败( false )。 has has(productid string) → promise\<boolean> 检查玩家库存中是否存在指定的 world 内商品。会抛出 inventoryerror 。 参数 类型 说明 productid string 要检查的商品 id。 返回值: promise\<boolean> — 处理完成时兑现的 promise ,表示存在( true )或不存在( false )。 get get(productid string) → promise\<inventoryrecord | null> 从玩家库存中获取 world 内商品。会抛出 inventoryerror 。 参数 类型 说明 productid string 要获取的商品 id。 返回值: promise\<inventoryrecord | null> — 处理完成时兑现的 promise ,携带获取到的 inventoryrecord 对象。 remove remove(productid string) → promise\<boolean> 从玩家库存中移除 world 内商品。会抛出 inventoryerror 。 参数 类型 说明 productid string 要移除的商品 id。 返回值: promise\<boolean> — 处理完成时兑现的 promise ,表示成功( true )或失败( false )。 list list() → promise\<inventoryrecord\[]> 从玩家库存中获取所有 world 内商品。会抛出 inventoryerror 。 返回值: promise\<inventoryrecord\[]> — 处理完成时兑现的 promise ,携带获取到的 inventoryrecord 对象数组。
