💫 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, source: this,
description: '2071-burst-2', description: '2071-burst-2',
actionAsyn: function () { actionAsyn: function () {
var cards = this.player.mainDeck.getTopCards(2); return this.player.setTrapFromDeckTopAsyn(2,2,{ callback: true }).callback(this,function (cards) {
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 () {
this.game.trashCards(cards); this.game.trashCards(cards);
}); });
} }
@ -119517,7 +119505,7 @@ var CardInfo = {
return this.player.selectAsyn('TRASH',cards).callback(this,function (card) { return this.player.selectAsyn('TRASH',cards).callback(this,function (card) {
if (!card) return; if (!card) return;
card.trash(); 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 () { actionAsyn: function () {
return this.banishAsyn().callback(this,function (succ) { return this.banishAsyn().callback(this,function (succ) {
if (!succ) return; 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: { spellEffect: {
actionAsyn: function () { actionAsyn: function () {
// 复制并修改自 WX15-053 return this.player.setTrapFromDeckTopAsyn(5,5,{ callback: true }).callback(this,function (cards) {
// 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 () {
this.game.trashCards(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 (!isNum(max)) max = 1;
if (!arg) arg = {};
var cards = this.mainDeck.getTopCards(count); var cards = this.mainDeck.getTopCards(count);
this.informCards(cards); this.informCards(cards);
var done = false; var done = false;
return Callback.loop(this,max,function () { return Callback.loop(this,max,function () {
if (done) return; 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; if (!card) return done = true;
removeFromArr(card,cards); removeFromArr(card,cards);
return this.selectAsyn('TARGET',this.signiZones).callback(this,function (zone) { return this.selectAsyn('TARGET',this.signiZones).callback(this,function (zone) {
@ -2431,11 +2432,14 @@ Player.prototype.setTrapFromDeckTopAsyn = function(count,max,forced) {
}); });
}); });
}).callback(this,function () { }).callback(this,function () {
if (arg.callback) return;
var len = cards.length; var len = cards.length;
if (!len) return; if (!len) return;
return this.selectSomeAsyn('SET_ORDER',cards,len,len,true).callback(this,function (cards) { return this.selectSomeAsyn('SET_ORDER',cards,len,len,true).callback(this,function (cards) {
this.mainDeck.moveCardsToBottom(cards); this.mainDeck.moveCardsToBottom(cards);
}); });
}).callback(this,function () {
return cards;
}); });
}; };