针对game.delay添加game.asyncDelay和game.asyncDelayx函数

This commit is contained in:
shijian 2023-12-09 13:39:52 +08:00
parent 5a73498601
commit 244c541aa6
2 changed files with 34 additions and 1 deletions

View File

@ -371,7 +371,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
trigger.player.judging[0]=chooseCardResultCards[0]; trigger.player.judging[0]=chooseCardResultCards[0];
trigger.orderingCards.addArray(chooseCardResultCards); trigger.orderingCards.addArray(chooseCardResultCards);
game.log(trigger.player,'的判定牌改为',chooseCardResultCards[0]); game.log(trigger.player,'的判定牌改为',chooseCardResultCards[0]);
game.delay(2); await game.asyncDelay(2);
}, },
ai:{ ai:{
rejudge:true, rejudge:true,

View File

@ -41664,6 +41664,39 @@ new Promise(resolve=>{
} }
return game.delay(time,time2); 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){ check:function(event){
var i,j,range; var i,j,range;
if(event==undefined) event=_status.event; if(event==undefined) event=_status.event;