forked from External/mage
Added support for casting modal spells or activating modal abilities with more than one mode to choose.
This commit is contained in:
parent
d520d63e2c
commit
853810ce45
8 changed files with 201 additions and 90 deletions
|
|
@ -170,9 +170,12 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> implements Ability {
|
|||
if (card != null) {
|
||||
card.adjustChoices(this, game);
|
||||
}
|
||||
if (getChoices().size() > 0 && getChoices().choose(game, this) == false) {
|
||||
logger.debug("activate failed - choice");
|
||||
return false;
|
||||
for (UUID modeId :this.getModes().getSelectedModes()) {
|
||||
this.getModes().setMode(this.getModes().get(modeId));
|
||||
if (getChoices().size() > 0 && getChoices().choose(game, this) == false) {
|
||||
logger.debug("activate failed - choice");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 20121001 - 601.2b
|
||||
|
|
@ -198,33 +201,37 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> implements Ability {
|
|||
// its mana cost; see rule 107.3), the player announces the value of that variable.
|
||||
VariableManaCost variableManaCost = handleXCosts(game, noMana);
|
||||
|
||||
//20121001 - 601.2c
|
||||
// 601.2c The player announces his or her choice of an appropriate player, object, or zone for
|
||||
// each target the spell requires. A spell may require some targets only if an alternative or
|
||||
// additional cost (such as a buyback or kicker cost), or a particular mode, was chosen for it;
|
||||
// otherwise, the spell is cast as though it did not require those targets. If the spell has a
|
||||
// variable number of targets, the player announces how many targets he or she will choose before
|
||||
// he or she announces those targets. The same target can't be chosen multiple times for any one
|
||||
// instance of the word "target" on the spell. However, if the spell uses the word "target" in
|
||||
// multiple places, the same object, player, or zone can be chosen once for each instance of the
|
||||
// word "target" (as long as it fits the targeting criteria). If any effects say that an object
|
||||
// or player must be chosen as a target, the player chooses targets so that he or she obeys the
|
||||
// maximum possible number of such effects without violating any rules or effects that say that
|
||||
// an object or player can't be chosen as a target. The chosen players, objects, and/or zones
|
||||
// each become a target of that spell. (Any abilities that trigger when those players, objects,
|
||||
// and/or zones become the target of a spell trigger at this point; they'll wait to be put on
|
||||
// the stack until the spell has finished being cast.)
|
||||
if (card != null) {
|
||||
card.adjustTargets(this, game);
|
||||
}
|
||||
if (getTargets().size() > 0 && getTargets().chooseTargets(getEffects().get(0).getOutcome(), this.controllerId, this, game) == false) {
|
||||
if (variableManaCost != null) {
|
||||
game.informPlayers(new StringBuilder(card.getName()).append(": no valid targets with this value of X").toString());
|
||||
} else {
|
||||
logger.debug("activate failed - target");
|
||||
for (UUID modeId :this.getModes().getSelectedModes()) {
|
||||
this.getModes().setMode(this.getModes().get(modeId));
|
||||
//20121001 - 601.2c
|
||||
// 601.2c The player announces his or her choice of an appropriate player, object, or zone for
|
||||
// each target the spell requires. A spell may require some targets only if an alternative or
|
||||
// additional cost (such as a buyback or kicker cost), or a particular mode, was chosen for it;
|
||||
// otherwise, the spell is cast as though it did not require those targets. If the spell has a
|
||||
// variable number of targets, the player announces how many targets he or she will choose before
|
||||
// he or she announces those targets. The same target can't be chosen multiple times for any one
|
||||
// instance of the word "target" on the spell. However, if the spell uses the word "target" in
|
||||
// multiple places, the same object, player, or zone can be chosen once for each instance of the
|
||||
// word "target" (as long as it fits the targeting criteria). If any effects say that an object
|
||||
// or player must be chosen as a target, the player chooses targets so that he or she obeys the
|
||||
// maximum possible number of such effects without violating any rules or effects that say that
|
||||
// an object or player can't be chosen as a target. The chosen players, objects, and/or zones
|
||||
// each become a target of that spell. (Any abilities that trigger when those players, objects,
|
||||
// and/or zones become the target of a spell trigger at this point; they'll wait to be put on
|
||||
// the stack until the spell has finished being cast.)
|
||||
|
||||
if (card != null) {
|
||||
card.adjustTargets(this, game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (getTargets().size() > 0 && getTargets().chooseTargets(getEffects().get(0).getOutcome(), this.controllerId, this, game) == false) {
|
||||
if (variableManaCost != null) {
|
||||
game.informPlayers(new StringBuilder(card != null ? card.getName(): "").append(": no valid targets with this value of X").toString());
|
||||
} else {
|
||||
logger.debug("activate failed - target");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} // end modes
|
||||
|
||||
// TODO: Handle optionalCosts at the same time as already OptionalAdditionalSourceCosts are handled.
|
||||
for (Cost cost : optionalCosts) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue