From b22558d0b3237de069a3c0589f560b5f0da5821e Mon Sep 17 00:00:00 2001 From: Joywayer Date: Wed, 26 Aug 2026 21:51:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=8C=E4=B8=83=E7=8E=8B=EF=BC=9A=E5=89=8D?= =?UTF-8?q?=E7=AB=AF=E6=8E=A5=E5=85=A5=E9=AA=A8=E6=9E=B6=E4=B8=8E=20index.?= =?UTF-8?q?html=20=E5=8A=A0=E8=BD=BD=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SubGameHooks 从模板复制、本阶段保持空骨架(无 hook 时转发壳走平台默认)。 index.html 按 client 06 §3 的顺序加入 codes 段:config → shared → core → ui → SubGameHooks → 三文件转发壳,三个转发壳一字未动。 Node vm 依序加载验证无异常,全部 EQW_* 与 SubGameHooks 就绪;两端测试全绿。 Co-Authored-By: Claude Opus 5 (1M context) --- client/index.html | 31 +++ client/js/01_SubGame/codes/SubGameHooks.js | 219 +++++++++++++++++++++ 2 files changed, 250 insertions(+) create mode 100644 client/js/01_SubGame/codes/SubGameHooks.js diff --git a/client/index.html b/client/index.html index 5c4814b..c7c9747 100644 --- a/client/index.html +++ b/client/index.html @@ -208,6 +208,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/client/js/01_SubGame/codes/SubGameHooks.js b/client/js/01_SubGame/codes/SubGameHooks.js new file mode 100644 index 0000000..d038f57 --- /dev/null +++ b/client/js/01_SubGame/codes/SubGameHooks.js @@ -0,0 +1,219 @@ +// ============================================================================ +// SubGameHooks.js —— 二七王子游戏接入入口(实现骨架,本阶段空函数,B/F 阶段逐个填充) +// 平台契约文件(00/01/02 转发壳)会把同名平台接口转发到这里。只需实现【本游戏需要的】hook, +// 未实现的接口由转发壳走空操作(A)/平台默认返回值(B)/模板默认 UI 渲染(D)。严格 ES5。 +// 接口清单与默认值见 spec §9 / 文档 06。 +// ============================================================================ + +var SubGameHooks = window.SubGameHooks || {}; + +// ===== gameHallImport.*(大厅,9) ===== + +// [A] hallAppStart():大厅应用启动(注:与 Game_Modify.appStart 同名冲突,故加 hall 前缀区分)。 +// SubGameHooks.hallAppStart = function () { /* ... */ }; + +// [A] jumpMenuScene():大厅跳转菜单场景。 +// SubGameHooks.jumpMenuScene = function () { /* ... */ }; + +// [A] gameStart():大厅游戏开始入口。 +// SubGameHooks.gameStart = function () { /* ... */ }; + +// [A] setGameList():设置游戏列表。 +// SubGameHooks.setGameList = function () { /* ... */ }; + +// [A] clearGameinfo():清除游戏信息。 +// SubGameHooks.clearGameinfo = function () { /* ... */ }; + +// [A] getWebdata(data):获取网络数据回调。 +// SubGameHooks.getWebdata = function (data) { /* ... */ }; + +// [B] isInstalled(data):检查是否已安装;无 hook 时默认:return 1。 +// SubGameHooks.isInstalled = function (data) { /* ... */ }; + +// [A] up_imgurl(recid, photo):更新图片 URL。 +// SubGameHooks.up_imgurl = function (recid, photo) { /* ... */ }; + +// [A] getphoto(recid, photo):获取玩家头像。 +// SubGameHooks.getphoto = function (recid, photo) { /* ... */ }; + +// ===== Game_Modify.*(事件/交互,来自 01,9) ===== + +// [A] utlmousedown(gameid, spid, downx, downy, no1, no2, no3, no4, no5, no6):精灵按下事件;子游戏转发到 SpriteEventController。 +// SubGameHooks.utlmousedown = function (gameid, spid, downx, downy, no1, no2, no3, no4, no5, no6) { /* ... */ }; + +// [A] utlmousedown_nomove(gameid, spid, downx, downy, timelong, no1, no2, no3, no4, no5):精灵按下(无移动)事件。 +// SubGameHooks.utlmousedown_nomove = function (gameid, spid, downx, downy, timelong, no1, no2, no3, no4, no5) { /* ... */ }; + +// [A] mouseup(gameid, spid_down, downx, downy, spid_up, upx, upy, timelong, no1, no2):精灵抬起事件。 +// SubGameHooks.mouseup = function (gameid, spid_down, downx, downy, spid_up, upx, upy, timelong, no1, no2) { /* ... */ }; + +// [A] utlmousemove(gameid, spid, downx, downy, movex, movey, timelong, offmovex, offmovey, no1):精灵移动事件。 +// SubGameHooks.utlmousemove = function (gameid, spid, downx, downy, movex, movey, timelong, offmovex, offmovey, no1) { /* ... */ }; + +// [A] utlgamemydrawbegin(gameid, spid, times, timelong, no2, no3, no4, no5, no6, no7):精灵绘制开始事件。 +// SubGameHooks.utlgamemydrawbegin = function (gameid, spid, times, timelong, no2, no3, no4, no5, no6, no7) { /* ... */ }; + +// [A] gamemydraw(gameid, spid, times, timelong, no2, no3, no4, no5, no6, no7):精灵绘制帧事件。 +// SubGameHooks.gamemydraw = function (gameid, spid, times, timelong, no2, no3, no4, no5, no6, no7) { /* ... */ }; + +// [A] OpenCreateRoom():打开创建房间界面。 +// SubGameHooks.OpenCreateRoom = function () { /* ... */ }; + +// [A] CloseCreateRoom():关闭创建房间界面。 +// SubGameHooks.CloseCreateRoom = function () { /* ... */ }; + +// [A] setRoomDes(roomcode, asetcount, roomtype):设置房间描述文案。 +// SubGameHooks.setRoomDes = function (roomcode, asetcount, roomtype) { /* ... */ }; + +// ===== Game_Modify.*(生命周期/回调,来自 02,45) ===== + +// [A] appStart():游戏应用启动(与 gameHallImport.appStart 语义不同,对应 Game_Modify 侧启动)。 +// SubGameHooks.appStart = function () { /* ... */ }; + +// [A] StartWar(_msg):开战(开局)回调,解包开局数据并初始化游戏状态。 +// SubGameHooks.StartWar = function (_msg) { /* ... */ }; + +// [A] _ReceiveData(_msg):接收服务端主动推送的数据包,派发给对应业务处理器。 +// SubGameHooks._ReceiveData = function (_msg) { /* ... */ }; + +// [A] createRoom(_roomtype, _infinite):前端发起创建房间请求。 +// SubGameHooks.createRoom = function (_roomtype, _infinite) { /* ... */ }; + +// [A] myJoinRoom(_msg):自己成功进入房间回调。 +// SubGameHooks.myJoinRoom = function (_msg) { /* ... */ }; + +// [A] Reconnect(_deskinfo):重连回调,用服务端返回的桌面信息恢复游戏界面。 +// SubGameHooks.Reconnect = function (_deskinfo) { /* ... */ }; + +// [A] stopAllSounds():停止所有声音(切换到后台时触发)。 +// SubGameHooks.stopAllSounds = function () { /* ... */ }; + +// [A] Free(_msg):投票解散确认回调。 +// SubGameHooks.Free = function (_msg) { /* ... */ }; + +// [A] DeskInfo(_msg):未开战状态下加入牌桌的数据同步。 +// SubGameHooks.DeskInfo = function (_msg) { /* ... */ }; + +// [A] breakRoom():开局后自己退出房间触发。 +// SubGameHooks.breakRoom = function () { /* ... */ }; + +// [A] playerJoinRoom(seat):其他玩家加入房间通知。 +// SubGameHooks.playerJoinRoom = function (seat) { /* ... */ }; + +// [A] playerLeaveRoom(seat):其他玩家离开房间通知。 +// SubGameHooks.playerLeaveRoom = function (seat) { /* ... */ }; + +// [A] updateScene():更新游戏界面(分辨率变化等)。 +// SubGameHooks.updateScene = function () { /* ... */ }; + +// [A] closeGameScene():关闭游戏界面。 +// SubGameHooks.closeGameScene = function () { /* ... */ }; + +// [A] playerOffline(seat):玩家掉线通知。 +// SubGameHooks.playerOffline = function (seat) { /* ... */ }; + +// [A] playerOnline(seat):玩家上线通知。 +// SubGameHooks.playerOnline = function (seat) { /* ... */ }; + +// [A] playerphonestate(seat, type):玩家电话状态变化通知。 +// SubGameHooks.playerphonestate = function (seat, type) { /* ... */ }; + +// [A] shakeEvent():设备摇一摇事件。 +// SubGameHooks.shakeEvent = function () { /* ... */ }; + +// [A] calResult(inputArr):计算结算结果。 +// SubGameHooks.calResult = function (inputArr) { /* ... */ }; + +// [A] onEnterMainScene(roomtype):进入游戏主场景。 +// SubGameHooks.onEnterMainScene = function (roomtype) { /* ... */ }; + +// [A] onExitMainScene():退出游戏主场景。 +// SubGameHooks.onExitMainScene = function () { /* ... */ }; + +// [A] onGameConfig(_gameConfig):获取游戏配置时触发。 +// SubGameHooks.onGameConfig = function (_gameConfig) { /* ... */ }; + +// [A] onEnterVideo():进入牌局回放模式。 +// SubGameHooks.onEnterVideo = function () { /* ... */ }; + +// [A] onSurrender(_msg):收到投降回包。 +// SubGameHooks.onSurrender = function (_msg) { /* ... */ }; + +// [A] onReady(seat):玩家准备触发。 +// SubGameHooks.onReady = function (seat) { /* ... */ }; + +// [B] getRoomInfo(roomtype, type, tea):获取房间描述文案;无 hook 时默认:"房间描述" + roomtype。 +// SubGameHooks.getRoomInfo = function (roomtype, type, tea) { /* ... */ }; + +// [B] getStarLimit(roomtype):获取星星场下限分数;无 hook 时默认:return 2001000。 +// SubGameHooks.getStarLimit = function (roomtype) { /* ... */ }; + +// [B] getMult(roomtype, type):获取星星场倍数;无 hook 时默认:return 10000。 +// SubGameHooks.getMult = function (roomtype, type) { /* ... */ }; + +// [B] getFullRoomInfo(roomtype):获取房间完整信息描述;无 hook 时默认:"房间描述" + roomtype。 +// SubGameHooks.getFullRoomInfo = function (roomtype) { /* ... */ }; + +// [A] onOpenHelp(spid):打开帮助页面。 +// SubGameHooks.onOpenHelp = function (spid) { /* ... */ }; + +// [A] onMainMenuScene():显示大厅主菜单界面。 +// SubGameHooks.onMainMenuScene = function () { /* ... */ }; + +// [A] onCheckInput(_result):数字输入框确认回调。 +// SubGameHooks.onCheckInput = function (_result) { /* ... */ }; + +// [A] onCreateRoom(_data):创建房间成功后触发。 +// SubGameHooks.onCreateRoom = function (_data) { /* ... */ }; + +// [B] getLeaveLimit(roomtype):获取离场限制局数;无 hook 时默认:return 10。 +// SubGameHooks.getLeaveLimit = function (roomtype) { /* ... */ }; + +// [A] onLocationInfo(_locationInfo):成功获取定位信息回调。 +// SubGameHooks.onLocationInfo = function (_locationInfo) { /* ... */ }; + +// [A] onCreateDesk(roomtype):进入游戏界面创建牌桌之前触发。 +// SubGameHooks.onCreateDesk = function (roomtype) { /* ... */ }; + +// [B] getVideoByRoomType(roomtype):获取该房型是否开启视频功能;无 hook 时默认:return 1。 +// SubGameHooks.getVideoByRoomType = function (roomtype) { /* ... */ }; + +// [B] getRoomTopDescAry(roomtype):获取房间顶部描述文案数组;无 hook 时默认:["" + roomtype]。 +// SubGameHooks.getRoomTopDescAry = function (roomtype) { /* ... */ }; + +// [A] getShareRoom(_msg):星星场房间列表数据。 +// SubGameHooks.getShareRoom = function (_msg) { /* ... */ }; + +// [A] myExitRoom(seat):玩家自己退出房间。 +// SubGameHooks.myExitRoom = function (seat) { /* ... */ }; + +// [A] changeSeat(seat1, seat2):接收到换座包触发。 +// SubGameHooks.changeSeat = function (seat1, seat2) { /* ... */ }; + +// [A] onCloseVip():关闭 VIP 选项时调用。 +// SubGameHooks.onCloseVip = function () { /* ... */ }; + +// [B] getRoomMode(roomtype):判断房间模式(0=非金币场);无 hook 时默认:return 0。 +// SubGameHooks.getRoomMode = function (roomtype) { /* ... */ }; + +// [B] getMaxPlayerCount(roomtype):获取房间最大玩家数量;无 hook 时默认:return Game_Config.Max.PlayerCnt || 4。 +// SubGameHooks.getMaxPlayerCount = function (roomtype) { /* ... */ }; + +// [D] updatePlayerInfoUI(targetSeat):更新指定座位玩家信息 UI;无 hook 时模板提供【可变人数】默认渲染 +// (头像/昵称/分数随人数 2/3/4 贴合各玩家,布局见 01 的 Game_Modify.PLAYER_INFO_LAYOUT)。子游戏可用 hook 完全接管。 +// SubGameHooks.updatePlayerInfoUI = function (targetSeat) { /* ... */ }; + +// ===== Game_Modify.*(桌面聊天/语音气泡,3) ===== +// 以下接口无 hook 时,模板提供【可变人数】默认渲染(气泡随人数贴合各玩家,布局见 01 的 Game_Modify.BUBBLE_LAYOUT)。 + +// [D] ShowChat(seat, text):显示桌面文字聊天气泡(seat 为绝对座位)。 +// SubGameHooks.ShowChat = function (seat, text) { /* ... */ }; + +// [D] gameui_play_voice(uiIndex):播放桌面语音气泡(uiIndex 为相对显示位序)。 +// SubGameHooks.gameui_play_voice = function (uiIndex) { /* ... */ }; + +// [D] gameui_stop_voice(uiIndex):停止桌面语音气泡。 +// SubGameHooks.gameui_stop_voice = function (uiIndex) { /* ... */ }; + +window.SubGameHooks = SubGameHooks; +if (typeof module !== 'undefined' && module.exports) { module.exports = SubGameHooks; }