From 0fd3a389399b499ac25212f86cf5aadfc39ea821 Mon Sep 17 00:00:00 2001 From: Tipx-L <138244655+Tipx-L@users.noreply.github.com> Date: Tue, 22 Aug 2023 02:17:49 -0700 Subject: [PATCH] Fix recasting related errors. --- card/mtg.js | 1 + character/ddd.js | 2 +- character/huicui.js | 27 +++++++++++---------------- game/game.js | 34 ++++++++++++++++++++++++++-------- 4 files changed, 39 insertions(+), 25 deletions(-) diff --git a/card/mtg.js b/card/mtg.js index 96c4f01a0..03aa6b308 100644 --- a/card/mtg.js +++ b/card/mtg.js @@ -501,6 +501,7 @@ game.import('card',function(lib,game,ui,get,ai,_status){ } if(cardsToGain.length) player.gain(cardsToGain,'draw'); if(cards.length-cardsToGain.length) player.draw(cards.length-cardsToGain.length).log=false; + return cardsToGain; }); }, ai:{ diff --git a/character/ddd.js b/character/ddd.js index 75637ccb1..d48918391 100644 --- a/character/ddd.js +++ b/character/ddd.js @@ -117,7 +117,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ target.useCard(result.targets,card,event.links); } else{ - target.recast(event.links,(player,cards)=>game.cardsDiscard(cards)); + target.recast(event.links,(player,cards)=>game.cardsDiscard(cards).cards); } 'step 4' for(var card of cards){ diff --git a/character/huicui.js b/character/huicui.js index db80db52f..a743e2b53 100644 --- a/character/huicui.js +++ b/character/huicui.js @@ -580,25 +580,20 @@ game.import('character',function(lib,game,ui,get,ai,_status){ player.logSkill('dcjini'); player.addTempSkill('dcjini_counted'); player.addMark('dcjini_counted',cards.length,false); - player.recast(cards); + event.recast=player.recast(cards); } else event.finish(); 'step 2' - if(trigger.source&&trigger.source.isIn()&&Array.isArray(result)){ - for(var i of result){ - if(get.name(i,player)=='sha'&&get.owner(i)==player&&get.position(i)=='h'){ - player.chooseToUse(function(card,player,event){ - if(get.name(card)!='sha') return false; - return lib.filter.filterCard.apply(this,arguments); - },'击逆:是否对'+get.translation(trigger.source)+'使用一张不可被响应的杀?').set('complexSelect',true).set('filterTarget',function(card,player,target){ - if(target!=_status.event.sourcex&&!ui.selected.targets.contains(_status.event.sourcex)) return false; - return lib.filter.targetEnabled.apply(this,arguments); - }).set('sourcex',trigger.source).set('oncard',()=>{ - _status.event.directHit.addArray(game.players); - }); - break; - } - } + if(trigger.source&&trigger.source.isIn()&&player.hasHistory('gain',evt=>evt.getParent(2)==event.recast&&evt.cards.some(value=>get.name(value)=='sha'))){ + player.chooseToUse(function(card){ + if(get.name(card)!='sha') return false; + return lib.filter.filterCard.apply(this,arguments); + },'击逆:是否对'+get.translation(trigger.source)+'使用一张不可被响应的杀?').set('complexSelect',true).set('filterTarget',function(card,player,target){ + if(target!=_status.event.sourcex&&!ui.selected.targets.contains(_status.event.sourcex)) return false; + return lib.filter.targetEnabled.apply(this,arguments); + }).set('sourcex',trigger.source).set('oncard',()=>{ + _status.event.directHit.addArray(game.players); + }); } }, subSkill:{ diff --git a/game/game.js b/game/game.js index bb76b2281..ec40dac61 100644 --- a/game/game.js +++ b/game/game.js @@ -10705,11 +10705,20 @@ recast:()=>{ 'step 0' game.log(player,'重铸了',cards); - if(typeof event.recastingLose=='function') event.recastingLose(player,cards); + if(typeof event.recastingLose=='function') event.recastingLoseCards=event.recastingLose(player,cards); 'step 1' event.trigger('recast'); 'step 2' - if(typeof event.recastingGain=='function') event.recastingGain(player,cards); + if(typeof event.recastingGain!='function') return; + event.recastingGainCards=event.recastingGain(player,cards); + if(get.itemtype(event.recastingGainCards)=='card') event.recastingGainCards=[event.recastingGainCards]; + 'step 3' + event.result=[]; + if(get.itemtype(event.recastingGainCards)=='cards') event.result.addArray(event.recastingGainCards); + if(get.itemtype(result.cards)=='card') event.result.push(result.cards); + else if(get.itemtype(result.cards)=='cards') event.result.addArray(result.cards); + if(get.itemtype(result)=='card') event.result.push(result); + else if(get.itemtype(result)=='cards') event.result.addArray(result); }, //装备栏相关 disableEquip:function(){ @@ -18264,7 +18273,7 @@ if(get.itemtype(cards)=='card') recast.cards=[cards]; else if(get.itemtype(cards)=='cards'&&cards.length) recast.cards=cards; else _status.event.next.remove(recast); - if(typeof recastingLose!='function') recastingLose=(player,cards)=>player.loseToDiscardpile(cards).log=false; + if(typeof recastingLose!='function') recastingLose=(player,cards)=>player.loseToDiscardpile(cards).set("log",false).cards; recast.recastingLose=recastingLose; if(typeof recastingGain!='function') recastingGain=(player,cards)=>player.draw(cards.length).log=false; recast.recastingGain=recastingGain; @@ -29944,12 +29953,16 @@ delay:false, content:function(){ player.recast(cards,null,(player,cards)=>{ - let numberOfCardsToDraw=cards.length; + var numberOfCardsToDraw=cards.length, cardsToGain=[]; cards.forEach(value=>{ if(lib.config.mode=='stone'&&_status.mode=='deck'&&!player.isMin()&&get.type(value).indexOf('stone')==0){ var stonecard=get.stonecard(1,player.career); - numberOfCardsToDraw--; - if(stonecard.length) player.gain(game.createCard(stonecard.randomGet()),'draw'); + if(stonecard.length){ + numberOfCardsToDraw-=stonecard.length; + var card=game.createCard(stonecard.randomGet()); + player.gain(card,'draw'); + cardsToGain.push(card); + } else player.draw({ drawDeck:1 }).log=false; @@ -29958,16 +29971,21 @@ var libCard=get.libCard(info=>info.subtype=='spell_silver'); if(!libCard.length) return; numberOfCardsToDraw--; - player.gain(game.createCard(libCard.randomGet()),'draw'); + var card=game.createCard(libCard.randomGet()); + player.gain(card,'draw'); + cardsToGain.push(card); } else if(get.subtype(value)=='spell_silver'){ var libCard=get.libCard(info=>info.subtype=='spell_bronze'); if(!libCard.length) return; numberOfCardsToDraw--; - player.gain(game.createCard(libCard.randomGet()),'draw'); + var card=game.createCard(libCard.randomGet()); + player.gain(card,'draw'); + cardsToGain.push(card); } }); if(numberOfCardsToDraw) player.draw(numberOfCardsToDraw).log=false; + return cardsToGain; }); }, ai:{