1
0
Fork 0

💫 implement source in handleTrapAsyn (for WX17-029)

This commit is contained in:
WEBXOSS 2017-10-04 15:50:03 +08:00
parent 7933d8b43c
commit ada169136a
2 changed files with 7 additions and 6 deletions

10
Card.js
View file

@ -1355,7 +1355,7 @@ Card.prototype.attackAsyn = function () {
if (opposingSigni || !trap) return;
return this.player.opponent.selectOptionalAsyn('LAUNCH',[trap]).callback(this,function (card) {
if (!card) return;
return card.handleTrapAsyn(event);
return card.handleTrapAsyn({event: event});
});
}).callback(this,function () {
// 攻击被无效,结束处理
@ -1853,8 +1853,10 @@ Card.prototype.isInfected = function() {
return this.zone.virus;
};
Card.prototype.handleTrapAsyn = function(event) {
// 注意 event 是可选的!
Card.prototype.handleTrapAsyn = function(arg) {
if (!arg) arg = {};
var event = arg.event; // 注意 event 是可选的!
var source = arg.source || this;
return Callback.immediately().callback(this,function () {
if (this.zone.cards.indexOf(this) === 0) {
this.faceup();
@ -1863,7 +1865,7 @@ Card.prototype.handleTrapAsyn = function(event) {
}
}).callback(this,function () {
if (!this.trap) return;
return this.game.blockAsyn(this,function () {
return this.game.blockAsyn(source,this,function () {
this.player.onTrapTriggered.trigger();
return this.trap.actionAsyn.call(this,event);
})

View file

@ -128830,8 +128830,7 @@ var CardInfo = {
return this.player.opponent.showCardsAsyn([card]).callback(this,function () {
return this.player.payCostOptionalAsyn(cost).callback(this,function (costArg) {
if (!costArg) return;
// TODO: source
return card.handleTrapAsyn(null,this);
return card.handleTrapAsyn({source: this});
});
});
});