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

View file

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