From 310ad8506baba54561656e3c3a9895e2463de380 Mon Sep 17 00:00:00 2001 From: shijian <2954700422@qq.com> Date: Sun, 17 Dec 2023 20:13:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E5=BC=82=E6=AD=A5=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E7=9A=84debugger=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game/game.js | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/game/game.js b/game/game.js index bcc80ba4b..70f2ac600 100644 --- a/game/game.js +++ b/game/game.js @@ -32198,11 +32198,40 @@ new Promise(resolve=>{ return this.#event; } /** - * TODO: 实现debugger + * 在某个异步事件中调试变量信息 + * + * 注: 在调试步骤中`定义的变量只在当前输入的语句有效` + * + * @example + * 在技能中调试技能content相关的信息 + * ```js + * await event.debugger(); + * ``` + * 在技能中调试触发此技能事件的相关的信息 + * ```js + * await trigger.debugger(); + * ``` */ async debugger(){ return new Promise(resolve=>{ - resolve(null); + const runCode=function(event,code){ + try { + var {player,_trigger:trigger,_result:result}=event; + return eval(code); + }catch(error){ + return error; + } + }.bind(window); + const inputCallback=inputResult=>{ + if(inputResult===false){ + resolve(null); + }else{ + const obj=runCode(this.toEvent(),inputResult); + alert((!obj||obj instanceof Error)?String(obj):get.stringify(obj)); + game.promises.prompt('debugger调试').then(inputCallback); + } + } + game.promises.prompt('debugger调试').then(inputCallback); }); } },