From 244c541aa635b4ced1f40e23b4de678b1ab6239b Mon Sep 17 00:00:00 2001 From: shijian <2954700422@qq.com> Date: Sat, 9 Dec 2023 13:39:52 +0800 Subject: [PATCH] =?UTF-8?q?=E9=92=88=E5=AF=B9game.delay=E6=B7=BB=E5=8A=A0g?= =?UTF-8?q?ame.asyncDelay=E5=92=8Cgame.asyncDelayx=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- character/standard.js | 2 +- game/game.js | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/character/standard.js b/character/standard.js index 11a20de7c..6f345a764 100755 --- a/character/standard.js +++ b/character/standard.js @@ -371,7 +371,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ trigger.player.judging[0]=chooseCardResultCards[0]; trigger.orderingCards.addArray(chooseCardResultCards); game.log(trigger.player,'的判定牌改为',chooseCardResultCards[0]); - game.delay(2); + await game.asyncDelay(2); }, ai:{ rejudge:true, diff --git a/game/game.js b/game/game.js index 818105c53..c40142075 100644 --- a/game/game.js +++ b/game/game.js @@ -41664,6 +41664,39 @@ new Promise(resolve=>{ } return game.delay(time,time2); }, + /** + * 在async content中对game.delay的代替使用方法 + * + * 因为async content里不应该使用game.pause和game.resume + */ + asyncDelay:function(time,time2){ + // if(_status.paused) return; + // game.pause(); + if(typeof time!='number') time=1; + if(typeof time2!='number') time2=0; + time=time*lib.config.duration+time2; + if(lib.config.speed=='vvfast') time/=3; + //_status.timeout=setTimeout(game.resume,time); + return new Promise(resolve=>{ + setTimeout(resolve,time); + }); + }, + /** + * 在async content中对game.delayx的代替使用方法 + * + * 因为async content里不应该使用game.pause和game.resume + */ + asyncDelayx:function(time,time2){ + if(typeof time!='number') time=1; + switch(lib.config.game_speed){ + case 'vslow':time*=2.5;break; + case 'slow':time*=1.5;break; + case 'fast':time*=0.7;break; + case 'vfast':time*=0.4;break; + case 'vvfast':time*=0.2;break; + } + return game.asyncDelay(time,time2); + }, check:function(event){ var i,j,range; if(event==undefined) event=_status.event;