forked from External/mage
* Splice onto Arcane - Fixed that an arcane spell with no targets did not fizzle if a targeted spell was spliced with it that has no more legal targets on resolution (so all targets of the spell were illegal).
This commit is contained in:
parent
7224ab1614
commit
822528d05c
6 changed files with 224 additions and 78 deletions
|
|
@ -171,6 +171,7 @@ public class Spell extends StackObjImpl implements Card {
|
|||
int index = 0;
|
||||
result = false;
|
||||
boolean legalParts = false;
|
||||
boolean notTargeted = true;
|
||||
// check for legal parts
|
||||
for (SpellAbility spellAbility : this.spellAbilities) {
|
||||
// if muliple modes are selected, and there are modes with targets, then at least one mode has to have a legal target or
|
||||
|
|
@ -178,10 +179,15 @@ public class Spell extends StackObjImpl implements Card {
|
|||
// If all targets are illegal when the spell tries to resolve, the spell is countered and none of its effects happen.
|
||||
// If at least one target is still legal at that time, the spell resolves, but an illegal target can't perform any actions
|
||||
// or have any actions performed on it.
|
||||
legalParts |= spellAbilityHasLegalParts(spellAbility, game);
|
||||
// if only a spliced spell has targets and all targets ar illegal, the complete spell is countered
|
||||
if (hasTargets(spellAbility, game)) {
|
||||
notTargeted = false;
|
||||
legalParts |= spellAbilityHasLegalParts(spellAbility, game);
|
||||
}
|
||||
|
||||
}
|
||||
// resolve if legal parts
|
||||
if (legalParts) {
|
||||
if (notTargeted || legalParts) {
|
||||
for (SpellAbility spellAbility : this.spellAbilities) {
|
||||
if (spellAbilityHasLegalParts(spellAbility, game)) {
|
||||
for (UUID modeId : spellAbility.getModes().getSelectedModes()) {
|
||||
|
|
@ -262,6 +268,21 @@ public class Spell extends StackObjImpl implements Card {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean hasTargets(SpellAbility spellAbility, Game game) {
|
||||
if (spellAbility.getModes().getSelectedModes().size() > 1) {
|
||||
for (UUID modeId : spellAbility.getModes().getSelectedModes()) {
|
||||
spellAbility.getModes().setActiveMode(modeId);
|
||||
if (!spellAbility.getTargets().isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
return !spellAbility.getTargets().isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean spellAbilityHasLegalParts(SpellAbility spellAbility, Game game) {
|
||||
if (spellAbility.getModes().getSelectedModes().size() > 1) {
|
||||
boolean targetedMode = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue