From 08de74b1abfb855ed3a254d526dcfbea42bd4197 Mon Sep 17 00:00:00 2001 From: Rintim Date: Wed, 27 Sep 2023 00:05:16 +0800 Subject: [PATCH] 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