# 为你的游戏添加 Game Center 挑战

> 让智能体把游戏的某个排行榜变成 Game Center 挑战，配上每种语言的名称、描述和图片，并送交 App 审核。

Source: https://air.build/cn/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 界面。你在项目的聊天中请智能体处理，它会使用 `asc game-center challenges`（列在 [asc：App 与 App Store 页面](https://air.build/cn/docs/cli/asc-apps/#game-center)的 `game-center` 下）。要查看结果，可以问智能体，或在 App Store Connect 中打开你的 App。

## 开始之前

游戏需要 Game Center 和至少一个排行榜：每个挑战都建立在一个排行榜之上。如果两者都还没有，请从[添加 Game Center 排行榜和成就](https://air.build/cn/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. 智能体找到排行榜，并用 `asc game-center challenges create` 创建挑战，带上参考名称、挑战 ID 和该排行榜。
2. 它用 `asc game-center challenges localizations create` 逐个语言添加玩家看到的内容：名称和描述。
3. 它用 `asc game-center challenges images upload` 以 PNG 格式上传图片，可以只用于一种语言，也可以作为所有语言的默认图片。
4. 它在聊天中告诉你创建了什么。随时想查看列表，可以问“游戏有哪些挑战？”。智能体会用 `asc game-center challenges list` 读取。

图片可以由智能体制作（参见[让智能体为你的 App 制作图片](https://air.build/cn/docs/build/make-pictures-for-your-app/)），也可以由你在聊天中发送自己的图片（参见[向智能体发送照片、文件和草图](https://air.build/cn/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 审核

请智能体把挑战放进你下一次的 App 审核提交中，例如：

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

智能体会用 `asc review items add` 添加它，该命令的帮助把挑战列为提交可以包含的项目之一（参见 [asc：审核与发布](https://air.build/cn/docs/cli/asc-release/#review)中的 `review`）。然后照常提交版本。**App 审核** 标签页上的 **提交审核** 会发送正在准备的提交，因此挑战会随版本一起送出。参见[提交 App 审核并发布](https://air.build/cn/docs/app-store/submit-for-review/#submit-a-version)。

如果这是游戏第一次带 Game Center 的更新，该版本也需要开启 Game Center：参见[添加 Game Center 排行榜和成就](https://air.build/cn/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?
```

智能体会用 `asc game-center challenges versions list` 读取挑战的版本。每个版本都有来自 App Store Connect 的状态，例如 `WAITING_FOR_REVIEW`、`ACCEPTED` 或 `LIVE`。

`asc game-center challenges releases` 的帮助说明，发布（release）用于把挑战版本发布上线。它没有说明何时需要这一步。如果 Apple 已接受某个挑战但它仍未上线，请智能体查一查。

## 更改或停用挑战

说明要更改什么。智能体会使用：

| 目的 | 命令 |
| --- | --- |
| 更改名称或描述 | `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`，所以智能体会先问你。`asc` 没有恢复已删除挑战的命令，所以如果你以后可能还要用，请改为归档。

关于修改后的挑战何时需要再次送交 App 审核，参见 Apple 的[管理挑战](https://developer.apple.com/help/app-store-connect/configure-game-center/manage-challenges)。

## 常见问题

**游戏需要为挑战编写新代码吗？**

Apple 的 GameKit 文章说明，游戏上报到挑战所用排行榜的分数会计入挑战。如果想让玩家在游戏内发起挑战，请让智能体添加这项功能。

**智能体说这个 App 没有 Game Center 详细信息。**

当 App 在 App Store Connect 中还没有设置 Game Center 时，`asc` 会显示“Warning: no Game Center detail exists for this app.”（警告：此 App 没有 Game Center 详细信息。），例如在智能体查找它的排行榜时。请智能体先设置 Game Center：参见[添加 Game Center 排行榜和成就](https://air.build/cn/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/cn/docs/app-store/share-game-center-between-your-games/)。

**可以在发布前试用挑战吗？**

和排行榜一样，在登录 Game Center 的状态下玩 TestFlight 构建。参见[添加 Game Center 排行榜和成就](https://air.build/cn/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)。
