From 0c81724af6b7134dc309c5f00de823af21a1d47b Mon Sep 17 00:00:00 2001 From: kuangthree Date: Fri, 25 Aug 2023 22:01:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AD=99=E7=BF=8E=E9=B8=BEAI?= =?UTF-8?q?=E9=80=9F=E5=BA=A6=EF=BC=8C=E6=96=B0=E5=A2=9E=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E4=B8=AD=E7=BC=93=E5=AD=98=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- character/xianding.js | 90 ++++++++++++++++++++++++++++++++++++++++--- game/game.js | 19 +++++++++ 2 files changed, 103 insertions(+), 6 deletions(-) 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