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

2.3 KiB
Raw Blame History

scense 游戏展示模块(元景 W-08

功能

游戏列表入口 / 点击开始玩(初始化 W-10 世界运行态进入)/ 暂停 / 继续 / 结束结算 / 重新开始 / 分数结果展示 / 分享链接进入 / 玩中交互(点选移动实体触发脚本逻辑)/ 退出保存进度。

数据表

作用 关键字段
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/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前端运行态服务端辅助可选
  • world 模块(游戏世界来源,防御式降级独立模式)
  • sqlor / ahserver / ServerEnv

集成

  1. app/sage.py: from scense.init import load_scense + load_scense() in init()
  2. build.sh 安装循环添加 scense
  3. scripts/load_path.py 注册 RBAC 路径(禁通配符)
  4. global_menu.ui 添加菜单项 {{entire_url('/scense/game/index.ui')}}
  5. 部署目标 /d/scense/scense_app:模块 wwwroot 软链接 + pip install -e