# 為你的遊戲加入 Game Center 挑戰

> 請 Agent 把遊戲的某個排行榜變成 Game Center 挑戰，配上各語言的名稱、描述和圖片，並送交 App 審查。

Source: https://air.build/tw/docs/app-store/add-game-center-challenges/

Game Center 挑戰把遊戲的某個排行榜變成好友之間的比賽。Apple 的說明表示，挑戰建立在排行榜之上，讓玩家在限時比賽中與好友較量；當好友向玩家發起挑戰或超越玩家的分數時，玩家會收到通知。請參閱 Apple 的[管理挑戰](https://developer.apple.com/help/app-store-connect/configure-game-center/manage-challenges)。

Apple 的 GameKit 文章說明，遊戲已經回報到該排行榜的分數也會計入挑戰，玩家會在「遊戲」App 中看到挑戰。請參閱[用排行榜打造吸引人的挑戰](https://developer.apple.com/documentation/gamekit/creating-engaging-challenges-from-leaderboards)。

> [!NOTE]
> AirBuild 沒有 Game Center 畫面。你在專案的聊天中請 Agent 處理，它會使用 `asc game-center challenges`（列在 [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/)開始。該頁面也列出了你的 Apple 開發者帳號需要什麼。

## 要求加入挑戰

在專案的聊天中說明挑戰針對哪個排行榜，以及玩家應該看到什麼文字，例如：

```text
Add a Game Center challenge on the best-score leaderboard. Call it "Beat my score" in English and "Bats mon score" in French, with a one-line description. Make a picture for it too.
```

1. Agent 找到排行榜，並用 `asc game-center challenges create` 建立挑戰，附上參考名稱、挑戰 ID 和該排行榜。
2. 它用 `asc game-center challenges localizations create` 逐一語言加入玩家看到的內容：名稱和描述。
3. 它用 `asc game-center challenges images upload` 以 PNG 格式上傳圖片，可以只用於一種語言，也可以作為所有語言的預設圖片。
4. 它在聊天中告訴你建立了什麼。想隨時查看列表，可以問「遊戲有哪些挑戰？」。Agent 會用 `asc game-center challenges list` 讀取。

圖片可以由 Agent 製作（請參閱[讓 Agent 為你的 App 製作圖片](https://air.build/tw/docs/build/make-pictures-for-your-app/)），也可以由你在聊天中傳送自己的圖片（請參閱[傳送照片、檔案和草圖給 Agent](https://air.build/tw/docs/projects/send-photos-and-files/)）。Apple 的[挑戰參考資料](https://developer.apple.com/help/app-store-connect/reference/game-center/challenges)列出了 Apple 接受的圖片尺寸和格式。

### 需要決定的事項

如果你有偏好，請在要求中說明這些。

| 選項 | 說明 |
| --- | --- |
| 排行榜 | 挑戰所根據的排行榜。 |
| 參考名稱 | 在 App Store Connect 中給你看的名稱。玩家看不到。 |
| 挑戰 ID | 挑戰的 ID。Apple 的參考資料表示它之後無法變更。 |
| 可重複 | 挑戰能否玩多次。Apple 的參考資料表示，可重複挑戰的玩家可以選擇自己有幾次機會。 |
| 名稱和描述 | 玩家在各語言中看到的文字。 |
| 圖片 | 每種語言一張，或所有語言共用一張預設圖片。 |

## 送交 App 審查

請 Agent 把挑戰放進你下一次的 App 審查提交項目中，例如：

```text
Add the new challenge to the App Review submission for version 1.3.
```

Agent 會用 `asc review items add` 加入它，這個指令的說明把挑戰列為提交項目可以包含的項目之一（請參閱 [asc：審查與發布](https://air.build/tw/docs/cli/asc-release/#review)中的 `review`）。然後照常提交版本。**App 審查** 標籤頁上的 **提交審查** 會送出正在準備的提交項目，因此挑戰會隨版本一起送出。請參閱[提交 App 審查並發布](https://air.build/tw/docs/app-store/submit-for-review/#submit-a-version)。

如果這是遊戲第一次帶有 Game Center 的更新，該版本也需要開啟 Game Center：請參閱[加入 Game Center 排行榜和成就](https://air.build/tw/docs/app-store/add-game-center-leaderboards/#ship-them)。關於挑戰何時需要隨版本提交、何時可以單獨送審，請參閱 Apple 的[提交 Game Center 元件](https://developer.apple.com/help/app-store-connect/manage-submissions-to-app-review/submit-game-center-components)。

提交後，**App 審查** 標籤頁上該提交項目的 **已提交的項目** 會列出隨版本一起送出的內容。

## 查看進度

例如可以問：

```text
Is the "Beat my score" challenge live yet?
```

Agent 會用 `asc game-center challenges versions list` 讀取挑戰的版本。每個版本都有來自 App Store Connect 的狀態，例如 `WAITING_FOR_REVIEW`、`ACCEPTED` 或 `LIVE`。

`asc game-center challenges releases` 的說明表示，release 用於將挑戰版本發佈上線。它沒有說明何時需要這一步。如果 Apple 已接受某個挑戰但它仍未上線，請 Agent 查一查。

## 變更或停用挑戰

說明要變更什麼。Agent 會使用：

| 目的 | 指令 |
| --- | --- |
| 變更名稱或描述 | `asc game-center challenges localizations update` |
| 變更圖片 | `asc game-center challenges images`（`upload`、`delete`） |
| 改用另一個排行榜，或變更是否可重複 | `asc game-center challenges update` |
| 暫時封存 | `asc game-center challenges update --archived true`；`--archived false` 可以將它恢復 |
| 刪除 | `asc game-center challenges delete` |

刪除挑戰、挑戰的某個語言或某張圖片都需要 `--confirm`，所以 Agent 會先問你。`asc` 沒有恢復已刪除挑戰的指令，所以如果之後可能還要用，請改為封存。

關於修改後的挑戰何時需要再次送交 App 審查，請參閱 Apple 的[管理挑戰](https://developer.apple.com/help/app-store-connect/configure-game-center/manage-challenges)。

## 常見問題

**遊戲需要為挑戰撰寫新的程式碼嗎？**

Apple 的 GameKit 文章說明，遊戲回報到挑戰所用排行榜的分數會計入挑戰。如果想讓玩家在遊戲內發起挑戰，請 Agent 加入這項功能。

**Agent 說這個 App 沒有 Game Center 詳細資訊。**

當 App 在 App Store Connect 中還沒有設定 Game Center 時，`asc` 會顯示「Warning: no Game Center detail exists for this app.」（警告：此 App 沒有 Game Center 詳細資訊。），例如在 Agent 查詢它的排行榜時。請 Agent 先設定 Game Center：請參閱[加入 Game Center 排行榜和成就](https://air.build/tw/docs/app-store/add-game-center-leaderboards/)。

**可以不讓舊版本的玩家參加挑戰嗎？**

Apple 的說明介紹了在網頁版 App Store Connect 中為挑戰設定最低遊戲版本的方法。`asc` 沒有對應的指令。請參閱 Apple 的[管理挑戰](https://developer.apple.com/help/app-store-connect/configure-game-center/manage-challenges)。

**我的兩款遊戲可以共用一個挑戰嗎？**

可以，前提是它們透過群組共享 Game Center。請參閱[在你的多款遊戲之間共用排行榜和成就](https://air.build/tw/docs/app-store/share-game-center-between-your-games/)。

**可以在推出前試玩挑戰嗎？**

和排行榜一樣，在登入 Game Center 的狀態下玩 TestFlight 建置。請參閱[加入 Game Center 排行榜和成就](https://air.build/tw/docs/app-store/add-game-center-leaderboards/#try-them-before-release)；測試期間你的 Game Center 好友能看到什麼，請參閱 Apple 的[測試 Game Center 概覽](https://developer.apple.com/help/app-store-connect/configure-game-center/overview-of-testing-game-center)。
