From 1c2f8f4caa8d7310ad231687cbbe22dc14de2b53 Mon Sep 17 00:00:00 2001 From: jeffwadsworth Date: Wed, 3 Feb 2021 15:21:18 -0600 Subject: [PATCH] - little refactor of Ethereal Valkyrie --- .../src/mage/cards/e/EtherealValkyrie.java | 186 +------- .../abilities/keyword/ForetellAbility.java | 437 +++++++++--------- 2 files changed, 222 insertions(+), 401 deletions(-) diff --git a/Mage.Sets/src/mage/cards/e/EtherealValkyrie.java b/Mage.Sets/src/mage/cards/e/EtherealValkyrie.java index 88c8983b26..35b514066d 100644 --- a/Mage.Sets/src/mage/cards/e/EtherealValkyrie.java +++ b/Mage.Sets/src/mage/cards/e/EtherealValkyrie.java @@ -4,13 +4,8 @@ import java.util.UUID; import mage.MageInt; import mage.MageObjectReference; import mage.abilities.Ability; -import mage.abilities.ActivatedAbility; -import mage.abilities.SpellAbility; import mage.abilities.TriggeredAbilityImpl; -import mage.abilities.costs.Cost; -import mage.abilities.costs.Costs; -import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.effects.ContinuousEffectImpl; +import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; import mage.abilities.keyword.FlyingAbility; @@ -18,19 +13,11 @@ import mage.abilities.keyword.ForetellAbility; import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.cards.ModalDoubleFacesCard; -import mage.cards.SplitCard; import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.Layer; import mage.constants.Outcome; -import mage.constants.SpellAbilityCastMode; -import mage.constants.SpellAbilityType; -import mage.constants.SubLayer; import mage.constants.SubType; import mage.constants.Zone; import mage.filter.FilterCard; -import mage.game.ExileZone; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; @@ -149,176 +136,11 @@ class EtherealValkyrieEffect extends OneShotEffect { foretellAbility.setControllerId(exileCard.getOwnerId()); game.getState().addOtherAbility(exileCard, foretellAbility); 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 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 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; - } - -} +} \ No newline at end of file diff --git a/Mage/src/main/java/mage/abilities/keyword/ForetellAbility.java b/Mage/src/main/java/mage/abilities/keyword/ForetellAbility.java index 812471ee11..dfd7437e63 100644 --- a/Mage/src/main/java/mage/abilities/keyword/ForetellAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/ForetellAbility.java @@ -74,265 +74,264 @@ public class ForetellAbility extends SpecialAction { @Override public String getRule() { - return "Foretell " + foretellCost + " (During your turn, " + - "you may pay {2} and exile this card from your hand face down. " + - "Cast it on a later turn for its foretell cost.)"; - } -} - -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; + return "Foretell " + foretellCost + " (During your turn, " + + "you may pay {2} and exile this card from your hand face down. " + + "Cast it on a later turn for its foretell cost.)"; } - public ForetellExileEffect(final ForetellExileEffect effect) { - super(effect); - this.card = effect.card; - this.foretellCost = effect.foretellCost; + public 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) { + 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 ForetellExileEffect copy() { - return new ForetellExileEffect(this); - } + public class ForetellLookAtCardEffect extends AsThoughEffectImpl { - @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); + public ForetellLookAtCardEffect() { + super(AsThoughEffectType.LOOK_AT_FACE_DOWN, Duration.EndOfGame, Outcome.AIDontUseIt); + } - // foretell turn number shows up on exile window - Effect effect = new ExileTargetEffect(exileId, " Foretell Turn Number: " + game.getTurnNum()); + public ForetellLookAtCardEffect(final ForetellLookAtCardEffect effect) { + super(effect); + } - // 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); + @Override + public boolean apply(Game game, Ability source) { return true; } - return false; - } -} -class ForetellLookAtCardEffect extends AsThoughEffectImpl { + @Override + public ForetellLookAtCardEffect copy() { + return new ForetellLookAtCardEffect(this); + } - public ForetellLookAtCardEffect() { - super(AsThoughEffectType.LOOK_AT_FACE_DOWN, Duration.EndOfGame, Outcome.AIDontUseIt); - } - - public ForetellLookAtCardEffect(final ForetellLookAtCardEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - return true; - } - - @Override - 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; + @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()); } - 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) { - super(effect); - this.mor = effect.mor; - } + public class ForetellAddCostEffect extends ContinuousEffectImpl { - @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(); + 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); } - return true; } - @Override - public ForetellAddCostEffect copy() { - return new ForetellAddCostEffect(this); - } -} + public class ForetellCostAbility extends SpellAbility { -class ForetellCostAbility extends SpellAbility { + private String abilityName; + private SpellAbility spellAbilityToResolve; - 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(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; + } - public ForetellCostAbility(final ForetellCostAbility ability) { - super(ability); - this.spellAbilityType = ability.spellAbilityType; - this.abilityName = ability.abilityName; - this.spellAbilityToResolve = ability.spellAbilityToResolve; - } + @Override + public 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 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 - public ActivationStatus canActivate(UUID playerId, Game game) { - if (super.canActivate(playerId, game).canActivate()) { + @Override + public SpellAbility getSpellAbilityToResolve(Game game) { Card card = game.getCard(getSourceId()); 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); + 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(); } - } 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); + 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 card.getSpellAbility().canActivate(playerId, game); } + return spellAbilityToResolve; } - return ActivationStatus.getFalse(); - } - @Override - public SpellAbility getSpellAbilityToResolve(Game game) { - Card card = game.getCard(getSourceId()); - if (card != null) { + @Override + public Costs getCosts() { 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 super.getCosts(); } + return spellAbilityToResolve.getCosts(); } - return spellAbilityToResolve; - } - @Override - public Costs getCosts() { - if (spellAbilityToResolve == null) { - return super.getCosts(); + @Override + public ForetellCostAbility copy() { + return new ForetellCostAbility(this); } - return spellAbilityToResolve.getCosts(); - } - @Override - public ForetellCostAbility copy() { - return new ForetellCostAbility(this); - } + @Override + public String getRule(boolean all) { + return ""; + } - @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; + } - /** - * Used for split card in PlayerImpl method: - * getOtherUseableActivatedAbilities - * - * @param abilityName - */ - public void setAbilityName(String abilityName) { - this.abilityName = abilityName; } - }