mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
parent
39bf4bf0bc
commit
41fb3d14cb
3 changed files with 28 additions and 31 deletions
|
@ -947,22 +947,12 @@ public abstract class AbilityImpl implements Ability {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canChooseTarget(Game game, UUID playerId) {
|
public boolean canChooseTarget(Game game, UUID playerId) {
|
||||||
if (this instanceof SpellAbility) {
|
return canChooseTargetAbility(this, getModes(), game, playerId);
|
||||||
if (SpellAbilityType.SPLIT_FUSED.equals(((SpellAbility) this).getSpellAbilityType())) {
|
|
||||||
Card card = game.getCard(getSourceId());
|
|
||||||
if (card != null) {
|
|
||||||
return canChooseTargetAbility(((SplitCard) card).getLeftHalfCard().getSpellAbility(), game, playerId)
|
|
||||||
&& canChooseTargetAbility(((SplitCard) card).getRightHalfCard().getSpellAbility(), game, playerId);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return canChooseTargetAbility(this, game, playerId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean canChooseTargetAbility(Ability ability, Game game, UUID controllerId) {
|
protected static boolean canChooseTargetAbility(Ability ability, Modes modes, Game game, UUID controllerId) {
|
||||||
int found = 0;
|
int found = 0;
|
||||||
for (Mode mode : ability.getModes().values()) {
|
for (Mode mode : modes.values()) {
|
||||||
boolean validTargets = true;
|
boolean validTargets = true;
|
||||||
for (Target target : mode.getTargets()) {
|
for (Target target : mode.getTargets()) {
|
||||||
UUID abilityControllerId = controllerId;
|
UUID abilityControllerId = controllerId;
|
||||||
|
@ -977,10 +967,10 @@ public abstract class AbilityImpl implements Ability {
|
||||||
|
|
||||||
if (validTargets) {
|
if (validTargets) {
|
||||||
found++;
|
found++;
|
||||||
if (ability.getModes().isEachModeMoreThanOnce()) {
|
if (modes.isEachModeMoreThanOnce()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (found >= ability.getModes().getMinModes()) {
|
if (found >= modes.getMinModes()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,24 @@ public class SpellAbility extends ActivatedAbilityImpl {
|
||||||
this.cardName = ability.cardName;
|
this.cardName = ability.cardName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canChooseTarget(Game game, UUID playerId) {
|
||||||
|
if (SpellAbilityType.SPLIT_FUSED.equals(getSpellAbilityType())) {
|
||||||
|
Card card = game.getCard(getSourceId());
|
||||||
|
if (card == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
SpellAbility left = ((SplitCard) card).getLeftHalfCard().getSpellAbility();
|
||||||
|
SpellAbility right = ((SplitCard) card).getRightHalfCard().getSpellAbility();
|
||||||
|
return canChooseTargetAbility(left, left.getModes(), game, playerId) && canChooseTargetAbility(right, right.getModes(), game, playerId);
|
||||||
|
}
|
||||||
|
return super.canChooseTarget(game, playerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canSpliceOnto(Ability abilityToModify, Game game) {
|
||||||
|
return canChooseTargetAbility(abilityToModify, getModes(), game, abilityToModify.getControllerId());
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 7/5/19 - jgray1206 - Moved null != game.getContinuesEffects()... into this method instead of having it in
|
* 7/5/19 - jgray1206 - Moved null != game.getContinuesEffects()... into this method instead of having it in
|
||||||
* canActivate. There are abilities that directly use this method that should know when spells
|
* canActivate. There are abilities that directly use this method that should know when spells
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package mage.abilities.keyword;
|
package mage.abilities.keyword;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import mage.MageObject;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.SpellAbility;
|
import mage.abilities.SpellAbility;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
|
@ -188,23 +187,13 @@ class SpliceCardEffectImpl extends ContinuousEffectImpl implements SpliceCardEff
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||||
MageObject object = game.getObject(abilityToModify.getSourceId());
|
if (!filter.match(game.getObject(abilityToModify.getSourceId()), game)) {
|
||||||
if (object != null && filter.match(object, game)) {
|
return false;
|
||||||
return spliceSpellCanBeActivated(source, game);
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean spliceSpellCanBeActivated(Ability source, Game game) {
|
|
||||||
// check if spell can be activated (protection problem not solved because effect will be used from the base spell?)
|
|
||||||
Card card = game.getCard(source.getSourceId());
|
Card card = game.getCard(source.getSourceId());
|
||||||
if (card != null) {
|
if (card == null) {
|
||||||
if (card.getManaCost().isEmpty()) { // e.g. Evermind
|
return false;
|
||||||
return card.getSpellAbility().spellCanBeActivatedRegularlyNow(source.getControllerId(), game);
|
|
||||||
} else {
|
|
||||||
return card.getSpellAbility().canActivate(source.getControllerId(), game).canActivate();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return card.getSpellAbility().canSpliceOnto(abilityToModify, game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue