From 18516597bf7581892bc128c92d6c93aa65a2c8dd Mon Sep 17 00:00:00 2001 From: Rintim Date: Tue, 26 Sep 2023 23:56:20 +0800 Subject: [PATCH 1/5] fix end-comma error in compatible version. --- game/game.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/game/game.js b/game/game.js index 303eef490..20cc77bbd 100644 --- a/game/game.js +++ b/game/game.js @@ -305,7 +305,7 @@ cs.of( cs.class("card","fullskin",`${nature}`), '>', - cs.class("name"), + cs.class("name") ) ); let result={}; From 6aa4e18982eac41d1e787ea46641fbc9c0e6aac7 Mon Sep 17 00:00:00 2001 From: Rintim Date: Tue, 26 Sep 2023 23:58:05 +0800 Subject: [PATCH 2/5] unite arguments length between prototype function and its hook. --- game/game.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/game/game.js b/game/game.js index 20cc77bbd..a4fb56f47 100644 --- a/game/game.js +++ b/game/game.js @@ -266,7 +266,7 @@ }); }], //增加新属性杀 - addNature:[(nature,config)=>{ + addNature:[(nature,_translation,config)=>{ if(typeof config!='object') config={}; let linked=config.linked,order=config.order,background=config.background,lineColor=config.lineColor; if(typeof linked!='boolean') linked=true; @@ -33429,7 +33429,7 @@ lib.onload.add(()=>{ for(const hook of lib.hooks.addNature){ if(hook!=null&&typeof hook=="function"){ - hook(nature,config); + hook(nature,translation,config); } } }) From 08de74b1abfb855ed3a254d526dcfbea42bd4197 Mon Sep 17 00:00:00 2001 From: Rintim Date: Wed, 27 Sep 2023 00:05:16 +0800 Subject: [PATCH 3/5] detach hook-calling to make prototype function able to run anytime. --- game/game.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/game/game.js b/game/game.js index a4fb56f47..a445202bd 100644 --- a/game/game.js +++ b/game/game.js @@ -33426,13 +33426,15 @@ addNature:(nature,translation,config)=>{ if(!nature) throw new TypeError(); if(translation&&translation.length) lib.translate['nature_'+nature]=translation; - lib.onload.add(()=>{ + var hookCall=()=>{ for(const hook of lib.hooks.addNature){ if(hook!=null&&typeof hook=="function"){ hook(nature,translation,config); } } - }) + }; + if ("onload" in lib) lib.onload.add(hookCall); + else hookCall(); return nature; }, //设置卡牌信息/事件的属性 @@ -33500,13 +33502,15 @@ lib.group.add(id); if(short)lib.translate[id] = short; if(name)lib.translate[`${id}2`] = name; - lib.onload.add(()=>{ + var hookCall=()=>{ for(const hook of lib.hooks.addGroup){ if(hook!=null&&typeof hook=="function"){ hook(id,short,name,config); } } - }) + }; + if ("onload" in lib) lib.onload.add(hookCall); + else hookCall(); return id; }, //Yingbian From 33b8e4b4dc6008b33c9b24ce2dea3d8a2a16d099 Mon Sep 17 00:00:00 2001 From: Rintim Date: Wed, 27 Sep 2023 00:23:02 +0800 Subject: [PATCH 4/5] detach hook-call to game. --- game/game.js | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/game/game.js b/game/game.js index a445202bd..4a127f76a 100644 --- a/game/game.js +++ b/game/game.js @@ -33426,15 +33426,7 @@ addNature:(nature,translation,config)=>{ if(!nature) throw new TypeError(); if(translation&&translation.length) lib.translate['nature_'+nature]=translation; - var hookCall=()=>{ - for(const hook of lib.hooks.addNature){ - if(hook!=null&&typeof hook=="function"){ - hook(nature,translation,config); - } - } - }; - if ("onload" in lib) lib.onload.add(hookCall); - else hookCall(); + game.callHook("addNature",[nature,translation,config]); return nature; }, //设置卡牌信息/事件的属性 @@ -33509,10 +33501,21 @@ } } }; - if ("onload" in lib) lib.onload.add(hookCall); - else hookCall(); + game.callHook("addGroup",[id,short,name,config]); return id; }, + //通用的调用钩子函数 + callHook:(name,args)=>{ + const callHook=()=>{ + for(const hook of lib.hooks[name]){ + if(hook!=null&&typeof hook=="function"){ + hook(...args); + } + } + } + if ("onload" in lib) lib.onload.add(callHook); + else callHook(); + }, //Yingbian //应变 yingbianEffect:function(event,content){ From e1af98e1660cd4d9a89dfcfa4c352ada0ee812be Mon Sep 17 00:00:00 2001 From: Rintim Date: Wed, 27 Sep 2023 00:32:58 +0800 Subject: [PATCH 5/5] remove unneed function. --- game/game.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/game/game.js b/game/game.js index 4a127f76a..dab78d16b 100644 --- a/game/game.js +++ b/game/game.js @@ -33494,13 +33494,6 @@ lib.group.add(id); if(short)lib.translate[id] = short; if(name)lib.translate[`${id}2`] = name; - var hookCall=()=>{ - for(const hook of lib.hooks.addGroup){ - if(hook!=null&&typeof hook=="function"){ - hook(id,short,name,config); - } - } - }; game.callHook("addGroup",[id,short,name,config]); return id; },