💫 improve player.setTrapFromDeckTopAsyn (for WX17-044)

This commit is contained in:
WEBXOSS 2017-10-15 17:00:57 +08:00
parent d505f00545
commit 8f4ba4de63
2 changed files with 10 additions and 32 deletions

View file

@ -106888,19 +106888,7 @@ var CardInfo = {
source: this,
description: '2071-burst-2',
actionAsyn: function () {
var cards = this.player.mainDeck.getTopCards(2);
this.player.informCards(cards);
var done = false;
return Callback.loop(this,2,function () {
if (done) return;
return this.player.selectOptionalAsyn('TARGET',cards).callback(this,function (card) {
if (!card) return done = true;
removeFromArr(card,cards);
return this.player.selectAsyn('TARGET',this.player.signiZones).callback(this,function (zone) {
card.trapTo(zone);
});
});
}).callback(this,function () {
return this.player.setTrapFromDeckTopAsyn(2,2,{ callback: true }).callback(this,function (cards) {
this.game.trashCards(cards);
});
}
@ -119517,7 +119505,7 @@ var CardInfo = {
return this.player.selectAsyn('TRASH',cards).callback(this,function (card) {
if (!card) return;
card.trash();
return this.player.setTrapFromDeckTopAsyn(3,1,true);
return this.player.setTrapFromDeckTopAsyn(3,1,{ forced: true });
});
},
}],
@ -128807,7 +128795,7 @@ var CardInfo = {
actionAsyn: function () {
return this.banishAsyn().callback(this,function (succ) {
if (!succ) return;
return this.player.setTrapFromDeckTopAsyn(4,1,true);
return this.player.setTrapFromDeckTopAsyn(4,1,{ forced: true });
});
},
},
@ -129175,21 +129163,7 @@ var CardInfo = {
],
spellEffect: {
actionAsyn: function () {
// 复制并修改自 WX15-053
// TODO: 辅助函数
var cards = this.player.mainDeck.getTopCards(5);
this.player.informCards(cards);
var done = false;
return Callback.loop(this,5,function () {
if (done) return;
return this.player.selectOptionalAsyn('TARGET',cards).callback(this,function (card) {
if (!card) return done = true;
removeFromArr(card,cards);
return this.player.selectAsyn('TARGET',this.player.signiZones).callback(this,function (zone) {
card.trapTo(zone);
});
});
}).callback(this,function () {
return this.player.setTrapFromDeckTopAsyn(5,5,{ callback: true }).callback(this,function (cards) {
this.game.trashCards(cards);
});
},

View file

@ -2416,14 +2416,15 @@ Player.prototype.infectZoneAsyn = function() {
});
};
Player.prototype.setTrapFromDeckTopAsyn = function(count,max,forced) {
Player.prototype.setTrapFromDeckTopAsyn = function(count,max,arg) {
if (!isNum(max)) max = 1;
if (!arg) arg = {};
var cards = this.mainDeck.getTopCards(count);
this.informCards(cards);
var done = false;
return Callback.loop(this,max,function () {
if (done) return;
return this.selectAsyn('TARGET',cards,!forced).callback(this,function (card) {
return this.selectAsyn('TARGET',cards,!arg.forced).callback(this,function (card) {
if (!card) return done = true;
removeFromArr(card,cards);
return this.selectAsyn('TARGET',this.signiZones).callback(this,function (zone) {
@ -2431,11 +2432,14 @@ Player.prototype.setTrapFromDeckTopAsyn = function(count,max,forced) {
});
});
}).callback(this,function () {
if (arg.callback) return;
var len = cards.length;
if (!len) return;
return this.selectSomeAsyn('SET_ORDER',cards,len,len,true).callback(this,function (cards) {
this.mainDeck.moveCardsToBottom(cards);
});
}).callback(this,function () {
return cards;
});
};