diff --git a/card/mtg.js b/card/mtg.js index 03aa6b308..6aef3e3e5 100644 --- a/card/mtg.js +++ b/card/mtg.js @@ -499,9 +499,10 @@ game.import('card',function(lib,game,ui,get,ai,_status){ var card=get.cardPile(card=>get.type(card,'trick')=='trick'); if(card) cardsToGain.push(card); } - if(cardsToGain.length) player.gain(cardsToGain,'draw'); - if(cards.length-cardsToGain.length) player.draw(cards.length-cardsToGain.length).log=false; - return cardsToGain; + var recastingGainingEvents=[]; + if(cardsToGain.length) recastingGainingEvents.push(player.gain(cardsToGain,'draw')); + if(cards.length-cardsToGain.length) recastingGainingEvents.push(player.draw(cards.length-cardsToGain.length).set('log',false)); + return recastingGainingEvents; }); }, ai:{ diff --git a/character/ddd.js b/character/ddd.js index d48918391..75637ccb1 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).cards); + target.recast(event.links,(player,cards)=>game.cardsDiscard(cards)); } 'step 4' for(var card of cards){ diff --git a/character/hearth.js b/character/hearth.js index dc6a64cac..129002bfc 100644 --- a/character/hearth.js +++ b/character/hearth.js @@ -8470,22 +8470,12 @@ game.import('character',function(lib,game,ui,get,ai,_status){ 'step 1' if(result.bool&&result.cards.length){ target.recast(result.cards,null,(player,cards)=>{ - var type=get.type(result.cards[0],'trick'); - var name=result.cards[0].name; - var card2=get.cardPile(function(card){ - return get.type(card,'trick')==type&&card.name!=name; - }); - if(!card2){ - card2=get.cardPile(function(card){ - return get.type(card,'trick')==type; - }); - } - if(card2){ - target.gain(card2,'draw'); - } - else{ - target.draw().log=false; - } + var type=get.type(cards[0],'trick'),name=cards[0].name,card2=get.cardPile(card=>get.type(card,'trick')==type&&card.name!=name); + if(!card2) card2=get.cardPile(card=>get.type(card,'trick')==type); + var recastingGainingEvents=[]; + if(card2) recastingGainingEvents.push(player.gain(card2,'draw')); + else recastingGainingEvents.push(player.draw().set('log',false)); + return recastingGainingEvents; }); var clone=game.createCard(card); player.gain(clone,'gain2'); diff --git a/character/sp.js b/character/sp.js index 3528712c7..feb31fda6 100755 --- a/character/sp.js +++ b/character/sp.js @@ -3736,7 +3736,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ target.chooseCard('he',true,'铸币:请重铸一张牌',lib.filter.cardRecastable); 'step 1' if(result.bool){ - target.recast(result.cards,null,player=>player.draw().set('log',false).gaintag=['olzhubi_tag']); + target.recast(result.cards,null,player=>player.draw().set('log',false).set('gaintag',['olzhubi_tag'])); } }, ai:{ diff --git a/game/game.js b/game/game.js index 3e546f348..c4b46ee2a 100644 --- a/game/game.js +++ b/game/game.js @@ -10716,20 +10716,23 @@ recast:()=>{ 'step 0' game.log(player,'重铸了',cards); - if(typeof event.recastingLose=='function') event.recastingLostCards=event.recastingLose(player,cards); + if(typeof event.recastingLose!='function') return; + event.trigger('recastingLose'); + var recastingLosingEvents=event.recastingLose(player,cards); + if(get.itemtype(recastingLosingEvents)=='event') event.recastingLosingEvents.push(event.recastingLosingEvents); + else if(Array.isArray(recastingLosingEvents)) event.recastingLosingEvents.push(...recastingLosingEvents); 'step 1' event.trigger('recast'); 'step 2' if(typeof event.recastingGain!='function') return; - event.recastingGainedCards=event.recastingGain(player,cards); - if(get.itemtype(event.recastingGainedCards)=='card') event.recastingGainedCards=[event.recastingGainedCards]; + event.trigger('recastingGain'); + var recastingGainingEvents=event.recastingGain(player,cards); + if(get.itemtype(recastingGainingEvents)=='event') event.recastingGainingEvents.push(event.recastingGainingEvents); + else if(Array.isArray(recastingGainingEvents)) event.recastingGainingEvents.push(...recastingGainingEvents); 'step 3' - event.result=[]; - if(get.itemtype(event.recastingGainedCards)=='cards') event.result.addArray(event.recastingGainedCards); - 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); + event.result=event.recastingGainingEvents.reduce((previousValue,currentValue)=>Array.isArray(currentValue.cards)?previousValue.addArray(currentValue.cards):previousValue,[]); + if(Array.isArray(result.cards)) event.result.addArray(result.cards); + if(Array.isArray(result)) event.result.addArray(result); }, //装备栏相关 disableEquip:function(){ @@ -10958,7 +10961,7 @@ next.player=player; next.card=card; } - if(info.equipDelay!='false') game.delayx(); + if(info.equipDelay!=false) game.delayx(); } delete player.equiping; if(event.delay){ @@ -18284,13 +18287,16 @@ recast:function(cards,recastingLose,recastingGain){ const recast=game.createEvent('recast'); recast.player=this; - if(get.itemtype(cards)=='card') recast.cards=[cards]; - else if(get.itemtype(cards)=='cards'&&cards.length) recast.cards=cards; + const isArray=Array.isArray(cards); + if(cards&&!isArray) recast.cards=[cards]; + else if(isArray&&cards.length) recast.cards=cards; else _status.event.next.remove(recast); - if(typeof recastingLose!='function') recastingLose=(player,cards)=>player.loseToDiscardpile(cards).set("log",false).cards; + if(typeof recastingLose!='function') recastingLose=(player,cards)=>player.loseToDiscardpile(cards).set("log",false); recast.recastingLose=recastingLose; - if(typeof recastingGain!='function') recastingGain=(player,cards)=>player.draw(cards.length).log=false; + recast.recastingLosingEvents=[]; + if(typeof recastingGain!='function') recastingGain=(player,cards)=>player.draw(cards.length).set("log",false); recast.recastingGain=recastingGain; + recast.recastingGainingEvents=[]; recast.setContent('recast'); recast._args=Array.from(arguments); return recast; @@ -30035,39 +30041,36 @@ delay:false, content:function(){ player.recast(cards,null,(player,cards)=>{ - var numberOfCardsToDraw=cards.length, cardsToGain=[]; + var numberOfCardsToDraw=cards.length,recastingGainingEvents=[]; 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); if(stonecard.length){ numberOfCardsToDraw-=stonecard.length; var card=game.createCard(stonecard.randomGet()); - player.gain(card,'draw'); - cardsToGain.push(card); + recastingGainingEvents.push(player.gain(card,'draw')); } - else player.draw({ + else recastingGainingEvents.push(player.draw({ drawDeck:1 - }).log=false; + }).set('log',false)); } else if(get.subtype(value)=='spell_gold'){ var libCard=get.libCard(info=>info.subtype=='spell_silver'); if(!libCard.length) return; numberOfCardsToDraw--; var card=game.createCard(libCard.randomGet()); - player.gain(card,'draw'); - cardsToGain.push(card); + recastingGainingEvents.push(player.gain(card,'draw')); } else if(get.subtype(value)=='spell_silver'){ var libCard=get.libCard(info=>info.subtype=='spell_bronze'); if(!libCard.length) return; numberOfCardsToDraw--; var card=game.createCard(libCard.randomGet()); - player.gain(card,'draw'); - cardsToGain.push(card); + recastingGainingEvents.push(player.gain(card,'draw')); } }); - if(numberOfCardsToDraw) player.draw(numberOfCardsToDraw).log=false; - return cardsToGain; + if(numberOfCardsToDraw) recastingGainingEvents.push(player.draw(numberOfCardsToDraw).set('log',false)); + return recastingGainingEvents; }); }, ai:{