Recast.
This commit is contained in:
parent
04d35b5e90
commit
8516c7299c
|
@ -499,9 +499,10 @@ game.import('card',function(lib,game,ui,get,ai,_status){
|
||||||
var card=get.cardPile(card=>get.type(card,'trick')=='trick');
|
var card=get.cardPile(card=>get.type(card,'trick')=='trick');
|
||||||
if(card) cardsToGain.push(card);
|
if(card) cardsToGain.push(card);
|
||||||
}
|
}
|
||||||
if(cardsToGain.length) player.gain(cardsToGain,'draw');
|
var recastingGainingEvents=[];
|
||||||
if(cards.length-cardsToGain.length) player.draw(cards.length-cardsToGain.length).log=false;
|
if(cardsToGain.length) recastingGainingEvents.push(player.gain(cardsToGain,'draw'));
|
||||||
return cardsToGain;
|
if(cards.length-cardsToGain.length) recastingGainingEvents.push(player.draw(cards.length-cardsToGain.length).set('log',false));
|
||||||
|
return recastingGainingEvents;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
ai:{
|
ai:{
|
||||||
|
|
|
@ -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).cards);
|
target.recast(event.links,(player,cards)=>game.cardsDiscard(cards));
|
||||||
}
|
}
|
||||||
'step 4'
|
'step 4'
|
||||||
for(var card of cards){
|
for(var card of cards){
|
||||||
|
|
|
@ -8470,22 +8470,12 @@ game.import('character',function(lib,game,ui,get,ai,_status){
|
||||||
'step 1'
|
'step 1'
|
||||||
if(result.bool&&result.cards.length){
|
if(result.bool&&result.cards.length){
|
||||||
target.recast(result.cards,null,(player,cards)=>{
|
target.recast(result.cards,null,(player,cards)=>{
|
||||||
var type=get.type(result.cards[0],'trick');
|
var type=get.type(cards[0],'trick'),name=cards[0].name,card2=get.cardPile(card=>get.type(card,'trick')==type&&card.name!=name);
|
||||||
var name=result.cards[0].name;
|
if(!card2) card2=get.cardPile(card=>get.type(card,'trick')==type);
|
||||||
var card2=get.cardPile(function(card){
|
var recastingGainingEvents=[];
|
||||||
return get.type(card,'trick')==type&&card.name!=name;
|
if(card2) recastingGainingEvents.push(player.gain(card2,'draw'));
|
||||||
});
|
else recastingGainingEvents.push(player.draw().set('log',false));
|
||||||
if(!card2){
|
return recastingGainingEvents;
|
||||||
card2=get.cardPile(function(card){
|
|
||||||
return get.type(card,'trick')==type;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if(card2){
|
|
||||||
target.gain(card2,'draw');
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
target.draw().log=false;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
var clone=game.createCard(card);
|
var clone=game.createCard(card);
|
||||||
player.gain(clone,'gain2');
|
player.gain(clone,'gain2');
|
||||||
|
|
|
@ -3736,7 +3736,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
|
||||||
target.chooseCard('he',true,'铸币:请重铸一张牌',lib.filter.cardRecastable);
|
target.chooseCard('he',true,'铸币:请重铸一张牌',lib.filter.cardRecastable);
|
||||||
'step 1'
|
'step 1'
|
||||||
if(result.bool){
|
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:{
|
ai:{
|
||||||
|
|
53
game/game.js
53
game/game.js
|
@ -10716,20 +10716,23 @@
|
||||||
recast:()=>{
|
recast:()=>{
|
||||||
'step 0'
|
'step 0'
|
||||||
game.log(player,'重铸了',cards);
|
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'
|
'step 1'
|
||||||
event.trigger('recast');
|
event.trigger('recast');
|
||||||
'step 2'
|
'step 2'
|
||||||
if(typeof event.recastingGain!='function') return;
|
if(typeof event.recastingGain!='function') return;
|
||||||
event.recastingGainedCards=event.recastingGain(player,cards);
|
event.trigger('recastingGain');
|
||||||
if(get.itemtype(event.recastingGainedCards)=='card') event.recastingGainedCards=[event.recastingGainedCards];
|
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'
|
'step 3'
|
||||||
event.result=[];
|
event.result=event.recastingGainingEvents.reduce((previousValue,currentValue)=>Array.isArray(currentValue.cards)?previousValue.addArray(currentValue.cards):previousValue,[]);
|
||||||
if(get.itemtype(event.recastingGainedCards)=='cards') event.result.addArray(event.recastingGainedCards);
|
if(Array.isArray(result.cards)) event.result.addArray(result.cards);
|
||||||
if(get.itemtype(result.cards)=='card') event.result.push(result.cards);
|
if(Array.isArray(result)) event.result.addArray(result);
|
||||||
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(){
|
||||||
|
@ -10958,7 +10961,7 @@
|
||||||
next.player=player;
|
next.player=player;
|
||||||
next.card=card;
|
next.card=card;
|
||||||
}
|
}
|
||||||
if(info.equipDelay!='false') game.delayx();
|
if(info.equipDelay!=false) game.delayx();
|
||||||
}
|
}
|
||||||
delete player.equiping;
|
delete player.equiping;
|
||||||
if(event.delay){
|
if(event.delay){
|
||||||
|
@ -18284,13 +18287,16 @@
|
||||||
recast:function(cards,recastingLose,recastingGain){
|
recast:function(cards,recastingLose,recastingGain){
|
||||||
const recast=game.createEvent('recast');
|
const recast=game.createEvent('recast');
|
||||||
recast.player=this;
|
recast.player=this;
|
||||||
if(get.itemtype(cards)=='card') recast.cards=[cards];
|
const isArray=Array.isArray(cards);
|
||||||
else if(get.itemtype(cards)=='cards'&&cards.length) recast.cards=cards;
|
if(cards&&!isArray) recast.cards=[cards];
|
||||||
|
else if(isArray&&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).set("log",false).cards;
|
if(typeof recastingLose!='function') recastingLose=(player,cards)=>player.loseToDiscardpile(cards).set("log",false);
|
||||||
recast.recastingLose=recastingLose;
|
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.recastingGain=recastingGain;
|
||||||
|
recast.recastingGainingEvents=[];
|
||||||
recast.setContent('recast');
|
recast.setContent('recast');
|
||||||
recast._args=Array.from(arguments);
|
recast._args=Array.from(arguments);
|
||||||
return recast;
|
return recast;
|
||||||
|
@ -30035,39 +30041,36 @@
|
||||||
delay:false,
|
delay:false,
|
||||||
content:function(){
|
content:function(){
|
||||||
player.recast(cards,null,(player,cards)=>{
|
player.recast(cards,null,(player,cards)=>{
|
||||||
var numberOfCardsToDraw=cards.length, cardsToGain=[];
|
var numberOfCardsToDraw=cards.length,recastingGainingEvents=[];
|
||||||
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);
|
||||||
if(stonecard.length){
|
if(stonecard.length){
|
||||||
numberOfCardsToDraw-=stonecard.length;
|
numberOfCardsToDraw-=stonecard.length;
|
||||||
var card=game.createCard(stonecard.randomGet());
|
var card=game.createCard(stonecard.randomGet());
|
||||||
player.gain(card,'draw');
|
recastingGainingEvents.push(player.gain(card,'draw'));
|
||||||
cardsToGain.push(card);
|
|
||||||
}
|
}
|
||||||
else player.draw({
|
else recastingGainingEvents.push(player.draw({
|
||||||
drawDeck:1
|
drawDeck:1
|
||||||
}).log=false;
|
}).set('log',false));
|
||||||
}
|
}
|
||||||
else if(get.subtype(value)=='spell_gold'){
|
else if(get.subtype(value)=='spell_gold'){
|
||||||
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--;
|
||||||
var card=game.createCard(libCard.randomGet());
|
var card=game.createCard(libCard.randomGet());
|
||||||
player.gain(card,'draw');
|
recastingGainingEvents.push(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--;
|
||||||
var card=game.createCard(libCard.randomGet());
|
var card=game.createCard(libCard.randomGet());
|
||||||
player.gain(card,'draw');
|
recastingGainingEvents.push(player.gain(card,'draw'));
|
||||||
cardsToGain.push(card);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if(numberOfCardsToDraw) player.draw(numberOfCardsToDraw).log=false;
|
if(numberOfCardsToDraw) recastingGainingEvents.push(player.draw(numberOfCardsToDraw).set('log',false));
|
||||||
return cardsToGain;
|
return recastingGainingEvents;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
ai:{
|
ai:{
|
||||||
|
|
Loading…
Reference in New Issue