scense/skill/SKILL.md
2026-08-29 17:38:48 +08:00

2.6 KiB
Raw Permalink Blame History

name description
scense 元景 W-08 游戏展示模块——游戏会话/结果管理 + bricks 前端游戏页(全屏渲染+交互)。开发/修改 scense 相关功能前必读。

scense 模块W-08 游戏展示)

数据表

作用 关键字段
game_session 游戏会话 status(created/playing/paused/ended), score, level, elapsed_ms, progress_json, share_token
game_result 游戏结果 session_id, score, duration_ms, level, result_json

会话状态机(会话级)

  • 开始玩无会话→playing已有 playing/paused→恢复 playing续玩
  • playing ⇄ pausedpause/resume
  • playing/paused → endedend 唯一结算出口,写 game_result
  • 任意状态 → playingrestart 重置分数/关卡)
  • save 保存进度快照(不改变状态)

API 端点wwwroot/game/api/*.dspy全部 logined

文件 功能 对应功能点
game_list.dspy 游戏列表 + 历史会话 W-08a
game_start.dspy 开始玩(进入运行态) W-08b
game_pause.dspy 暂停 W-08c
game_resume.dspy 继续 W-08d
game_end.dspy 结束结算(写 game_result W-08e/f/g
game_restart.dspy 重新开始(重置) W-08f
game_share.dspy 生成/解析分享链接 W-08h
game_save.dspy 保存进度快照 W-08j

前端

  • game/index.ui — bricks 游戏列表入口页
  • game/game_play.html — 全屏游戏页canvas + HUD + 结算面板 + 交互),验收入口
  • game/game.js — 游戏交互(开始/暂停/继续/结束/重开/分享/保存/点选实体)
  • game/game_list.js — 列表页渲染

依赖

  • W-10 runtimeruntime.js RuntimeEngine前端运行态 + /runtime/api/load_world.dspy
  • world 模块(游戏世界来源,防御式降级独立模式)
  • sqlor/ahserver/ServerEnv

陷阱

  1. dspy 禁 import/print/uuid/f-string显式 returntry/except 包裹;返回值必须 json.dumps。
  2. 取库名 get_module_dbname('scense').dspy 全局)或 ServerEnv().get_module_dbname('scense').py禁硬编码 DBNAME。
  3. 状态非法流转返回 400ValueError → code 400不得 500。
  4. sor.C 必须显式 created_at/updated_atsor.U 同理更新 updated_at。
  5. game_play.html 独立 HTML 可用 fetch/setIntervalbricks script actiontype 禁 fetch——列表交互放 game_list.js。
  6. RBAC 禁通配符逐条显式scripts/load_path.py
  7. ID 生成用 getID()appPublic.uniqueID禁 uuid.uuid4。
  8. game_play.html 引用 runtime.js 用绝对路径 /runtime/runtime.jsruntime 模块 any 权限自动服务)。