- little refactor of Ethereal Valkyrie

This commit is contained in:
jeffwadsworth 2021-02-03 15:21:18 -06:00
parent fb447d7740
commit 1c2f8f4caa
2 changed files with 222 additions and 401 deletions

View file

@ -4,13 +4,8 @@ import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.MageObjectReference; import mage.MageObjectReference;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.ActivatedAbility;
import mage.abilities.SpellAbility;
import mage.abilities.TriggeredAbilityImpl; import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.costs.Cost; import mage.abilities.effects.ContinuousEffect;
import mage.abilities.costs.Costs;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.FlyingAbility;
@ -18,19 +13,11 @@ import mage.abilities.keyword.ForetellAbility;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.cards.ModalDoubleFacesCard;
import mage.cards.SplitCard;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SpellAbilityCastMode;
import mage.constants.SpellAbilityType;
import mage.constants.SubLayer;
import mage.constants.SubType; import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.FilterCard; import mage.filter.FilterCard;
import mage.game.ExileZone;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
@ -149,176 +136,11 @@ class EtherealValkyrieEffect extends OneShotEffect {
foretellAbility.setControllerId(exileCard.getOwnerId()); foretellAbility.setControllerId(exileCard.getOwnerId());
game.getState().addOtherAbility(exileCard, foretellAbility); game.getState().addOtherAbility(exileCard, foretellAbility);
foretellAbility.activate(game, true); foretellAbility.activate(game, true);
game.addEffect(new ForetellAddCostEffect(new MageObjectReference(exileCard, game)), source); ContinuousEffect effect = foretellAbility.new ForetellAddCostEffect(new MageObjectReference(exileCard, game));
game.addEffect(effect, source);
return true; return true;
} }
} }
return false; return false;
} }
} }
class ForetellAddCostEffect extends ContinuousEffectImpl {
private final MageObjectReference mor;
public ForetellAddCostEffect(MageObjectReference mor) {
super(Duration.EndOfGame, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility);
this.mor = mor;
staticText = "Foretold card";
}
public ForetellAddCostEffect(final ForetellAddCostEffect effect) {
super(effect);
this.mor = effect.mor;
}
@Override
public boolean apply(Game game, Ability source) {
Card card = mor.getCard(game);
if (card != null
&& game.getState().getZone(card.getId()) == Zone.EXILED) {
String foretellCost = (String) game.getState().getValue(card.getId().toString() + "Foretell Cost");
Ability ability = new ForetellCostAbility(foretellCost);
ability.setSourceId(card.getId());
ability.setControllerId(source.getControllerId());
game.getState().addOtherAbility(card, ability);
} else {
discard();
}
return true;
}
@Override
public ForetellAddCostEffect copy() {
return new ForetellAddCostEffect(this);
}
}
class ForetellCostAbility extends SpellAbility {
private String abilityName;
private SpellAbility spellAbilityToResolve;
public ForetellCostAbility(String foretellCost) {
super(null, "Testing", Zone.EXILED, SpellAbilityType.BASE_ALTERNATE, SpellAbilityCastMode.NORMAL);
this.setAdditionalCostsRuleVisible(false);
this.name = "Foretell " + foretellCost;
this.addCost(new ManaCostsImpl(foretellCost));
}
public ForetellCostAbility(final ForetellCostAbility ability) {
super(ability);
this.spellAbilityType = ability.spellAbilityType;
this.abilityName = ability.abilityName;
this.spellAbilityToResolve = ability.spellAbilityToResolve;
}
@Override
public ActivatedAbility.ActivationStatus canActivate(UUID playerId, Game game) {
if (super.canActivate(playerId, game).canActivate()) {
Card card = game.getCard(getSourceId());
if (card != null) {
// Card must be in the exile zone
if (game.getState().getZone(card.getId()) != Zone.EXILED) {
return ActivatedAbility.ActivationStatus.getFalse();
}
// Card must be Foretold
if (game.getState().getValue(card.getId().toString() + "Foretell Turn Number") == null
&& game.getState().getValue(card.getId().toString() + "foretellAbility") == null) {
return ActivatedAbility.ActivationStatus.getFalse();
}
// Can't be cast if the turn it was Foretold is the same
if ((int) game.getState().getValue(card.getId().toString() + "Foretell Turn Number") == game.getTurnNum()) {
return ActivatedAbility.ActivationStatus.getFalse();
}
// Check that the card is actually in the exile zone (ex: Oblivion Ring exiles it after it was Foretold, etc)
UUID exileId = (UUID) game.getState().getValue(card.getId().toString() + "foretellAbility");
ExileZone exileZone = game.getState().getExile().getExileZone(exileId);
if (exileZone != null
&& exileZone.isEmpty()) {
return ActivatedAbility.ActivationStatus.getFalse();
}
if (card instanceof SplitCard) {
if (((SplitCard) card).getLeftHalfCard().getName().equals(abilityName)) {
return ((SplitCard) card).getLeftHalfCard().getSpellAbility().canActivate(playerId, game);
} else if (((SplitCard) card).getRightHalfCard().getName().equals(abilityName)) {
return ((SplitCard) card).getRightHalfCard().getSpellAbility().canActivate(playerId, game);
}
} else if (card instanceof ModalDoubleFacesCard) {
if (((ModalDoubleFacesCard) card).getLeftHalfCard().getName().equals(abilityName)) {
return ((ModalDoubleFacesCard) card).getLeftHalfCard().getSpellAbility().canActivate(playerId, game);
} else if (((ModalDoubleFacesCard) card).getRightHalfCard().getName().equals(abilityName)) {
return ((ModalDoubleFacesCard) card).getRightHalfCard().getSpellAbility().canActivate(playerId, game);
}
}
return card.getSpellAbility().canActivate(playerId, game);
}
}
return ActivatedAbility.ActivationStatus.getFalse();
}
@Override
public SpellAbility getSpellAbilityToResolve(Game game) {
Card card = game.getCard(getSourceId());
if (card != null) {
if (spellAbilityToResolve == null) {
SpellAbility spellAbilityCopy = null;
if (card instanceof SplitCard) {
if (((SplitCard) card).getLeftHalfCard().getName().equals(abilityName)) {
spellAbilityCopy = ((SplitCard) card).getLeftHalfCard().getSpellAbility().copy();
} else if (((SplitCard) card).getRightHalfCard().getName().equals(abilityName)) {
spellAbilityCopy = ((SplitCard) card).getRightHalfCard().getSpellAbility().copy();
}
} else if (card instanceof ModalDoubleFacesCard) {
if (((ModalDoubleFacesCard) card).getLeftHalfCard().getName().equals(abilityName)) {
spellAbilityCopy = ((ModalDoubleFacesCard) card).getLeftHalfCard().getSpellAbility().copy();
} else if (((ModalDoubleFacesCard) card).getRightHalfCard().getName().equals(abilityName)) {
spellAbilityCopy = ((ModalDoubleFacesCard) card).getRightHalfCard().getSpellAbility().copy();
}
} else {
spellAbilityCopy = card.getSpellAbility().copy();
}
if (spellAbilityCopy == null) {
return null;
}
spellAbilityCopy.setId(this.getId());
spellAbilityCopy.getManaCosts().clear();
spellAbilityCopy.getManaCostsToPay().clear();
spellAbilityCopy.getCosts().addAll(this.getCosts().copy());
spellAbilityCopy.addCost(this.getManaCosts().copy());
spellAbilityCopy.setSpellAbilityCastMode(this.getSpellAbilityCastMode());
spellAbilityToResolve = spellAbilityCopy;
}
}
return spellAbilityToResolve;
}
@Override
public Costs<Cost> getCosts() {
if (spellAbilityToResolve == null) {
return super.getCosts();
}
return spellAbilityToResolve.getCosts();
}
@Override
public ForetellCostAbility copy() {
return new ForetellCostAbility(this);
}
@Override
public String getRule(boolean all) {
return "";
}
/**
* Used for split card in PlayerImpl method:
* getOtherUseableActivatedAbilities
*
* @param abilityName
*/
public void setAbilityName(String abilityName) {
this.abilityName = abilityName;
}
}

