diff --git a/card/guozhan.js b/card/guozhan.js index 3171ef9e7..e043aa8cd 100644 --- a/card/guozhan.js +++ b/card/guozhan.js @@ -43,51 +43,58 @@ game.import('card',function(lib,game,ui,get,ai,_status){ fullskin:true, type:'trick', enable:true, - filterTarget:function(card,player,target){ + filterTarget(card,player,target){ return target!=player&&!target.isMinHp(); }, - content:function(){ - 'step 0' - event.list=game.filterPlayer(function(current){ + async content(event,trigger,player){ + const target=event.target; + if(!target.isIn()) return; + const str=get.translation(target); + const card=new lib.element.VCard({name:'sha'}); + const targets=game.filterPlayer(current=>{ return current!=target; }).sortBySeat(); - 'step 1' - if(!target.isIn()){ - event.finish(); - return; + for(const current of targets){ + if(!target.isIn()) return; + if(!current||!current.isIn()||current.hasSkill('diaohulishan')) continue; + let choiceList=[ + '弃置一张牌,视为对'+str+'使用一张【杀】', + '弃置'+str+'一张牌', + ],choices=['出杀','弃牌','cancel2']; + if(current.identity=='wei'){ + choiceList[0]=choiceList[0].slice(6); + choiceList[1]='获得'+choiceList[1].slice(2); + choices[1]='得牌'; + } + if(!current.canUse(card,target,false)||(current.identity!='wei'&&!current.countDiscardableCards(current,'he'))){ + choiceList[0]=''+choiceList[0]+''; + choices.remove('出杀'); + } + if(!target.countCards('he')){ + choiceList[1]=''+choiceList[1]+''; + choices.remove(current.identity=='wei'?'得牌':'弃牌'); + } + if(choices.length>1){ + const {result:{control}}=await current.chooseControl(choices) + .set('prompt','号令天下:请选择其中一项').set('target',target) + .set('ai',()=>{ + const player=get.event('player'),target=get.event('target'),choices=get.event('controls'); + const guohe=new lib.element.VCard({name:'guohe_copy2'}),shunshou=new lib.element.VCard({name:'shunshou_copy2'}),sha=new lib.element.VCard({name:'sha'}); + const num=Math.max(0,choices.includes('弃牌')?get.effect(target,guohe,player):0,choices.includes('得牌')?get.effect(target,shunshou,player):0); + if(choices.includes('出杀')&&get.effect(player,guohe,player)+get.effect(target,sha,player)>num) return '出杀'; + if(choices.includes('得牌')&&num>0) return '得牌'; + if(choices.includes('弃牌')&&num>0) return '弃牌'; + return 'cancel2'; + }); + if(control!='cancel2'){ + if(control=='出杀'){ + if(current.identity!='wei') await current.chooseToDiscard('he',true); + await current.useCard(card,target,false); + } + else await current[current.identity=='wei'?'gainPlayerCard':'discardPlayerCard'](target,true,'he').set('boolline',true); + } + } } - var current=event.list.shift(); - if(!current||!current.isIn()||current.hasSkill('diaohulishan')){ - if(event.list.length) event.redo(); - else event.finish(); - return; - } - event.current=current; - if(current.identity!='wei'){ - current.chooseToDiscard('he','弃置一张牌,并视为对'+get.translation(target)+'使用一张【杀】,或点击「取消」弃置其一张牌').set('ai',function(card){ - if(!_status.event.goon) return 0; - return 5-get.value(card); - }).set('goon',(get.effect(target,{name:'guohe'},current)