From fe0816187560b3496ef9662a14d986f788540fc7 Mon Sep 17 00:00:00 2001 From: kuangthree Date: Fri, 25 Aug 2023 22:40:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AD=99=E7=BF=8E=E9=B8=BEAI?= =?UTF-8?q?=EF=BC=8C=E6=96=B0=E5=A2=9E=E4=B8=B4=E6=97=B6=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E5=87=BD=E6=95=B0?= 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 30913db30..7933b5c9f 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