View file

@ -74,265 +74,264 @@ public class ForetellAbility extends SpecialAction {
@Override @Override
public String getRule() { public String getRule() {
return "Foretell " + foretellCost + " <i>(During your turn, " + return "Foretell " + foretellCost + " <i>(During your turn, "
"you may pay {2} and exile this card from your hand face down. " + + "you may pay {2} and exile this card from your hand face down. "
"Cast it on a later turn for its foretell cost.)</i>"; + "Cast it on a later turn for its foretell cost.)</i>";
}
}
class ForetellExileEffect extends OneShotEffect {
private final Card card;
String foretellCost;
public ForetellExileEffect(Card card, String foretellCost) {
super(Outcome.Neutral);
this.card = card;
this.foretellCost = foretellCost;
} }
public ForetellExileEffect(final ForetellExileEffect effect) { public class ForetellExileEffect extends OneShotEffect {
super(effect);
this.card = effect.card; private final Card card;
this.foretellCost = effect.foretellCost; String foretellCost;
public ForetellExileEffect(Card card, String foretellCost) {
super(Outcome.Neutral);
this.card = card;
this.foretellCost = foretellCost;
}
public ForetellExileEffect(final ForetellExileEffect effect) {
super(effect);
this.card = effect.card;
this.foretellCost = effect.foretellCost;
}
@Override
public ForetellExileEffect copy() {
return new ForetellExileEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null
&& card != null) {
// retrieve the exileId of the foretold card
UUID exileId = CardUtil.getExileZoneId(card.getId().toString() + "foretellAbility", game);
// foretell turn number shows up on exile window
Effect effect = new ExileTargetEffect(exileId, " Foretell Turn Number: " + game.getTurnNum());
// remember turn number it was cast
game.getState().setValue(card.getId().toString() + "Foretell Turn Number", game.getTurnNum());
// remember the foretell cost
game.getState().setValue(card.getId().toString() + "Foretell Cost", foretellCost);
// exile the card face-down
effect.setTargetPointer(new FixedTarget(card.getId()));
effect.apply(game, source);
card.setFaceDown(true, game);
game.addEffect(new ForetellAddCostEffect(new MageObjectReference(card, game)), source);
return true;
}
return false;
}
} }
@Override public class ForetellLookAtCardEffect extends AsThoughEffectImpl {
public ForetellExileEffect copy() {
return new ForetellExileEffect(this);
}
@Override public ForetellLookAtCardEffect() {
public boolean apply(Game game, Ability source) { super(AsThoughEffectType.LOOK_AT_FACE_DOWN, Duration.EndOfGame, Outcome.AIDontUseIt);
Player controller = game.getPlayer(source.getControllerId()); }
if (controller != null
&& card != null) {
// retrieve the exileId of the foretold card
UUID exileId = CardUtil.getExileZoneId(card.getId().toString() + "foretellAbility", game);
// foretell turn number shows up on exile window public ForetellLookAtCardEffect(final ForetellLookAtCardEffect effect) {
Effect effect = new ExileTargetEffect(exileId, " Foretell Turn Number: " + game.getTurnNum()); super(effect);
}
// remember turn number it was cast @Override
game.getState().setValue(card.getId().toString() + "Foretell Turn Number", game.getTurnNum()); public boolean apply(Game game, Ability source) {
// remember the foretell cost
game.getState().setValue(card.getId().toString() + "Foretell Cost", foretellCost);
// exile the card face-down
effect.setTargetPointer(new FixedTarget(card.getId()));
effect.apply(game, source);
card.setFaceDown(true, game);
game.addEffect(new ForetellAddCostEffect(new MageObjectReference(card, game)), source);
return true; return true;
} }
return false;
}
}
class ForetellLookAtCardEffect extends AsThoughEffectImpl { @Override
public ForetellLookAtCardEffect copy() {
return new ForetellLookAtCardEffect(this);
}
public ForetellLookAtCardEffect() { @Override
super(AsThoughEffectType.LOOK_AT_FACE_DOWN, Duration.EndOfGame, Outcome.AIDontUseIt); public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
} if (affectedControllerId.equals(source.getControllerId())) {
Card card = game.getCard(objectId);
public ForetellLookAtCardEffect(final ForetellLookAtCardEffect effect) { if (card != null
super(effect); && CardUtil.getExileZoneId(card.getId().toString() + "foretellAbility", game) != null) {
} MageObject sourceObject = game.getObject(source.getSourceId());
if (sourceObject == null) {
@Override return false;
public boolean apply(Game game, Ability source) { }
return true; UUID exileId = CardUtil.getExileZoneId(card.getId().toString() + "foretellAbility", game);
} ExileZone exile = game.getExile().getExileZone(exileId);
return exile != null
@Override && exile.contains(card.getId());
public ForetellLookAtCardEffect copy() {
return new ForetellLookAtCardEffect(this);
}
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
if (affectedControllerId.equals(source.getControllerId())) {
Card card = game.getCard(objectId);
if (card != null
&& CardUtil.getExileZoneId(card.getId().toString() + "foretellAbility", game) != null) {
MageObject sourceObject = game.getObject(source.getSourceId());
if (sourceObject == null) {
return false;
} }
UUID exileId = CardUtil.getExileZoneId(card.getId().toString() + "foretellAbility", game);
ExileZone exile = game.getExile().getExileZone(exileId);
return exile != null
&& exile.contains(card.getId());
} }
return false;
} }
return false;
}
}
// this needed to be a continuousEffect for a card like Dream Devourer...unless someone has a better idea
class ForetellAddCostEffect extends ContinuousEffectImpl {
private final MageObjectReference mor;
public ForetellAddCostEffect(MageObjectReference mor) {
super(Duration.EndOfGame, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility);
this.mor = mor;
staticText = "Foretold card";
} }
public ForetellAddCostEffect(final ForetellAddCostEffect effect) { public class ForetellAddCostEffect extends ContinuousEffectImpl {
super(effect);
this.mor = effect.mor;
}
@Override private final MageObjectReference mor;
public boolean apply(Game game, Ability source) {
Card card = mor.getCard(game); public ForetellAddCostEffect(MageObjectReference mor) {
if (card != null super(Duration.EndOfGame, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility);
&& game.getState().getZone(card.getId()) == Zone.EXILED) { this.mor = mor;
String foretellCost = (String) game.getState().getValue(card.getId().toString() + "Foretell Cost"); staticText = "Foretold card";
Ability ability = new ForetellCostAbility(foretellCost); }
ability.setSourceId(card.getId());
ability.setControllerId(source.getControllerId()); public ForetellAddCostEffect(final ForetellAddCostEffect effect) {
game.getState().addOtherAbility(card, ability); super(effect);
} else { this.mor = effect.mor;
discard(); }
@Override
public boolean apply(Game game, Ability source) {
Card card = mor.getCard(game);
if (card != null
&& game.getState().getZone(card.getId()) == Zone.EXILED) {
String foretellCost = (String) game.getState().getValue(card.getId().toString() + "Foretell Cost");
Ability ability = new ForetellCostAbility(foretellCost);
ability.setSourceId(card.getId());
ability.setControllerId(source.getControllerId());
game.getState().addOtherAbility(card, ability);
} else {
discard();
}
return true;
}
@Override
public ForetellAddCostEffect copy() {
return new ForetellAddCostEffect(this);
} }
return true;
} }
@Override public class ForetellCostAbility extends SpellAbility {
public ForetellAddCostEffect copy() {
return new ForetellAddCostEffect(this);
}
}
class ForetellCostAbility extends SpellAbility { private String abilityName;
private SpellAbility spellAbilityToResolve;
private String abilityName; public ForetellCostAbility(String foretellCost) {
private SpellAbility spellAbilityToResolve; super(null, "Testing", Zone.EXILED, SpellAbilityType.BASE_ALTERNATE, SpellAbilityCastMode.NORMAL);
this.setAdditionalCostsRuleVisible(false);
this.name = "Foretell " + foretellCost;
this.addCost(new ManaCostsImpl(foretellCost));
}
public ForetellCostAbility(String foretellCost) { public ForetellCostAbility(final ForetellCostAbility ability) {
super(null, "Testing", Zone.EXILED, SpellAbilityType.BASE_ALTERNATE, SpellAbilityCastMode.NORMAL); super(ability);
this.setAdditionalCostsRuleVisible(false); this.spellAbilityType = ability.spellAbilityType;
this.name = "Foretell " + foretellCost; this.abilityName = ability.abilityName;
this.addCost(new ManaCostsImpl(foretellCost)); this.spellAbilityToResolve = ability.spellAbilityToResolve;
} }
public ForetellCostAbility(final ForetellCostAbility ability) { @Override
super(ability); public ActivationStatus canActivate(UUID playerId, Game game) {
this.spellAbilityType = ability.spellAbilityType; if (super.canActivate(playerId, game).canActivate()) {
this.abilityName = ability.abilityName; Card card = game.getCard(getSourceId());
this.spellAbilityToResolve = ability.spellAbilityToResolve; if (card != null) {
} // Card must be in the exile zone
if (game.getState().getZone(card.getId()) != Zone.EXILED) {
return ActivationStatus.getFalse();
}
// Card must be Foretold
if (game.getState().getValue(card.getId().toString() + "Foretell Turn Number") == null
&& game.getState().getValue(card.getId().toString() + "foretellAbility") == null) {
return ActivationStatus.getFalse();
}
// Can't be cast if the turn it was Foretold is the same
if ((int) game.getState().getValue(card.getId().toString() + "Foretell Turn Number") == game.getTurnNum()) {
return ActivationStatus.getFalse();
}
// Check that the card is actually in the exile zone (ex: Oblivion Ring exiles it after it was Foretold, etc)
UUID exileId = (UUID) game.getState().getValue(card.getId().toString() + "foretellAbility");
ExileZone exileZone = game.getState().getExile().getExileZone(exileId);
if (exileZone != null
&& exileZone.isEmpty()) {
return ActivationStatus.getFalse();
}
if (card instanceof SplitCard) {
if (((SplitCard) card).getLeftHalfCard().getName().equals(abilityName)) {
return ((SplitCard) card).getLeftHalfCard().getSpellAbility().canActivate(playerId, game);
} else if (((SplitCard) card).getRightHalfCard().getName().equals(abilityName)) {
return ((SplitCard) card).getRightHalfCard().getSpellAbility().canActivate(playerId, game);
}
} else if (card instanceof ModalDoubleFacesCard) {
if (((ModalDoubleFacesCard) card).getLeftHalfCard().getName().equals(abilityName)) {
return ((ModalDoubleFacesCard) card).getLeftHalfCard().getSpellAbility().canActivate(playerId, game);
} else if (((ModalDoubleFacesCard) card).getRightHalfCard().getName().equals(abilityName)) {
return ((ModalDoubleFacesCard) card).getRightHalfCard().getSpellAbility().canActivate(playerId, game);
}
}
return card.getSpellAbility().canActivate(playerId, game);
}
}
return ActivationStatus.getFalse();
}
@Override @Override
public ActivationStatus canActivate(UUID playerId, Game game) { public SpellAbility getSpellAbilityToResolve(Game game) {
if (super.canActivate(playerId, game).canActivate()) {
Card card = game.getCard(getSourceId()); Card card = game.getCard(getSourceId());
if (card != null) { if (card != null) {
// Card must be in the exile zone if (spellAbilityToResolve == null) {
if (game.getState().getZone(card.getId()) != Zone.EXILED) { SpellAbility spellAbilityCopy = null;
return ActivationStatus.getFalse(); if (card instanceof SplitCard) {
} if (((SplitCard) card).getLeftHalfCard().getName().equals(abilityName)) {
// Card must be Foretold spellAbilityCopy = ((SplitCard) card).getLeftHalfCard().getSpellAbility().copy();
if (game.getState().getValue(card.getId().toString() + "Foretell Turn Number") == null } else if (((SplitCard) card).getRightHalfCard().getName().equals(abilityName)) {
&& game.getState().getValue(card.getId().toString() + "foretellAbility") == null) { spellAbilityCopy = ((SplitCard) card).getRightHalfCard().getSpellAbility().copy();
return ActivationStatus.getFalse(); }
} } else if (card instanceof ModalDoubleFacesCard) {
// Can't be cast if the turn it was Foretold is the same if (((ModalDoubleFacesCard) card).getLeftHalfCard().getName().equals(abilityName)) {
if ((int) game.getState().getValue(card.getId().toString() + "Foretell Turn Number") == game.getTurnNum()) { spellAbilityCopy = ((ModalDoubleFacesCard) card).getLeftHalfCard().getSpellAbility().copy();
return ActivationStatus.getFalse(); } else if (((ModalDoubleFacesCard) card).getRightHalfCard().getName().equals(abilityName)) {
} spellAbilityCopy = ((ModalDoubleFacesCard) card).getRightHalfCard().getSpellAbility().copy();
// Check that the card is actually in the exile zone (ex: Oblivion Ring exiles it after it was Foretold, etc) }
UUID exileId = (UUID) game.getState().getValue(card.getId().toString() + "foretellAbility"); } else {
ExileZone exileZone = game.getState().getExile().getExileZone(exileId); spellAbilityCopy = card.getSpellAbility().copy();
if (exileZone != null
&& exileZone.isEmpty()) {
return ActivationStatus.getFalse();
}
if (card instanceof SplitCard) {
if (((SplitCard) card).getLeftHalfCard().getName().equals(abilityName)) {
return ((SplitCard) card).getLeftHalfCard().getSpellAbility().canActivate(playerId, game);
} else if (((SplitCard) card).getRightHalfCard().getName().equals(abilityName)) {
return ((SplitCard) card).getRightHalfCard().getSpellAbility().canActivate(playerId, game);
} }
} else if (card instanceof ModalDoubleFacesCard) { if (spellAbilityCopy == null) {
if (((ModalDoubleFacesCard) card).getLeftHalfCard().getName().equals(abilityName)) { return null;
return ((ModalDoubleFacesCard) card).getLeftHalfCard().getSpellAbility().canActivate(playerId, game);
} else if (((ModalDoubleFacesCard) card).getRightHalfCard().getName().equals(abilityName)) {
return ((ModalDoubleFacesCard) card).getRightHalfCard().getSpellAbility().canActivate(playerId, game);
} }
spellAbilityCopy.setId(this.getId());
spellAbilityCopy.getManaCosts().clear();
spellAbilityCopy.getManaCostsToPay().clear();
spellAbilityCopy.getCosts().addAll(this.getCosts().copy());
spellAbilityCopy.addCost(this.getManaCosts().copy());
spellAbilityCopy.setSpellAbilityCastMode(this.getSpellAbilityCastMode());
spellAbilityToResolve = spellAbilityCopy;
} }
return card.getSpellAbility().canActivate(playerId, game);
} }
return spellAbilityToResolve;
} }
return ActivationStatus.getFalse();
}
@Override @Override
public SpellAbility getSpellAbilityToResolve(Game game) { public Costs<Cost> getCosts() {
Card card = game.getCard(getSourceId());
if (card != null) {
if (spellAbilityToResolve == null) { if (spellAbilityToResolve == null) {
SpellAbility spellAbilityCopy = null; return super.getCosts();
if (card instanceof SplitCard) {
if (((SplitCard) card).getLeftHalfCard().getName().equals(abilityName)) {
spellAbilityCopy = ((SplitCard) card).getLeftHalfCard().getSpellAbility().copy();
} else if (((SplitCard) card).getRightHalfCard().getName().equals(abilityName)) {
spellAbilityCopy = ((SplitCard) card).getRightHalfCard().getSpellAbility().copy();
}
} else if (card instanceof ModalDoubleFacesCard) {
if (((ModalDoubleFacesCard) card).getLeftHalfCard().getName().equals(abilityName)) {
spellAbilityCopy = ((ModalDoubleFacesCard) card).getLeftHalfCard().getSpellAbility().copy();
} else if (((ModalDoubleFacesCard) card).getRightHalfCard().getName().equals(abilityName)) {
spellAbilityCopy = ((ModalDoubleFacesCard) card).getRightHalfCard().getSpellAbility().copy();
}
} else {
spellAbilityCopy = card.getSpellAbility().copy();
}
if (spellAbilityCopy == null) {
return null;
}
spellAbilityCopy.setId(this.getId());
spellAbilityCopy.getManaCosts().clear();
spellAbilityCopy.getManaCostsToPay().clear();
spellAbilityCopy.getCosts().addAll(this.getCosts().copy());
spellAbilityCopy.addCost(this.getManaCosts().copy());
spellAbilityCopy.setSpellAbilityCastMode(this.getSpellAbilityCastMode());
spellAbilityToResolve = spellAbilityCopy;
} }
return spellAbilityToResolve.getCosts();
} }
return spellAbilityToResolve;
}
@Override @Override
public Costs<Cost> getCosts() { public ForetellCostAbility copy() {
if (spellAbilityToResolve == null) { return new ForetellCostAbility(this);
return super.getCosts();
} }
return spellAbilityToResolve.getCosts();
}
@Override @Override
public ForetellCostAbility copy() { public String getRule(boolean all) {
return new ForetellCostAbility(this); return "";
} }
@Override /**
public String getRule(boolean all) { * Used for split card in PlayerImpl method:
return ""; * getOtherUseableActivatedAbilities
} *
* @param abilityName
*/
public void setAbilityName(String abilityName) {
this.abilityName = abilityName;
}
/**
* Used for split card in PlayerImpl method:
* getOtherUseableActivatedAbilities
*
* @param abilityName
*/
public void setAbilityName(String abilityName) {
this.abilityName = abilityName;
} }
} }