bindbox-game/docs/matching_game_api_example.jsonc
邹方成 e2782a69d3 feat: 添加对对碰游戏功能与Redis支持
refactor: 重构抽奖逻辑以支持可验证凭据
feat(redis): 集成Redis客户端并添加配置支持
fix: 修复订单取消时的优惠券和库存处理逻辑
docs: 添加对对碰游戏前端对接指南和示例JSON
test: 添加对对碰游戏模拟测试和验证逻辑
2025-12-21 17:31:32 +08:00

106 lines
3.5 KiB
JSON
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
// 游戏唯一ID用于后续校验和记录查询
"game_id": "MG10011639882000",
// 初始棋盘状态9个格子
// null 表示该格子为空(理论上初始时不应有空,除非卡牌不够)
"initial_board": [
{
"id": "c1", // 卡牌唯一实例ID
"type": "A", // 卡牌类型代码(对应配置中的 Code
"name": "苹果", // 卡牌名称
"image_url": "apple.png" // 卡牌图片地址
},
{ "id": "c2", "type": "A", "name": "苹果", "image_url": "apple.png" },
{ "id": "c3", "type": "B", "name": "香蕉", "image_url": "banana.png" },
{ "id": "c4", "type": "B", "name": "香蕉", "image_url": "banana.png" },
{ "id": "c5", "type": "C", "name": "樱桃", "image_url": "cherry.png" },
{ "id": "c6", "type": "C", "name": "樱桃", "image_url": "cherry.png" },
{ "id": "c7", "type": "A", "name": "苹果", "image_url": "apple.png" },
{ "id": "c8", "type": "A", "name": "苹果", "image_url": "apple.png" },
{ "id": "c9", "type": "B", "name": "香蕉", "image_url": "banana.png" }
],
// 游戏完整时间轴,前端按顺序播放数组中的每一个 Round
"timeline": [
// --- 第 1 回合 ---
{
"round": 1, // 回合数
// 当前回合开始时的棋盘状态(主要用于校准,前端动画可基于此状态开始)
"board": [ ... ],
// 本回合消除的配对信息
"pairs": [
{
"card_type": "A", // 消除的卡牌类型
"count": 2, // 消除数量
"card_ids": ["c1", "c2"], // 被消除的卡牌ID
"slot_indices": [0, 1] // 被消除的棋盘格子索引 (0-8) -> 前端需播放这些位置的消除动画
}
],
"pairs_count": 1, // 本回合总消除对数
// 消除后,从牌堆抽卡填补空位的信息
"drawn_cards": [
{
"slot_index": 0, // 填补到哪个格子 (0-8)
"card": { // 填补的具体卡牌信息
"id": "c10",
"type": "B",
"name": "香蕉",
"image_url": "banana.png"
}
},
{
"slot_index": 1,
"card": {
"id": "c11",
"type": "C",
"name": "樱桃",
"image_url": "cherry.png"
}
}
],
"reshuffled": false, // 本回合是否触发了“死局重洗”。如果为 true前端需播放棋盘重洗动画所有卡牌重新排列
"can_continue": true // 游戏是否继续。如果为 false表示游戏结束
},
// --- 第 2 回合 ---
{
"round": 2,
"pairs": [
{
"card_type": "B",
"count": 4, // 一次消除了4张(2对)
"card_ids": ["c3", "c4", "c9", "c10"],
"slot_indices": [2, 3, 8, 0] // 这些位置的卡牌一起消失
}
],
"pairs_count": 2,
"drawn_cards": [ ... ], // 可能会填补4张新卡
"reshuffled": false,
"can_continue": true
},
// ... 中间省略若干回合 ...
// --- 最后回合 ---
{
"round": 5,
"pairs": [], // 没有可消除的了
"pairs_count": 0,
"drawn_cards": [],
"reshuffled": false,
"can_continue": false // 游戏结束
}
],
// 游戏总消除对数(最终得分)
"total_pairs": 8,
// 服务器种子哈希(用于公平性验证,可忽略)
"server_seed_hash": "a1b2c3d4..."
}