diff --git a/character/xianding.js b/character/xianding.js index abc580710..34b236a8e 100644 --- a/character/xianding.js +++ b/character/xianding.js @@ -128,6 +128,59 @@ game.import('character',function(lib,game,ui,get,ai,_status){ var source=player.storage.dcpandi_effect; return get.itemtype(source)!='player'||!source.isIn(); }, + pandi_wrapKey:function(){ + var str = ""; + for(var arg of arguments){ + if(arg === null || arg === undefined){ + str += (arg + "-"); + continue; + } + switch(get.itemtype(arg)){ + case 'player': + str+=("p:"+arg.playerid); + break; + case 'card': + if(arg.cardid){ + str+=("c:"+arg.cardid); + }else{ + str+=("c:"+arg.name); + } + break; + default: + str+=("n:"+arg); + break; + } + str+="-"; + } + return str; + }, + pandi_effect:function(target,card,player,viewer){ + if(!_status.event)return get.effect(target,card,player,viewer); + var key = lib.skill.dcpandi.pandi_wrapKey.apply(null,arguments); + var effect = _status.event.getTempCache('effect',key); + if(effect !== undefined)return effect; + effect = get.effect(target,card,player,viewer); + _status.event.putTempCache('effect',key,effect); + return effect; + }, + pandi_canUse:function(player,card,target,arg1,arg2){ + if(!_status.event)return player.canUse(card,target,arg1,arg2); + var key = lib.skill.dcpandi.pandi_wrapKey.apply(null,arguments); + var effect = _status.event.getTempCache('canUse',key); + if(effect !== undefined)return effect; + effect = player.canUse(card,target,arg1,arg2); + _status.event.putTempCache('canUse',key,effect); + return effect; + }, + pandi_effect_use:function(target,card,player,viewer){ + if(!_status.event)return get.effect_use(target,card,player,viewer); + var key = lib.skill.dcpandi.pandi_wrapKey.apply(null,arguments); + var effect = _status.event.getTempCache('effect_use',key); + if(effect !== undefined)return effect; + effect = get.effect_use(target,card,player,viewer); + _status.event.putTempCache('effect_use',key,effect); + return effect; + }, onChooseToUse:function(event){ if(!game.online&&event.type=='phase'){ var players=game.filterPlayer(function(current){ @@ -162,15 +215,32 @@ game.import('character',function(lib,game,ui,get,ai,_status){ if(typeof(card)=='string'){ card={name:card,isCard:true}; } + var key = lib.skill.dcpandi.pandi_wrapKey(card,player,viewer); + if(_status.event){ + var uv = _status.event.getTempCache('getUseValue',key); + if(uv!==undefined){ + return uv; + } + } var targets=game.filterPlayer(); var value=[]; var min=0; var info=get.info(card); - if(!info||info.notarget) return 0; + if(!info||info.notarget){ + if(_status.event){ + _status.event.putTempCache('getUseValue',key,0); + } + return 0; + } var range; var select=get.copy(info.selectTarget); if(select==undefined){ - if(info.filterTarget==undefined) return true; + if(info.filterTarget==undefined) { + if(_status.event){ + _status.event.putTempCache('getUseValue',key,true); + } + return true; + } range=[1,1]; } else if(typeof select=='number') range=[select,select]; @@ -178,11 +248,16 @@ game.import('character',function(lib,game,ui,get,ai,_status){ else if(typeof select=='function') range=select(card,player); if(info.singleCard) range=[1,1]; game.checkMod(card,player,range,'selectTarget',player); - if(!range) return 0; + if(!range){ + if(_status.event){ + _status.event.putTempCache('getUseValue',key,0); + } + return 0; + } for(var i=0;i