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