# 在你的多款遊戲之間共用排行榜和成就

> 讓 Agent 建立一個 Game Center 群組，把你的兩款或更多遊戲放進去，並為該群組加入群組中每款遊戲共用的排行榜和成就。

Source: https://air.build/tw/docs/app-store/share-game-center-between-your-games/

Game Center 群組讓你的兩款或更多遊戲共用排行榜、成就、挑戰和活動，例如同一款遊戲的免費版和付費版。Apple 的說明表示一個 App 只能屬於一個群組，而且一個群組可以混合不同平台的 App，例如一個 iOS App 和一個 macOS App。請參閱 Apple 的 [Overview of Game Center groups](https://developer.apple.com/help/app-store-connect/configure-game-center/overview-of-game-center-groups)。

> [!NOTE]
> AirBuild 沒有 Game Center 畫面。你在專案的聊天中詢問 Agent，它會使用 `asc game-center groups` 和 `asc game-center details`（列在 [asc：App 與 App Store 頁面](https://air.build/tw/docs/cli/asc-apps/#game-center) 的 `game-center` 下）。要查看結果，請詢問 Agent，或在 App Store Connect 中打開你的 App。

## 提出要求之前

- 每款遊戲都需要 Game Center。請參閱[加入 Game Center 排行榜和成就](https://air.build/tw/docs/app-store/add-game-center-leaderboards/)。
- 這些遊戲必須是你的 Agent 所用 Apple 團隊中的 App。`asc` 使用團隊擁有者在 AirBuild 中連結的 Apple 團隊。請參閱[連結你的 Apple 開發者帳號](https://air.build/tw/docs/app-store/connect-apple-developer-account/)。
- `asc` 可以把遊戲放進群組，但它的說明中沒有再把遊戲移出的方法。Apple 的 [Manage groups](https://developer.apple.com/help/app-store-connect/configure-game-center/manage-groups) 介紹了 App 何時以及如何在網頁版 App Store Connect 中離開群組。
- 如果你的遊戲已經有自己的排行榜或成就，`asc` 的說明沒有提到遊戲加入群組時它們會如何。在網頁版 App Store Connect 中，Apple 會引導你選擇群組保留哪些；請參閱 [Manage groups](https://developer.apple.com/help/app-store-connect/configure-game-center/manage-groups)。對於這樣的遊戲，你可能比較想在那裡進行。

## 建立群組

在任一款遊戲的專案聊天中提出要求，並說出兩款遊戲的名稱，例如：

```text
Make a Game Center group called "Fox Run games" and put Fox Run and Fox Run Lite in it.
```

1. Agent 用 `asc game-center groups create` 建立群組。群組的參考名稱是供你使用的，玩家看不到。
2. 對於每款遊戲，它用 `asc game-center details update --game-center-group-id` 把該遊戲的 Game Center 設定放進群組。
3. 它用 `asc game-center groups details list` 檢查群組中有哪些遊戲，並在聊天中告訴你。

## 加入共用的排行榜和成就

像為單一遊戲那樣提出要求，並說明它們是給群組的，例如：

```text
Add a shared leaderboard for the best score, highest first, to the Fox Run games group, and an achievement for the first win. Then update both games to use them.
```

- Agent 用 `--group-id` 建立它們，例如 `asc game-center leaderboards create --group-id`。挑戰、活動和排行榜組也可以用同樣的方式屬於群組。
- 群組的排行榜和成就有自己的 ID，以 `grp.` 開頭。沒有這個前綴的 ID 會被 `asc` 拒絕。
- 每款遊戲的程式碼依 ID 回報分數和成就，所以每款遊戲都需要修改才能使用群組的 ID。Agent 可以在每款遊戲的專案中進行修改。

要查看群組包含什麼，請問「Fox Run games 群組中有什麼？」。Agent 會用 `asc game-center groups leaderboards list`、`achievements list`、`leaderboard-sets list`、`activities list` 和 `challenges list` 列出。

### 你還可以設定什麼

| 選項 | 方式 |
| --- | --- |
| 哪些排行榜或成就屬於群組 | `asc game-center groups leaderboards set` 或 `achievements set`。每個指令都會用給出的列表取代群組的整個列表，所以需要 `--confirm`，Agent 會先詢問你。請說出完整的列表。 |
| 遊戲首先顯示哪個群組排行榜 | 為每款遊戲執行 `asc game-center details update --default-group-leaderboard-v2-id`。 |
| 群組的參考名稱 | `asc game-center groups update`。 |

## 發佈遊戲

新的群組排行榜和成就和單一遊戲的一樣需要經過 App 審查：請 Agent 把它們加入你下一次 App 審查提交中（`asc review items add`），然後照常提交。請參閱[提交 App 審查並發布](https://air.build/tw/docs/app-store/submit-for-review/#submit-a-version)。

Apple 的 [Overview of Game Center groups](https://developer.apple.com/help/app-store-connect/configure-game-center/overview-of-game-center-groups) 說明了哪些內容隨每款遊戲的版本上線，以及哪些內容不需要版本也會保持上線。

## 常見問題

**一款遊戲可以屬於兩個群組嗎？**

不可以。Apple 的說明表示一個 App 只能屬於一個群組。

**可以把遊戲移出群組嗎？**

`asc` 沒有這樣的指令。Apple 的 [Manage groups](https://developer.apple.com/help/app-store-connect/configure-game-center/manage-groups) 介紹了如何在網頁版 App Store Connect 中將 App 從群組中移除，以及何時可以這樣做。

**Agent 說 ID 必須以 grp. 開頭。**

`asc` 停止並顯示 `--vendor-id must start with "grp." when using --group-id`。為群組製作的排行榜、成就、挑戰、活動和排行榜組需要以 `grp.` 開頭的 ID。請讓 Agent 用這樣的 ID 再試一次。

**可以刪除群組嗎？**

詢問 Agent。`asc game-center groups delete` 需要 `--confirm`，所以它會先詢問你。`asc` 沒有復原已刪除群組的指令。

**兩款遊戲的玩家可以一起線上遊玩嗎？**

這是在 App Store Connect 中依遊戲版本設定的多人遊戲相容性；`asc` 可以列出它，但無法設定。請參閱 Apple 的 [Add multiplayer compatibility](https://developer.apple.com/help/app-store-connect/configure-game-center/add-multiplayer-compatibility)，以及[用 Game Center 為線上對戰配對玩家](https://air.build/tw/docs/app-store/match-players-for-multiplayer/)。
