你的下一项功能
玩家数值
由服务器管理的货币、计数和能量。为每个项目定义余额、优惠和经过校验的变更。
Godot

可见的结果
游戏会显示已配置的余额和优惠。购买操作会返回玩家的当前状态。
此步骤尚无视频。指南和MCP请求已可使用。
玩家数值
准备同一个项目
在仪表盘中选择与游戏配置相同的项目。
玩家数值 →在控制台表单中创建或复用这些测试条目。这些是示例值,并非项目当前数据。
- 数值
coins: initialBalance=100, maxBalance=1000000; energy: initialBalance=10, maxBalance=100- 允许直接变更
false- 优惠
energy-pack: costs=[{"key":"coins","amount":20}], rewards=[{"key":"energy","amount":5}]
每个数值键仅发放一次初始余额。直接变更默认关闭。Validated Actions 保留每局限制;每日及余额上限来自这些定义。可选上限留空表示不限。
运行示例前先保存、重新加载并核对条目。保留其他定义。
实现此功能
你可以预览指南。运行需要有效的项目密钥。 准备项目
已安装 SDK、导入项目配置,且玩家已登录。
此 SDK 示例使用 develop。请检查已安装的 SDK 是否具备所需 API。
先通过快速入门连接目标玩家,再通过明确的按钮或场景操作调用run_reviewed_action()。仅打开文件不会发送请求。
GDScript
1extends Node
2
3# Existing configured SDK and authenticated player session required.
4# Invoke run_reviewed_action explicitly after reviewing this example.
5func run_reviewed_action() -> void:
6 if not Horizon.auth.isSignedIn():
7 return
8 var user_id: String = Horizon.auth.getCurrentUser().userId
9 var current: Dictionary = await Horizon.playerValues.getState(user_id)
10 if not current.success:
11 push_error(current.errorCode)
12 return
13 print(current.state.values)
14 # Authoritative balances only; never add a copied historical reward locally.
15 # Purchases and exact original retry use the official player_values_example.gd
16 # and pending_purchase.gd. Persist the original user/offer/operationId before send.
17 # Keep an uncertain or expired original; do not silently create another ID.
测试你的新功能。
游戏会显示已配置的余额和优惠。购买操作会返回玩家的当前状态。
在仪表盘中选择与游戏配置相同的项目。
接口
- GET
/player-values - GET
/player-values/offers - POST
/player-values/purchase - POST
/player-values/adjust


