> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# インベントリ コレクション

> PlayFab Economy v2 のインベントリ コレクションを使用して、プレイヤーのインベントリをキャラクター、装備、収納コンテナー用の名前付きグループに分割します。

# コレクション

<Info>
  Economy v2 が一般提供 (GA) されました。サポートとフィードバックについては、[PlayFab フォーラム](https://community.playfab.com) を参照してください。
</Info>

Economy v2 の Inventory サービスは、インベントリのニーズに対してより高い柔軟性とサポートを追加できるコレクションの概念を導入します。コレクションは、単一のプレイヤー/PlayerId が複数のインベントリを持てるようにする仕組みです。この機能は、同じプレイヤーの異なるキャラクター向けに複数のインベントリを管理する場合や、異なるプラットフォーム向けに個別のインベントリを持つ場合など、さまざまな用途に使用できます。

Inventory API 呼び出しは、アクションを実行するコレクション/インベントリを指定する `CollectionId` パラメーターを受け取ることができます。新しいコレクションの作成は、未使用の CollectionId にアイテム/スタックを追加することで行われます。

## インベントリ コレクションの管理

### GetInventoryCollectionIds

`GetInventoryCollectionIds` API を使用して、特定のプレイヤーの `CollectionId` のリストを取得できます。プレイヤーは自分自身の ID リストにのみアクセスできます。Title Entity では `Entity` パラメーターを渡して、アクセスしたいプレイヤーのインベントリを指定できます。

`GetInventoryCollectionIds` リクエストの例:

```json theme={null}
{
  "Entity": {
    "Type": "title_player_account",
    "Id": "ABCD12345678"
  },
  "Count": 15,
  "ContinuationToken": "abc="
}
```

このリクエストは、次のレスポンスを返します。

```json theme={null}
{
  "data": {
  "CollectionIds": [
    "default",
    "main_character"
    ]
  }
}
```

#### 継続トークン

検索レスポンスから返される `ContinuationToken` フィールドは、複数の結果件数をページングするためにインベントリ リクエストに渡すことができます。

### 新しいインベントリ コレクションの追加

プレイヤーの新しいコレクションを作成するには、新しい CollectionId を指定して任意の書き込みリクエストを実行します。

たとえば、次の `AddInventoryItems` リクエストは collectionId `main_character` を使用しています。

```json theme={null}
{
    "Entity": {
        "Type": "title_player_account",
        "Id": "ABCD12345678"
    },
    "CollectionId": "main_character",
    "Item": {
        "Id": "0b440353-bdbc-48d8-8873-f0988c1f9d8b",
    },
    "Amount": 10,
}
```

上記のリクエストは、まったく新しいインベントリ コレクションを作成してアイテムを 10 個追加するか、既存の `main_character` インベントリ コレクションが既に存在する場合はそこに 10 個追加します。

### DeleteInventoryCollection

`DeleteInventoryCollectionId` API では、削除する `CollectionId` を定義できます。削除は非同期操作であり、大きなコレクションでは時間がかかる場合があります。削除操作が完了するまで、コレクションを再作成することはできません。

`DeleteInventoryCollectionIds` リクエストの例:

```json theme={null}
{
  "Entity": {
    "Type": "title_player_account",
    "Id": "ABCD12345678"
  },
  "CollectionId": "main_character"
}
```

<Note>
  現在、インベントリ コレクションを削除する唯一の方法は API です。Game Manager では、現在のところ、新規および既存のコレクションを表示したり、アイテムを追加したりすることしかできません。将来的に追加機能が加わる予定です。
</Note>

### ExecuteInventoryOperations API

`ExecuteInventoryOperations` API で `CollectionId` パラメーターを設定できます。このパラメーターを使用すると、操作を実行するコレクションを定義できます。

スタックを使用した `ExecuteInventoryOperations` リクエストの例:

```json theme={null}
{
    "Entity": {
        "Type": "title_player_account",
        "Id": "ABCD12345678"
    },
    "CollectionId": "main_character",
    "Operations": [
        {
            "Update": {
                "Item" {
                    "Id": "0b440353-bdbc-48d8-8873-f0988c1f9d8b",
                    "Amount": 10
                }
            }
        },
        {
            "Subtract": {
                "Item" {
                    "Id": "0b440353-bdbc-48d8-8873-f0988c1f9d8b",
                },
                "Amount": 5
            }
        }
    ]
}
```


## Related topics

- [Economy V2 の制限](/ja-jp/services/playfab/economy-monetization/economy-v2/limits.md)
- [PFInventoryDeleteInventoryCollectionAsync](/ja-jp/services/playfab/api-references/c/pfinventory/functions/pfinventorydeleteinventorycollectionasync.md)
- [PlayFab Inventory API](/ja-jp/services/playfab/economy-monetization/economy-v2/inventory/index.md)
- [インベントリの ETag](/ja-jp/services/playfab/economy-monetization/economy-v2/inventory/etags.md)
- [アイテムとインベントリの概要](/ja-jp/services/playfab/economy-monetization/economy-v2/inventory/items-and-inventory-overview.md)
