From feb150bc3fe3cb6ecbc512dd59861427dd341e79 Mon Sep 17 00:00:00 2001 From: kuangshen04 <2832899707@qq.com> Date: Thu, 30 Nov 2023 19:36:53 +0800 Subject: [PATCH 1/5] =?UTF-8?q?trigger=E5=A4=A7=E6=94=B9=EF=BC=88=E5=8D=B1?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- character/gujian.js | 2 +- character/hearth.js | 2 +- character/xianjian.js | 2 +- game/game.js | 992 +++++++++++++++--------------------------- 4 files changed, 351 insertions(+), 647 deletions(-) diff --git a/character/gujian.js b/character/gujian.js index 55264de28..311284c64 100644 --- a/character/gujian.js +++ b/character/gujian.js @@ -803,7 +803,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ silent:true, content:function(){ player.exitSubPlayer(true); - game.createTrigger('phaseAfter','lianjing',player,trigger); + if(lib.filter.filterTrigger(trigger,player,'phaseAfter','lianjing')) game.createTrigger('phaseAfter','lianjing',player,trigger); } } }, diff --git a/character/hearth.js b/character/hearth.js index 9c6db8dc4..442b1ca0e 100644 --- a/character/hearth.js +++ b/character/hearth.js @@ -8203,7 +8203,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ hs:get.cards(4) }); player.callSubPlayer(player.storage.huanfeng_end); - // game.createTrigger('phaseBegin','shengdun',player,trigger); + // if(lib.filter.filterTrigger(trigger,player,'phaseBegin','shengdun')) game.createTrigger('phaseBegin','shengdun',player,trigger); }, // group:'huanfeng_end', subSkill:{ diff --git a/character/xianjian.js b/character/xianjian.js index 29824d23c..b3d6a1a44 100644 --- a/character/xianjian.js +++ b/character/xianjian.js @@ -100,7 +100,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ player.draw(3); player.addSkill('shuiyun'); 'step 1' - game.createTrigger('phaseEnd','shuiyun',player,trigger); + if(lib.filter.filterTrigger(trigger,player,'phaseEnd','shuiyun')) game.createTrigger('phaseEnd','shuiyun',player,trigger); }, }, shenwu:{ diff --git a/game/game.js b/game/game.js index 50e90faae..283f97cbd 100644 --- a/game/game.js +++ b/game/game.js @@ -181,7 +181,7 @@ new Promise(resolve=>{ extensions:[], extensionPack:{}, cardType:{}, - hook:{globaltrigger:{},globalskill:{}}, + hook:{globalskill:{}}, //函数钩子 hooks:{ // 本体势力的颜色 @@ -417,7 +417,7 @@ new Promise(resolve=>{ // TODO: handle the error. reject(new Error()); break; - case "receiving": + case "receiving":{ /** * @type {PromiseResolve} */ @@ -427,6 +427,7 @@ new Promise(resolve=>{ this.status = "active"; resolve(); break ; + } case "active": this.status = "sending"; this._buffer = [value, resolve]; @@ -447,7 +448,7 @@ new Promise(resolve=>{ // TODO: handle the error. reject(new Error()); break; - case "sending": + case "sending":{ /** * @type {[T, PromiseResolve]} */ @@ -457,6 +458,7 @@ new Promise(resolve=>{ this.status = "active"; buffer[1](); break ; + } case "active": this.status = "receiving"; this._buffer = resolve; @@ -14780,270 +14782,139 @@ new Promise(resolve=>{ }, arrangeTrigger:function(){ 'step 0' - event.filter1=function(info){ - if(info[1].isDead()&&!lib.skill[info[0]].forceDie) return false; - if(info[1].isOut()&&!lib.skill[info[0]].forceOut) return false; - return lib.filter.filterTrigger(trigger,info[1],event.triggername,info[0]); - } - event.filter2=function(info2){ - var info=lib.skill[info2[0]]; - if(!lib.translate[info2[0]]||info.silent) return false; - return true; - } - event.filter3=function(info,info2){ - return event.filter2(info2)&&event.filter1(info2)&&info2[1]==info[1]&&info[2]==info2[2]&&(lib.skill.global.contains(info2[0])||info[1].hasSkill(info2[0],true)); - } + event.noDirectUse=info=>!lib.skill[info.skill].silent&&lib.translate[info.skill];//是否触发同顺序选择 'step 1' - if(trigger.filterStop&&trigger.filterStop()){ - event.finish(); - } - else if(event.list.length){ - var info=event.list.shift(); - game.createTrigger(event.triggername,info[0],info[1],trigger); - event.redo(); - } + if(!event.doingList.length) return event.finish(); + event.doing=event.doingList.shift(); + // console.log(event.triggername,event.doing,event.doingList) 'step 2' - if(!event.map.length){ - if(event.list2.length){ - var info=event.list2.shift(); - game.createTrigger(event.triggername,info[0],info[1],trigger); - event.redo(); - } - else{ - if(trigger._triggering==this){ - delete trigger._triggering; - } - event.finish(); - return; - } - } - event.doing=event.map.shift(); + if(trigger.filterStop&&trigger.filterStop()) return event.finish(); + const current=event.doing.todoList.find(info=>lib.filter.filterTrigger(trigger,info.player,event.triggername,info.skill)); + if(!current) return event.goto(1); + event.doing.todoList=event.doing.todoList.filter(i=>i.priority<=current.priority); + event.num=event.doing.todoList.indexOf(current); + if(!event.noDirectUse(current)) return event.goto(5); + event.choice=event.doing.todoList.filter(info=>{ + if(!lib.filter.filterTrigger(trigger,info.player,event.triggername,info.skill)) return false; + if(!event.noDirectUse(info)) return false; + if(current.skill!=info.skill) return false; + if(current.player!=info.player) return false; + return lib.skill.global.includes(info.skill)||current.player.hasSkill(info.skill,true); + }); + if(event.choice.length<2) event.goto(5); 'step 3' - event.num=0; - var bool=false; - var list=event.doing.list; - for(var i=0;ipriority){ - event.doing.list.splice(i--,1); - event.num--; - } - } - event.choice=[]; - if(event.numi.skill)); + next.set('prompt','选择下一个触发的技能'); + next.set('forceDie',true); + next.set('arrangeSkill',true); + next.set('includeOut',true); 'step 4' - var controls=[]; - event.current=event.choice[0][1] - for(var i=0;iinfo.skill==result.control&&info.player==event.choice[0].player); 'step 5' - if(result.control){ - for(var i=0;i