Fix recasting related errors.

This commit is contained in:
Tipx-L 2023-08-22 02:17:49 -07:00
parent 07c9bc831b
commit 0fd3a38939
4 changed files with 39 additions and 25 deletions

View File

@ -501,6 +501,7 @@ game.import('card',function(lib,game,ui,get,ai,_status){
} }
if(cardsToGain.length) player.gain(cardsToGain,'draw'); if(cardsToGain.length) player.gain(cardsToGain,'draw');
if(cards.length-cardsToGain.length) player.draw(cards.length-cardsToGain.length).log=false; if(cards.length-cardsToGain.length) player.draw(cards.length-cardsToGain.length).log=false;
return cardsToGain;
}); });
}, },
ai:{ ai:{

View File

@ -117,7 +117,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
target.useCard(result.targets,card,event.links); target.useCard(result.targets,card,event.links);
} }
else{ else{
target.recast(event.links,(player,cards)=>game.cardsDiscard(cards)); target.recast(event.links,(player,cards)=>game.cardsDiscard(cards).cards);
} }
'step 4' 'step 4'
for(var card of cards){ for(var card of cards){

View File

@ -580,14 +580,12 @@ game.import('character',function(lib,game,ui,get,ai,_status){
player.logSkill('dcjini'); player.logSkill('dcjini');
player.addTempSkill('dcjini_counted'); player.addTempSkill('dcjini_counted');
player.addMark('dcjini_counted',cards.length,false); player.addMark('dcjini_counted',cards.length,false);
player.recast(cards); event.recast=player.recast(cards);
} }
else event.finish(); else event.finish();
'step 2' 'step 2'
if(trigger.source&&trigger.source.isIn()&&Array.isArray(result)){ if(trigger.source&&trigger.source.isIn()&&player.hasHistory('gain',evt=>evt.getParent(2)==event.recast&&evt.cards.some(value=>get.name(value)=='sha'))){
for(var i of result){ player.chooseToUse(function(card){
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; if(get.name(card)!='sha') return false;
return lib.filter.filterCard.apply(this,arguments); return lib.filter.filterCard.apply(this,arguments);
},'击逆:是否对'+get.translation(trigger.source)+'使用一张不可被响应的杀?').set('complexSelect',true).set('filterTarget',function(card,player,target){ },'击逆:是否对'+get.translation(trigger.source)+'使用一张不可被响应的杀?').set('complexSelect',true).set('filterTarget',function(card,player,target){
@ -596,9 +594,6 @@ game.import('character',function(lib,game,ui,get,ai,_status){
}).set('sourcex',trigger.source).set('oncard',()=>{ }).set('sourcex',trigger.source).set('oncard',()=>{
_status.event.directHit.addArray(game.players); _status.event.directHit.addArray(game.players);
}); });
break;
}
}
} }
}, },
subSkill:{ subSkill:{

View File

@ -10705,11 +10705,20 @@
recast:()=>{ recast:()=>{
'step 0' 'step 0'
game.log(player,'重铸了',cards); 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' 'step 1'
event.trigger('recast'); event.trigger('recast');
'step 2' '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(){ disableEquip:function(){
@ -18264,7 +18273,7 @@
if(get.itemtype(cards)=='card') recast.cards=[cards]; if(get.itemtype(cards)=='card') recast.cards=[cards];
else if(get.itemtype(cards)=='cards'&&cards.length) recast.cards=cards; else if(get.itemtype(cards)=='cards'&&cards.length) recast.cards=cards;
else _status.event.next.remove(recast); 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; recast.recastingLose=recastingLose;
if(typeof recastingGain!='function') recastingGain=(player,cards)=>player.draw(cards.length).log=false; if(typeof recastingGain!='function') recastingGain=(player,cards)=>player.draw(cards.length).log=false;
recast.recastingGain=recastingGain; recast.recastingGain=recastingGain;
@ -29944,12 +29953,16 @@
delay:false, delay:false,
content:function(){ content:function(){
player.recast(cards,null,(player,cards)=>{ player.recast(cards,null,(player,cards)=>{
let numberOfCardsToDraw=cards.length; var numberOfCardsToDraw=cards.length, cardsToGain=[];
cards.forEach(value=>{ cards.forEach(value=>{
if(lib.config.mode=='stone'&&_status.mode=='deck'&&!player.isMin()&&get.type(value).indexOf('stone')==0){ if(lib.config.mode=='stone'&&_status.mode=='deck'&&!player.isMin()&&get.type(value).indexOf('stone')==0){
var stonecard=get.stonecard(1,player.career); var stonecard=get.stonecard(1,player.career);
numberOfCardsToDraw--; if(stonecard.length){
if(stonecard.length) player.gain(game.createCard(stonecard.randomGet()),'draw'); numberOfCardsToDraw-=stonecard.length;
var card=game.createCard(stonecard.randomGet());
player.gain(card,'draw');
cardsToGain.push(card);
}
else player.draw({ else player.draw({
drawDeck:1 drawDeck:1
}).log=false; }).log=false;
@ -29958,16 +29971,21 @@
var libCard=get.libCard(info=>info.subtype=='spell_silver'); var libCard=get.libCard(info=>info.subtype=='spell_silver');
if(!libCard.length) return; if(!libCard.length) return;
numberOfCardsToDraw--; 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'){ else if(get.subtype(value)=='spell_silver'){
var libCard=get.libCard(info=>info.subtype=='spell_bronze'); var libCard=get.libCard(info=>info.subtype=='spell_bronze');
if(!libCard.length) return; if(!libCard.length) return;
numberOfCardsToDraw--; 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; if(numberOfCardsToDraw) player.draw(numberOfCardsToDraw).log=false;
return cardsToGain;
}); });
}, },
ai:{ ai:{