diff --git a/game/game.js b/game/game.js index daae23dd8..8ec119e4e 100644 --- a/game/game.js +++ b/game/game.js @@ -14816,7 +14816,8 @@ } event.trigger('phaseDiscard'); "step 1" - player.chooseToDiscard(num,true); + player.chooseToDiscard(num,true) + .set('useCache',true); "step 2" event.cards=result.cards; }, @@ -22594,6 +22595,20 @@ } return skills; }, + getModableSkills:function(useCache){ + var func = function(player){ + var skills=player.getSkills().concat(lib.skill.global); + game.expandSkills(skills); + skills = skills.filter(function(skill){ + var info = get.info(skill); + return info && info.mod; + }); + skills.sort((a,b)=>get.priority(a)-get.priority(b)); + return skills; + }; + if(!useCache)return func(this); + return game.callFuncUseStepCache("player.getModableSkills",func,[this]); + }, getSkills:function(arg2,arg3,arg4){ var skills=this.skills.slice(0); var es=[]; @@ -26213,12 +26228,14 @@ }, addInvisibleSkill:function(skill){ if(Array.isArray(skill)){ + _status.event.clearStepCache(); for(var i=0;i{ - const info=get.info(skill); - return (info&&info.mod&&info.mod[name]); - }) - skills.sort((a,b)=>get.priority(a)-get.priority(b)); + if(skills.getSkills) skills=skills.getModableSkills(_status.event.useCache === true); const arg=argumentArray.slice(0,-2); skills.forEach(value=>{ - const result=get.info(value).mod[name].apply(this,arg); + var mod = get.info(value).mod[name]; + if(!mod)return; + const result=mod.apply(this,arg); if(typeof arg[arg.length-1]!='object'&&result!=undefined) arg[arg.length-1]=result; }); return arg[arg.length-1]; @@ -56031,6 +56090,27 @@ } return str; }, + //用于将参数转换为字符串,作为缓存的key。 + paramToCacheKey:function(){ + var str = ""; + for(var arg of arguments){ + if(arg === null || arg === undefined){ + str += (arg + "-"); + continue; + } + if(arg.playerid){ + str += "p:"+arg.playerid; + }else if(arg.cardid){ + str += "c:"+arg.cardid; + }else if(arg.name){ + str += "n:"+arg.name; + }else{ + str += "s:"+arg; + } + str+="-"; + } + return str; + }, yunjiao:function(str){ const util=window.pinyinUtilx; if(util) str=util.removeTone(str) @@ -59954,7 +60034,7 @@ sgnAttitude:function(){ return get.sgn(get.attitude.apply(this,arguments)); }, - useful:function(card,player){ + useful_raw:function(card,player){ if(get.position(card)=='j') return -1; if(get.position(card)=='e') return get.equipValue(card); if(card._modUseful){ @@ -59963,7 +60043,13 @@ var i=0; if(!player) player=_status.event.player; if(player){ - i=player.getCards('h',card.name).indexOf(card); + if(_status.event.useCache){ + i = game.callFuncUseStepCache("player.getCardsInUseful",function(player,position,cardname){ + return player.getCards(position,cardname); + },[player,'h',card.name]).indexOf(card); + }else{ + i=player.getCards('h',card.name).indexOf(card); + } if(i<0) i=0; } var aii=get.info(card).ai; @@ -59983,6 +60069,12 @@ result=game.checkMod(player,card,result,'aiUseful',player); return result; }, + useful:function(card,player){ + if(_status.event.useCache){ + return game.callFuncUseStepCache("get.useful_raw",get.useful_raw,[card,player]); + } + return get.useful_raw(card,player); + }, unuseful:function(card){ return -get.useful(card); },