💫 implement multi spell effects selection (for WX17-040)

This commit is contained in:
WEBXOSS 2017-10-04 15:19:59 +08:00
parent 867e9253cb
commit 36a0f2b25b
2 changed files with 40 additions and 27 deletions

View file

@ -125800,7 +125800,6 @@ var CardInfo = {
"対戦相手のライフクロスの枚数があなたより多い場合、対戦相手のシグニ1体をバニッシュする。"
],
getMinEffectCount: function () {
// TODO: getMinEffectCount 这个函数只在arts上用到过不知道spell上是否能用
return 1;
},
getMaxEffectCount: function () {

View file

@ -533,7 +533,7 @@ Player.prototype.useSpellAsyn = function () {
Player.prototype.handleSpellAsyn = function (card,ignoreCost,costObj,arg) {
if (!costObj) costObj = card;
if (!arg) arg = {};
var effect,target,costArg;
var effects,targets,costArg;
this.game.setData(this,'flagSpellUsed',true);
var count = this.game.getData(this,'CodeHeartAMS') || 0;
this.game.setData(this,'CodeHeartAMS',count + 1);
@ -558,37 +558,50 @@ Player.prototype.handleSpellAsyn = function (card,ignoreCost,costObj,arg) {
return this.payCostAsyn(costObj);
}).callback(this,function (_costArg) {
costArg = _costArg;
// 如果魔法卡的效果不止一个,选择其中个发动
// 如果魔法卡的效果不止一个,选择其中n个发动
if (card.spellEffects.length === 1) {
effect = card.spellEffects[0];
effects = card.spellEffects.slice();
} else {
return this.selectAsyn('SPELL_EFFECT',card.spellEffects).callback(this,function (eff) {
effect = eff;
return this.opponent.showEffectsAsyn([eff]);
var min,max;
if (!card.getMinEffectCount || !card.getMaxEffectCount) {
min = max = 1;
} else {
min = card.getMinEffectCount(costObj);
max = card.getMaxEffectCount(costObj);
}
return this.selectSomeAsyn('SPELL_EFFECT',card.artsEffects,min,max,false).callback(this,function (effs) {
effects = effs;
if (card.costChangeAfterChoose) {
card.costChangeAfterChoose.call(card,costObj,effs);
}
return this.opponent.showEffectsAsyn(effs);
});
}
}).callback(this,function () {
// 3. 娶(划掉)取对象.
card.activate();
if (effect.getTargets) {
// 简单的取对象,即从目标卡片中选一张. (也可以不选,空发)
if (effect.targetCovered) {
// 从废弃区等[卡片可能被覆盖的区域]取对象
return this.selectAsyn('TARGET',effect.getTargets.call(card)).callback(this,function (card) {
if (!card) return card;
return this.opponent.showCardsAsyn([card]).callback(this,function () {
return card;
return Callback.forEach(effects,function (effect,idx) {
return Callback.immediately().callback(this,function () {
if (effect.getTargets) {
// 简单的取对象,即从目标卡片中选一张.
if (!effect.targetCovered) return this.selectTargetAsyn(effect.getTargets.call(card));
// 从废弃区等[卡片可能被覆盖的区域]取对象
return this.selectAsyn('TARGET',effect.getTargets.call(card)).callback(this,function (card) {
if (!card) return card;
return this.opponent.showCardsAsyn([card]).callback(this,function () {
return card;
});
});
});
}
return this.selectTargetAsyn(effect.getTargets.call(card));
}
if (effect.getTargetAdvancedAsyn) {
// 复杂(高级)的取对象.
return effect.getTargetAdvancedAsyn.call(card,costArg);
}
}
if (effect.getTargetAdvancedAsyn) {
// 复杂(高级)的取对象.
return effect.getTargetAdvancedAsyn.call(card,costArg);
}
}).callback(this,function (target) {
targets[idx] = target;
});
},this);
}).callback(this,function (t) {
target = t;
return this.game.blockEndAsyn();
// ------ 块结束 ------
}).callback(this,function () {
@ -597,8 +610,9 @@ Player.prototype.handleSpellAsyn = function (card,ignoreCost,costObj,arg) {
}).callback(this,function (canceled) {
// 5. 处理.
// "处理+放置到废弃区"放在1个block里.
return this.game.blockAsyn(effect.source,this,function () {
return Callback.immediately().callback(this,function () {
return this.game.blockAsyn(card,this,function () {
return Callback.forEach(effects,function (effect,idx) {
var target = targets[idx];
// "结束这个回合",处理直接结束.
if (this.game.phase.checkForcedEndTurn()) return;
// "不会被取消"
@ -619,7 +633,7 @@ Player.prototype.handleSpellAsyn = function (card,ignoreCost,costObj,arg) {
}
}
return effect.actionAsyn.call(card,target,costArg);
}).callback(this,function () {
},this).callback(this,function () {
// 6. 放到废弃区
// 恢复控制权
card.player = card.owner;