diff --git a/Mage.Sets/src/mage/cards/a/AnimatingFaerie.java b/Mage.Sets/src/mage/cards/a/AnimatingFaerie.java index d5845a452cc..64f2f4ece3f 100644 --- a/Mage.Sets/src/mage/cards/a/AnimatingFaerie.java +++ b/Mage.Sets/src/mage/cards/a/AnimatingFaerie.java @@ -43,16 +43,16 @@ public final class AnimatingFaerie extends AdventureCard { // Bring to Life // Target noncreature artifact you control becomes a 0/0 artifact creature. Put four +1/+1 counters on it. - this.getAdventureSpellAbility().addEffect(new AddCardTypeTargetEffect( + this.getSpellCard().getSpellAbility().addEffect(new AddCardTypeTargetEffect( Duration.EndOfGame, CardType.ARTIFACT, CardType.CREATURE ).setText("Target noncreature artifact you control becomes")); - this.getAdventureSpellAbility().addEffect(new SetPowerToughnessTargetEffect( + this.getSpellCard().getSpellAbility().addEffect(new SetPowerToughnessTargetEffect( 0, 0, Duration.EndOfGame ).setText("a 0/0 artifact creature.")); - this.getAdventureSpellAbility().addEffect(new AddCountersTargetEffect( + this.getSpellCard().getSpellAbility().addEffect(new AddCountersTargetEffect( CounterType.P1P1.createInstance(4) ).setText("Put four +1/+1 counters on it.")); - this.getAdventureSpellAbility().addTarget(new TargetPermanent(filter)); + this.getSpellCard().getSpellAbility().addTarget(new TargetPermanent(filter)); } private AnimatingFaerie(final AnimatingFaerie card) { diff --git a/Mage.Sets/src/mage/cards/a/ArdenvaleTactician.java b/Mage.Sets/src/mage/cards/a/ArdenvaleTactician.java index cfafc8aac40..bc14efe0b1a 100644 --- a/Mage.Sets/src/mage/cards/a/ArdenvaleTactician.java +++ b/Mage.Sets/src/mage/cards/a/ArdenvaleTactician.java @@ -29,8 +29,8 @@ public final class ArdenvaleTactician extends AdventureCard { // Dizzying Swoop // Tap up to two target creatures. - this.getAdventureSpellAbility().addEffect(new TapTargetEffect()); - this.getAdventureSpellAbility().addTarget(new TargetCreaturePermanent(0, 2)); + this.getSpellCard().getSpellAbility().addEffect(new TapTargetEffect()); + this.getSpellCard().getSpellAbility().addTarget(new TargetCreaturePermanent(0, 2)); } private ArdenvaleTactician(final ArdenvaleTactician card) { diff --git a/Mage.Sets/src/mage/cards/b/BeanstalkGiant.java b/Mage.Sets/src/mage/cards/b/BeanstalkGiant.java index 18cd2db3f34..533ba125904 100644 --- a/Mage.Sets/src/mage/cards/b/BeanstalkGiant.java +++ b/Mage.Sets/src/mage/cards/b/BeanstalkGiant.java @@ -37,7 +37,7 @@ public final class BeanstalkGiant extends AdventureCard { // Fertile Footsteps // Search your library for a basic land card, put it onto the battlefield, then shuffle your library. - this.getAdventureSpellAbility().addEffect( + this.getSpellCard().getSpellAbility().addEffect( new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(StaticFilters.FILTER_CARD_BASIC_LAND)) ); } diff --git a/Mage.Sets/src/mage/cards/b/BolassCitadel.java b/Mage.Sets/src/mage/cards/b/BolassCitadel.java index b66b461f2bf..32da651d46c 100644 --- a/Mage.Sets/src/mage/cards/b/BolassCitadel.java +++ b/Mage.Sets/src/mage/cards/b/BolassCitadel.java @@ -1,118 +1,122 @@ -package mage.cards.b; - -import mage.abilities.Ability; -import mage.abilities.common.SimpleActivatedAbility; -import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.costs.Costs; -import mage.abilities.costs.CostsImpl; -import mage.abilities.costs.common.PayLifeCost; -import mage.abilities.costs.common.SacrificeTargetCost; -import mage.abilities.costs.common.TapSourceCost; -import mage.abilities.effects.AsThoughEffectImpl; -import mage.abilities.effects.common.LoseLifeOpponentsEffect; -import mage.abilities.effects.common.continuous.LookAtTopCardOfLibraryAnyTimeEffect; -import mage.cards.Card; -import mage.cards.CardImpl; -import mage.cards.CardSetInfo; -import mage.constants.*; -import mage.filter.common.FilterControlledPermanent; -import mage.filter.predicate.Predicates; -import mage.filter.predicate.mageobject.CardTypePredicate; -import mage.game.Game; -import mage.players.Player; -import mage.target.common.TargetControlledPermanent; - -import java.util.UUID; -import mage.abilities.costs.Cost; - -/** - * @author jeffwadsworth - */ -public final class BolassCitadel extends CardImpl { - - private static final FilterControlledPermanent filter = new FilterControlledPermanent("nonland permanents"); - - static { - filter.add(Predicates.not(new CardTypePredicate(CardType.LAND))); - } - - public BolassCitadel(UUID ownerId, CardSetInfo setInfo) { - super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{3}{B}{B}{B}"); - - this.addSuperType(SuperType.LEGENDARY); - - // You may look at the top card of your library any time. - this.addAbility(new SimpleStaticAbility(new LookAtTopCardOfLibraryAnyTimeEffect())); - - // You may play the top card of your library. If you cast a spell this way, pay life equal to its converted mana cost rather than pay its mana cost. - this.addAbility(new SimpleStaticAbility(new BolassCitadelPlayTheTopCardEffect())); - - // {T}, Sacrifice ten nonland permanents: Each opponent loses 10 life. - Ability ability = new SimpleActivatedAbility(new LoseLifeOpponentsEffect(10), new TapSourceCost()); - ability.addCost(new SacrificeTargetCost(new TargetControlledPermanent( - 10, 10, filter, true - ))); - this.addAbility(ability); - } - - private BolassCitadel(final BolassCitadel card) { - super(card); - } - - @Override - public BolassCitadel copy() { - return new BolassCitadel(this); - } -} - -class BolassCitadelPlayTheTopCardEffect extends AsThoughEffectImpl { - - BolassCitadelPlayTheTopCardEffect() { - super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, - Duration.WhileOnBattlefield, Outcome.AIDontUseIt); // AI will need help with this - staticText = "You may play the top card of your library. If you cast a spell this way, " - + "pay life equal to its converted mana cost rather than pay its mana cost."; - } - - private BolassCitadelPlayTheTopCardEffect(final BolassCitadelPlayTheTopCardEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - return true; - } - - @Override - public BolassCitadelPlayTheTopCardEffect copy() { - return new BolassCitadelPlayTheTopCardEffect(this); - } - - @Override - public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { - Card cardOnTop = game.getCard(objectId); - if (cardOnTop == null) { - return false; - } - if (affectedControllerId.equals(source.getControllerId()) - && cardOnTop.isOwnedBy(source.getControllerId())) { - Player controller = game.getPlayer(cardOnTop.getOwnerId()); - if (controller != null - && cardOnTop.equals(controller.getLibrary().getFromTop(game))) { - // add the life cost first - PayLifeCost cost = new PayLifeCost(cardOnTop.getManaCost().convertedManaCost()); - Costs costs = new CostsImpl(); - costs.add(cost); - // check for additional costs that must be paid - if (cardOnTop.getSpellAbility() != null) { - for (Cost additionalCost : cardOnTop.getSpellAbility().getCosts()) { - costs.add(additionalCost); - } - } - controller.setCastSourceIdWithAlternateMana(cardOnTop.getId(), null, costs); - return true; - } - } - return false; - } -} +package mage.cards.b; + +import mage.abilities.Ability; +import mage.abilities.ActivatedAbility; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.costs.Costs; +import mage.abilities.costs.CostsImpl; +import mage.abilities.costs.common.PayLifeCost; +import mage.abilities.costs.common.SacrificeTargetCost; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.effects.AsThoughEffectImpl; +import mage.abilities.effects.common.LoseLifeOpponentsEffect; +import mage.abilities.effects.common.continuous.LookAtTopCardOfLibraryAnyTimeEffect; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.filter.common.FilterControlledPermanent; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.mageobject.CardTypePredicate; +import mage.game.Game; +import mage.players.Player; +import mage.target.common.TargetControlledPermanent; + +import java.util.UUID; +import mage.abilities.costs.Cost; + +/** + * @author jeffwadsworth + */ +public final class BolassCitadel extends CardImpl { + + private static final FilterControlledPermanent filter = new FilterControlledPermanent("nonland permanents"); + + static { + filter.add(Predicates.not(new CardTypePredicate(CardType.LAND))); + } + + public BolassCitadel(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{3}{B}{B}{B}"); + + this.addSuperType(SuperType.LEGENDARY); + + // You may look at the top card of your library any time. + this.addAbility(new SimpleStaticAbility(new LookAtTopCardOfLibraryAnyTimeEffect())); + + // You may play the top card of your library. If you cast a spell this way, pay life equal to its converted mana cost rather than pay its mana cost. + this.addAbility(new SimpleStaticAbility(new BolassCitadelPlayTheTopCardEffect())); + + // {T}, Sacrifice ten nonland permanents: Each opponent loses 10 life. + Ability ability = new SimpleActivatedAbility(new LoseLifeOpponentsEffect(10), new TapSourceCost()); + ability.addCost(new SacrificeTargetCost(new TargetControlledPermanent( + 10, 10, filter, true + ))); + this.addAbility(ability); + } + + private BolassCitadel(final BolassCitadel card) { + super(card); + } + + @Override + public BolassCitadel copy() { + return new BolassCitadel(this); + } +} + +class BolassCitadelPlayTheTopCardEffect extends AsThoughEffectImpl { + + BolassCitadelPlayTheTopCardEffect() { + super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, + Duration.WhileOnBattlefield, Outcome.AIDontUseIt); // AI will need help with this + staticText = "You may play the top card of your library. If you cast a spell this way, " + + "pay life equal to its converted mana cost rather than pay its mana cost."; + } + + private BolassCitadelPlayTheTopCardEffect(final BolassCitadelPlayTheTopCardEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } + + @Override + public BolassCitadelPlayTheTopCardEffect copy() { + return new BolassCitadelPlayTheTopCardEffect(this); + } + + @Override + public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { + return applies(objectId, null, source, game, affectedControllerId); + } + + @Override + public boolean applies(UUID objectId, Ability affectedAbility, Ability source, Game game, UUID playerId) { + Card cardOnTop = game.getCard(objectId); + if (cardOnTop == null) { + return false; + } + if (playerId.equals(source.getControllerId()) + && cardOnTop.isOwnedBy(source.getControllerId())) { + Player controller = game.getPlayer(cardOnTop.getOwnerId()); + if (controller != null + && cardOnTop.equals(controller.getLibrary().getFromTop(game))) { + if (affectedAbility instanceof ActivatedAbility) { + ActivatedAbility activatedAbility = (ActivatedAbility) affectedAbility; + // add the life cost first + PayLifeCost cost = new PayLifeCost(activatedAbility.getManaCosts().convertedManaCost()); + Costs costs = new CostsImpl(); + costs.add(cost); + costs.addAll(activatedAbility.getCosts()); + controller.setCastSourceIdWithAlternateMana(activatedAbility.getSourceId(), null, costs); + return true; + } + } + } + return false; + } +} diff --git a/Mage.Sets/src/mage/cards/b/BonecrusherGiant.java b/Mage.Sets/src/mage/cards/b/BonecrusherGiant.java index 5d33e4e2289..8a756691c2e 100644 --- a/Mage.Sets/src/mage/cards/b/BonecrusherGiant.java +++ b/Mage.Sets/src/mage/cards/b/BonecrusherGiant.java @@ -34,9 +34,9 @@ public final class BonecrusherGiant extends AdventureCard { // Stomp // Damage can’t be prevented this turn. Stomp deals 2 damage to any target. - this.getAdventureSpellAbility().addEffect(new StompEffect()); - this.getAdventureSpellAbility().addEffect(new DamageTargetEffect(2)); - this.getAdventureSpellAbility().addTarget(new TargetAnyTarget()); + this.getSpellCard().getSpellAbility().addEffect(new StompEffect()); + this.getSpellCard().getSpellAbility().addEffect(new DamageTargetEffect(2)); + this.getSpellCard().getSpellAbility().addTarget(new TargetAnyTarget()); } private BonecrusherGiant(final BonecrusherGiant card) { diff --git a/Mage.Sets/src/mage/cards/b/BrazenBorrower.java b/Mage.Sets/src/mage/cards/b/BrazenBorrower.java index 14bc967401f..9a7d91a18c7 100644 --- a/Mage.Sets/src/mage/cards/b/BrazenBorrower.java +++ b/Mage.Sets/src/mage/cards/b/BrazenBorrower.java @@ -48,8 +48,8 @@ public final class BrazenBorrower extends AdventureCard { // Petty Theft // Return target nonland permanent an opponent controls to its owner's hand. - this.getAdventureSpellAbility().addEffect(new ReturnToHandTargetEffect()); - this.getAdventureSpellAbility().addTarget(new TargetPermanent(filter)); + this.getSpellCard().getSpellAbility().addEffect(new ReturnToHandTargetEffect()); + this.getSpellCard().getSpellAbility().addTarget(new TargetPermanent(filter)); } private BrazenBorrower(final BrazenBorrower card) { diff --git a/Mage.Sets/src/mage/cards/c/CuriousPair.java b/Mage.Sets/src/mage/cards/c/CuriousPair.java index f63363f9f3f..febc9db70ed 100644 --- a/Mage.Sets/src/mage/cards/c/CuriousPair.java +++ b/Mage.Sets/src/mage/cards/c/CuriousPair.java @@ -25,7 +25,7 @@ public final class CuriousPair extends AdventureCard { // Treats to Share // Create a Food token. - this.getAdventureSpellAbility().addEffect(new CreateTokenEffect(new FoodToken())); + this.getSpellCard().getSpellAbility().addEffect(new CreateTokenEffect(new FoodToken())); } private CuriousPair(final CuriousPair card) { diff --git a/Mage.Sets/src/mage/cards/e/EmberethShieldbreaker.java b/Mage.Sets/src/mage/cards/e/EmberethShieldbreaker.java index 3e1b7bf98f7..fe781fc842c 100644 --- a/Mage.Sets/src/mage/cards/e/EmberethShieldbreaker.java +++ b/Mage.Sets/src/mage/cards/e/EmberethShieldbreaker.java @@ -25,8 +25,8 @@ public final class EmberethShieldbreaker extends AdventureCard { // Battle Display // Destroy target artifact. - this.getAdventureSpellAbility().addEffect(new DestroyTargetEffect()); - this.getAdventureSpellAbility().addTarget(new TargetArtifactPermanent()); + this.getSpellCard().getSpellAbility().addEffect(new DestroyTargetEffect()); + this.getSpellCard().getSpellAbility().addTarget(new TargetArtifactPermanent()); } private EmberethShieldbreaker(final EmberethShieldbreaker card) { diff --git a/Mage.Sets/src/mage/cards/f/FaeOfWishes.java b/Mage.Sets/src/mage/cards/f/FaeOfWishes.java index d6aa24c094c..94ef4621340 100644 --- a/Mage.Sets/src/mage/cards/f/FaeOfWishes.java +++ b/Mage.Sets/src/mage/cards/f/FaeOfWishes.java @@ -42,7 +42,7 @@ public final class FaeOfWishes extends AdventureCard { // Granted // You may choose a noncreature card you own from outside the game, reveal it, and put it into your hand. - this.getAdventureSpellAbility().addEffect(new WishEffect(StaticFilters.FILTER_CARD_A_NON_LAND)); + this.getSpellCard().getSpellAbility().addEffect(new WishEffect(StaticFilters.FILTER_CARD_A_NON_LAND)); } private FaeOfWishes(final FaeOfWishes card) { diff --git a/Mage.Sets/src/mage/cards/f/FaerieGuidemother.java b/Mage.Sets/src/mage/cards/f/FaerieGuidemother.java index 03d51364ce6..24425fc8f13 100644 --- a/Mage.Sets/src/mage/cards/f/FaerieGuidemother.java +++ b/Mage.Sets/src/mage/cards/f/FaerieGuidemother.java @@ -30,13 +30,13 @@ public final class FaerieGuidemother extends AdventureCard { // Gift of the Fae // Target creature gets +2/+1 and gains flying until end of turn. - this.getAdventureSpellAbility().addEffect(new BoostTargetEffect( + this.getSpellCard().getSpellAbility().addEffect(new BoostTargetEffect( 2, 1, Duration.EndOfTurn ).setText("Target creature gets +2/+1")); - this.getAdventureSpellAbility().addEffect(new GainAbilityTargetEffect( + this.getSpellCard().getSpellAbility().addEffect(new GainAbilityTargetEffect( FlyingAbility.getInstance(), Duration.EndOfTurn ).setText("and gains flying until end of turn")); - this.getAdventureSpellAbility().addTarget(new TargetCreaturePermanent()); + this.getSpellCard().getSpellAbility().addTarget(new TargetCreaturePermanent()); } private FaerieGuidemother(final FaerieGuidemother card) { diff --git a/Mage.Sets/src/mage/cards/f/FlaxenIntruder.java b/Mage.Sets/src/mage/cards/f/FlaxenIntruder.java index 8e0659ecd7a..105e7d16c03 100644 --- a/Mage.Sets/src/mage/cards/f/FlaxenIntruder.java +++ b/Mage.Sets/src/mage/cards/f/FlaxenIntruder.java @@ -44,7 +44,7 @@ public final class FlaxenIntruder extends AdventureCard { // Welcome Home // Create three 2/2 green Bear creature tokens. - this.getAdventureSpellAbility().addEffect(new CreateTokenEffect(new BearToken(), 3)); + this.getSpellCard().getSpellAbility().addEffect(new CreateTokenEffect(new BearToken(), 3)); } private FlaxenIntruder(final FlaxenIntruder card) { diff --git a/Mage.Sets/src/mage/cards/f/FoulmireKnight.java b/Mage.Sets/src/mage/cards/f/FoulmireKnight.java index 4eb1a389b86..0e4756fb470 100644 --- a/Mage.Sets/src/mage/cards/f/FoulmireKnight.java +++ b/Mage.Sets/src/mage/cards/f/FoulmireKnight.java @@ -29,8 +29,8 @@ public final class FoulmireKnight extends AdventureCard { // Profane Insight // You draw a card and you lose 1 life. - this.getAdventureSpellAbility().addEffect(new DrawCardSourceControllerEffect(1).setText("You draw a card and")); - this.getAdventureSpellAbility().addEffect(new LoseLifeSourceControllerEffect(1)); + this.getSpellCard().getSpellAbility().addEffect(new DrawCardSourceControllerEffect(1).setText("You draw a card and")); + this.getSpellCard().getSpellAbility().addEffect(new LoseLifeSourceControllerEffect(1)); } private FoulmireKnight(final FoulmireKnight card) { diff --git a/Mage.Sets/src/mage/cards/g/GarenbrigCarver.java b/Mage.Sets/src/mage/cards/g/GarenbrigCarver.java index 311deb9a14f..403e453f53e 100644 --- a/Mage.Sets/src/mage/cards/g/GarenbrigCarver.java +++ b/Mage.Sets/src/mage/cards/g/GarenbrigCarver.java @@ -26,8 +26,8 @@ public final class GarenbrigCarver extends AdventureCard { // Shield's Might // Target creature gets +2/+2 until end of turn. - this.getAdventureSpellAbility().addEffect(new BoostTargetEffect(2, 2, Duration.EndOfTurn)); - this.getAdventureSpellAbility().addTarget(new TargetCreaturePermanent()); + this.getSpellCard().getSpellAbility().addEffect(new BoostTargetEffect(2, 2, Duration.EndOfTurn)); + this.getSpellCard().getSpellAbility().addTarget(new TargetCreaturePermanent()); } private GarenbrigCarver(final GarenbrigCarver card) { diff --git a/Mage.Sets/src/mage/cards/g/GiantKiller.java b/Mage.Sets/src/mage/cards/g/GiantKiller.java index 27ea0041560..07f05204659 100644 --- a/Mage.Sets/src/mage/cards/g/GiantKiller.java +++ b/Mage.Sets/src/mage/cards/g/GiantKiller.java @@ -47,8 +47,8 @@ public final class GiantKiller extends AdventureCard { // Chop Down // Destroy target creature with power 4 or greater. - this.getAdventureSpellAbility().addEffect(new DestroyTargetEffect()); - this.getAdventureSpellAbility().addTarget(new TargetPermanent(filter)); + this.getSpellCard().getSpellAbility().addEffect(new DestroyTargetEffect()); + this.getSpellCard().getSpellAbility().addTarget(new TargetPermanent(filter)); } private GiantKiller(final GiantKiller card) { diff --git a/Mage.Sets/src/mage/cards/h/HypnoticSprite.java b/Mage.Sets/src/mage/cards/h/HypnoticSprite.java index 40868c5afb0..89b51318570 100644 --- a/Mage.Sets/src/mage/cards/h/HypnoticSprite.java +++ b/Mage.Sets/src/mage/cards/h/HypnoticSprite.java @@ -37,8 +37,8 @@ public final class HypnoticSprite extends AdventureCard { // Mesmeric Glare // Counter target spell with converted mana cost 3 or less. - this.getAdventureSpellAbility().addEffect(new CounterTargetEffect()); - this.getAdventureSpellAbility().addTarget(new TargetSpell(filter)); + this.getSpellCard().getSpellAbility().addEffect(new CounterTargetEffect()); + this.getSpellCard().getSpellAbility().addTarget(new TargetSpell(filter)); } private HypnoticSprite(final HypnoticSprite card) { diff --git a/Mage.Sets/src/mage/cards/l/LonesomeUnicorn.java b/Mage.Sets/src/mage/cards/l/LonesomeUnicorn.java index ead17bfb3ea..fefbe07474b 100644 --- a/Mage.Sets/src/mage/cards/l/LonesomeUnicorn.java +++ b/Mage.Sets/src/mage/cards/l/LonesomeUnicorn.java @@ -28,7 +28,7 @@ public final class LonesomeUnicorn extends AdventureCard { // Rider in Need // Create a 2/2 white Knight creature token with vigilance. - this.getAdventureSpellAbility().addEffect(new CreateTokenEffect(new KnightToken())); + this.getSpellCard().getSpellAbility().addEffect(new CreateTokenEffect(new KnightToken())); } private LonesomeUnicorn(final LonesomeUnicorn card) { diff --git a/Mage.Sets/src/mage/cards/l/LovestruckBeast.java b/Mage.Sets/src/mage/cards/l/LovestruckBeast.java index c38b70ed3cb..8c4904ccfb0 100644 --- a/Mage.Sets/src/mage/cards/l/LovestruckBeast.java +++ b/Mage.Sets/src/mage/cards/l/LovestruckBeast.java @@ -39,7 +39,7 @@ public final class LovestruckBeast extends AdventureCard { // Heart's Desire // Create a 1/1 white Human creature token. - this.getAdventureSpellAbility().addEffect(new CreateTokenEffect(new HumanToken())); + this.getSpellCard().getSpellAbility().addEffect(new CreateTokenEffect(new HumanToken())); } private LovestruckBeast(final LovestruckBeast card) { diff --git a/Mage.Sets/src/mage/cards/m/MerchantOfTheVale.java b/Mage.Sets/src/mage/cards/m/MerchantOfTheVale.java index f89f695ad70..be27716805d 100644 --- a/Mage.Sets/src/mage/cards/m/MerchantOfTheVale.java +++ b/Mage.Sets/src/mage/cards/m/MerchantOfTheVale.java @@ -36,7 +36,7 @@ public final class MerchantOfTheVale extends AdventureCard { // Haggle // You may discard a card. If you do, draw a card. - this.getAdventureSpellAbility().addEffect(new DoIfCostPaid( + this.getSpellCard().getSpellAbility().addEffect(new DoIfCostPaid( new DrawCardSourceControllerEffect(1), new DiscardCardCost() )); } diff --git a/Mage.Sets/src/mage/cards/m/MerfolkSecretkeeper.java b/Mage.Sets/src/mage/cards/m/MerfolkSecretkeeper.java index fcc7b742a14..291c438190b 100644 --- a/Mage.Sets/src/mage/cards/m/MerfolkSecretkeeper.java +++ b/Mage.Sets/src/mage/cards/m/MerfolkSecretkeeper.java @@ -25,8 +25,8 @@ public final class MerfolkSecretkeeper extends AdventureCard { // Venture Deeper // Target player puts the top four cards of their library into their graveyard. - this.getAdventureSpellAbility().addEffect(new PutLibraryIntoGraveTargetEffect(4)); - this.getAdventureSpellAbility().addTarget(new TargetPlayer()); + this.getSpellCard().getSpellAbility().addEffect(new PutLibraryIntoGraveTargetEffect(4)); + this.getSpellCard().getSpellAbility().addTarget(new TargetPlayer()); } private MerfolkSecretkeeper(final MerfolkSecretkeeper card) { diff --git a/Mage.Sets/src/mage/cards/m/MurderousRider.java b/Mage.Sets/src/mage/cards/m/MurderousRider.java index 24cf1b16f90..f32b9e0c274 100644 --- a/Mage.Sets/src/mage/cards/m/MurderousRider.java +++ b/Mage.Sets/src/mage/cards/m/MurderousRider.java @@ -37,11 +37,11 @@ public final class MurderousRider extends AdventureCard { // Swift End // Destroy target creature or planeswalker. You lose 2 life. - this.getAdventureSpellAbility().addEffect(new DestroyTargetEffect()); - this.getAdventureSpellAbility().addEffect( + this.getSpellCard().getSpellAbility().addEffect(new DestroyTargetEffect()); + this.getSpellCard().getSpellAbility().addEffect( new LoseLifeSourceControllerEffect(2).setText("You lose 2 life.") ); - this.getAdventureSpellAbility().addTarget(new TargetCreatureOrPlaneswalker()); + this.getSpellCard().getSpellAbility().addTarget(new TargetCreatureOrPlaneswalker()); } private MurderousRider(final MurderousRider card) { diff --git a/Mage.Sets/src/mage/cards/o/OakhameRanger.java b/Mage.Sets/src/mage/cards/o/OakhameRanger.java index ce7ff7ddd5d..9ebc7bb6597 100644 --- a/Mage.Sets/src/mage/cards/o/OakhameRanger.java +++ b/Mage.Sets/src/mage/cards/o/OakhameRanger.java @@ -34,7 +34,7 @@ public final class OakhameRanger extends AdventureCard { // Bring Back // Create two 1/1 white Human creature tokens. - this.getAdventureSpellAbility().addEffect(new CreateTokenEffect(new HumanToken(), 2)); + this.getSpellCard().getSpellAbility().addEffect(new CreateTokenEffect(new HumanToken(), 2)); } private OakhameRanger(final OakhameRanger card) { diff --git a/Mage.Sets/src/mage/cards/o/OrderOfMidnight.java b/Mage.Sets/src/mage/cards/o/OrderOfMidnight.java index ef5a0030c59..9829efb2a30 100644 --- a/Mage.Sets/src/mage/cards/o/OrderOfMidnight.java +++ b/Mage.Sets/src/mage/cards/o/OrderOfMidnight.java @@ -34,8 +34,8 @@ public final class OrderOfMidnight extends AdventureCard { // Alter Fate // Return target creature card from your graveyard to your hand. - this.getAdventureSpellAbility().addEffect(new ReturnFromGraveyardToHandTargetEffect()); - this.getAdventureSpellAbility().addTarget(new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD)); + this.getSpellCard().getSpellAbility().addEffect(new ReturnFromGraveyardToHandTargetEffect()); + this.getSpellCard().getSpellAbility().addTarget(new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD)); } private OrderOfMidnight(final OrderOfMidnight card) { diff --git a/Mage.Sets/src/mage/cards/q/QueenOfIce.java b/Mage.Sets/src/mage/cards/q/QueenOfIce.java index 0bbbf185f4b..d1fe38e761c 100644 --- a/Mage.Sets/src/mage/cards/q/QueenOfIce.java +++ b/Mage.Sets/src/mage/cards/q/QueenOfIce.java @@ -39,10 +39,10 @@ public final class QueenOfIce extends AdventureCard { // Rage of Winter // Tap target creature. It doesn’t untap during its controller’s next untap step. - this.getAdventureSpellAbility().addEffect(new TapTargetEffect()); - this.getAdventureSpellAbility().addEffect(new DontUntapInControllersNextUntapStepTargetEffect() + this.getSpellCard().getSpellAbility().addEffect(new TapTargetEffect()); + this.getSpellCard().getSpellAbility().addEffect(new DontUntapInControllersNextUntapStepTargetEffect() .setText("It doesn't untap during its controller's next untap step")); - this.getAdventureSpellAbility().addTarget(new TargetCreaturePermanent()); + this.getSpellCard().getSpellAbility().addTarget(new TargetCreaturePermanent()); } private QueenOfIce(final QueenOfIce card) { diff --git a/Mage.Sets/src/mage/cards/r/RealmCloakedGiant.java b/Mage.Sets/src/mage/cards/r/RealmCloakedGiant.java index ea2c8bdd571..b0326ebfbba 100644 --- a/Mage.Sets/src/mage/cards/r/RealmCloakedGiant.java +++ b/Mage.Sets/src/mage/cards/r/RealmCloakedGiant.java @@ -37,7 +37,7 @@ public final class RealmCloakedGiant extends AdventureCard { // Cast Off // Destroy all non-Giant creatures. - this.getAdventureSpellAbility().addEffect(new DestroyAllEffect(filter)); + this.getSpellCard().getSpellAbility().addEffect(new DestroyAllEffect(filter)); } private RealmCloakedGiant(final RealmCloakedGiant card) { diff --git a/Mage.Sets/src/mage/cards/r/ReaperOfNight.java b/Mage.Sets/src/mage/cards/r/ReaperOfNight.java index 6bdd66b0da2..580020f7741 100644 --- a/Mage.Sets/src/mage/cards/r/ReaperOfNight.java +++ b/Mage.Sets/src/mage/cards/r/ReaperOfNight.java @@ -41,8 +41,8 @@ public final class ReaperOfNight extends AdventureCard { // Harvest Fear // Target opponent discards two cards. - this.getAdventureSpellAbility().addEffect(new DiscardTargetEffect(2)); - this.getAdventureSpellAbility().addTarget(new TargetOpponent()); + this.getSpellCard().getSpellAbility().addEffect(new DiscardTargetEffect(2)); + this.getSpellCard().getSpellAbility().addTarget(new TargetOpponent()); } private ReaperOfNight(final ReaperOfNight card) { diff --git a/Mage.Sets/src/mage/cards/r/RimrockKnight.java b/Mage.Sets/src/mage/cards/r/RimrockKnight.java index 929b181a062..da237fdba34 100644 --- a/Mage.Sets/src/mage/cards/r/RimrockKnight.java +++ b/Mage.Sets/src/mage/cards/r/RimrockKnight.java @@ -30,8 +30,8 @@ public final class RimrockKnight extends AdventureCard { // Boulder Rush // Target creature gets +2/+0 until end of turn. - this.getAdventureSpellAbility().addEffect(new BoostTargetEffect(2, 0, Duration.EndOfTurn)); - this.getAdventureSpellAbility().addTarget(new TargetCreaturePermanent()); + this.getSpellCard().getSpellAbility().addEffect(new BoostTargetEffect(2, 0, Duration.EndOfTurn)); + this.getSpellCard().getSpellAbility().addTarget(new TargetCreaturePermanent()); } private RimrockKnight(final RimrockKnight card) { diff --git a/Mage.Sets/src/mage/cards/r/RosethornAcolyte.java b/Mage.Sets/src/mage/cards/r/RosethornAcolyte.java index f396b6fcd87..354131f372f 100644 --- a/Mage.Sets/src/mage/cards/r/RosethornAcolyte.java +++ b/Mage.Sets/src/mage/cards/r/RosethornAcolyte.java @@ -28,7 +28,7 @@ public final class RosethornAcolyte extends AdventureCard { // Seasonal Ritual // Add one mana of any color. - this.getAdventureSpellAbility().addEffect(new AddManaOfAnyColorEffect()); + this.getSpellCard().getSpellAbility().addEffect(new AddManaOfAnyColorEffect()); } private RosethornAcolyte(final RosethornAcolyte card) { diff --git a/Mage.Sets/src/mage/cards/s/ShepherdOfTheFlock.java b/Mage.Sets/src/mage/cards/s/ShepherdOfTheFlock.java index 37c657ff450..2d08c676f9b 100644 --- a/Mage.Sets/src/mage/cards/s/ShepherdOfTheFlock.java +++ b/Mage.Sets/src/mage/cards/s/ShepherdOfTheFlock.java @@ -25,8 +25,8 @@ public final class ShepherdOfTheFlock extends AdventureCard { // Usher to Safety // Return target permanent you control to its owner’s hand. - this.getAdventureSpellAbility().addEffect(new ReturnToHandTargetEffect()); - this.getAdventureSpellAbility().addTarget(new TargetControlledPermanent()); + this.getSpellCard().getSpellAbility().addEffect(new ReturnToHandTargetEffect()); + this.getSpellCard().getSpellAbility().addTarget(new TargetControlledPermanent()); } private ShepherdOfTheFlock(final ShepherdOfTheFlock card) { diff --git a/Mage.Sets/src/mage/cards/s/SilverflameSquire.java b/Mage.Sets/src/mage/cards/s/SilverflameSquire.java index 1e607a73ff4..6f0f0b7e8ce 100644 --- a/Mage.Sets/src/mage/cards/s/SilverflameSquire.java +++ b/Mage.Sets/src/mage/cards/s/SilverflameSquire.java @@ -27,9 +27,9 @@ public final class SilverflameSquire extends AdventureCard { // On Alert // Target creature gets +2/+2 until end of turn. Untap it. - this.getAdventureSpellAbility().addEffect(new BoostTargetEffect(2, 2, Duration.EndOfTurn)); - this.getAdventureSpellAbility().addEffect(new UntapTargetEffect().setText("Untap it")); - this.getAdventureSpellAbility().addTarget(new TargetCreaturePermanent()); + this.getSpellCard().getSpellAbility().addEffect(new BoostTargetEffect(2, 2, Duration.EndOfTurn)); + this.getSpellCard().getSpellAbility().addEffect(new UntapTargetEffect().setText("Untap it")); + this.getSpellCard().getSpellAbility().addTarget(new TargetCreaturePermanent()); } private SilverflameSquire(final SilverflameSquire card) { diff --git a/Mage.Sets/src/mage/cards/s/SmittenSwordmaster.java b/Mage.Sets/src/mage/cards/s/SmittenSwordmaster.java index 6b8641545e5..673f947b493 100644 --- a/Mage.Sets/src/mage/cards/s/SmittenSwordmaster.java +++ b/Mage.Sets/src/mage/cards/s/SmittenSwordmaster.java @@ -33,7 +33,7 @@ public final class SmittenSwordmaster extends AdventureCard { // Curry Favor // You gain X life and each opponent loses X life, where X is the number of Knights you control. - this.getAdventureSpellAbility().addEffect(new CurryFavorEffect()); + this.getSpellCard().getSpellAbility().addEffect(new CurryFavorEffect()); } private SmittenSwordmaster(final SmittenSwordmaster card) { diff --git a/Mage.Sets/src/mage/cards/t/TuinvaleTreefolk.java b/Mage.Sets/src/mage/cards/t/TuinvaleTreefolk.java index 117552adc9c..ba0d79dc7be 100644 --- a/Mage.Sets/src/mage/cards/t/TuinvaleTreefolk.java +++ b/Mage.Sets/src/mage/cards/t/TuinvaleTreefolk.java @@ -26,8 +26,8 @@ public final class TuinvaleTreefolk extends AdventureCard { // Oaken Boon // Put two +1/+1 counters on target creature. - this.getAdventureSpellAbility().addEffect(new AddCountersTargetEffect(CounterType.P1P1.createInstance(2))); - this.getAdventureSpellAbility().addTarget(new TargetCreaturePermanent()); + this.getSpellCard().getSpellAbility().addEffect(new AddCountersTargetEffect(CounterType.P1P1.createInstance(2))); + this.getSpellCard().getSpellAbility().addTarget(new TargetCreaturePermanent()); } private TuinvaleTreefolk(final TuinvaleTreefolk card) { diff --git a/Mage.Sets/src/mage/sets/ThroneOfEldraine.java b/Mage.Sets/src/mage/sets/ThroneOfEldraine.java index 2a8c83a7695..25112e0fafd 100644 --- a/Mage.Sets/src/mage/sets/ThroneOfEldraine.java +++ b/Mage.Sets/src/mage/sets/ThroneOfEldraine.java @@ -327,8 +327,5 @@ public final class ThroneOfEldraine extends ExpansionSet { cards.add(new SetCardInfo("Worthy Knight", 36, Rarity.RARE, mage.cards.w.WorthyKnight.class)); cards.add(new SetCardInfo("Yorvo, Lord of Garenbrig", 185, Rarity.RARE, mage.cards.y.YorvoLordOfGarenbrig.class)); cards.add(new SetCardInfo("Youthful Knight", 37, Rarity.COMMON, mage.cards.y.YouthfulKnight.class)); - - // This is here to prevent the incomplete adventure implementation from causing problems and will be removed - cards.removeIf(setCardInfo -> AdventureCard.class.isAssignableFrom(setCardInfo.getCardClass())); } } diff --git a/Mage.Sets/src/mage/sets/ThroneOfEldraineCollectorsEdition.java b/Mage.Sets/src/mage/sets/ThroneOfEldraineCollectorsEdition.java index 9606cef6f0c..7edb2592788 100644 --- a/Mage.Sets/src/mage/sets/ThroneOfEldraineCollectorsEdition.java +++ b/Mage.Sets/src/mage/sets/ThroneOfEldraineCollectorsEdition.java @@ -111,8 +111,5 @@ public final class ThroneOfEldraineCollectorsEdition extends ExpansionSet { cards.add(new SetCardInfo("Witch's Vengeance", 358, Rarity.RARE, mage.cards.w.WitchsVengeance.class)); cards.add(new SetCardInfo("Worthy Knight", 341, Rarity.RARE, mage.cards.w.WorthyKnight.class)); cards.add(new SetCardInfo("Yorvo, Lord of Garenbrig", 376, Rarity.RARE, mage.cards.y.YorvoLordOfGarenbrig.class)); - - // This is here to prevent the incomplete adventure implementation from causing problems and will be removed - cards.removeIf(setCardInfo -> AdventureCard.class.isAssignableFrom(setCardInfo.getCardClass())); } } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/cost/adventure/AdventureCardsTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/cost/adventure/AdventureCardsTest.java new file mode 100644 index 00000000000..9e97ad2437b --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/cost/adventure/AdventureCardsTest.java @@ -0,0 +1,535 @@ +package org.mage.test.cards.cost.adventure; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import mage.counters.CounterType; +import mage.game.permanent.Permanent; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +public class AdventureCardsTest extends CardTestPlayerBase { + @Test + public void testCastTreatsToShare() { + /* + * Curious Pair {1}{G} + * Creature — Human Peasant + * 1/3 + * ---- + * Treats to Share {G} + * Sorcery — Adventure + * Create a Food token. + */ + setStrictChooseMode(true); + addCard(Zone.BATTLEFIELD, playerA, "Forest"); + addCard(Zone.HAND, playerA, "Curious Pair"); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Treats to Share"); + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + assertAllCommandsUsed(); + assertHandCount(playerA, 0); + assertPermanentCount(playerA, "Food", 1); + assertExileCount(playerA, "Curious Pair", 1); + assertGraveyardCount(playerA,0); + } + + @Test + public void testCantCastTreatsToShareTwice() { + setStrictChooseMode(true); + addCard(Zone.BATTLEFIELD, playerA, "Forest", 2); + addCard(Zone.HAND, playerA, "Curious Pair"); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Treats to Share"); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Treats to Share"); + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + assertActionsCount(playerA, 1); + assertHandCount(playerA, 0); + assertPermanentCount(playerA, "Food", 1); + assertExileCount(playerA, "Curious Pair", 1); + assertGraveyardCount(playerA,0); + } + + @Test + public void testCastCuriousPair() { + setStrictChooseMode(true); + addCard(Zone.BATTLEFIELD, playerA, "Forest"); + addCard(Zone.BATTLEFIELD, playerA, "Forest"); + addCard(Zone.HAND, playerA, "Curious Pair"); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Curious Pair"); + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + assertAllCommandsUsed(); + assertHandCount(playerA, 0); + assertPermanentCount(playerA, "Food", 0); + assertPermanentCount(playerA, "Curious Pair", 1); + assertExileCount(playerA, "Curious Pair", 0); + assertGraveyardCount(playerA,0); + } + + @Test + public void testCastTreatsToShareAndCuriousPair() { + setStrictChooseMode(true); + addCard(Zone.BATTLEFIELD, playerA, "Forest"); + addCard(Zone.BATTLEFIELD, playerA, "Forest"); + addCard(Zone.BATTLEFIELD, playerA, "Forest"); + addCard(Zone.HAND, playerA, "Curious Pair"); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Treats to Share"); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Curious Pair"); + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + assertAllCommandsUsed(); + assertHandCount(playerA, 0); + assertPermanentCount(playerA, "Food", 1); + assertPermanentCount(playerA, "Curious Pair", 1); + assertExileCount(playerA, "Curious Pair", 0); + assertGraveyardCount(playerA, 0); + } + + @Test + public void testCastTreatsToShareWithEdgewallInnkeeper() { + /* + * Edgewall Innkeeper {G} + * Creature — Human Peasant + * Whenever you cast a creature spell that has an Adventure, draw a card. + * 1/1 + */ + setStrictChooseMode(true); + addCard(Zone.BATTLEFIELD, playerA, "Forest"); + addCard(Zone.BATTLEFIELD, playerA, "Forest"); + addCard(Zone.BATTLEFIELD, playerA, "Forest"); + addCard(Zone.BATTLEFIELD, playerA, "Edgewall Innkeeper"); + addCard(Zone.HAND, playerA, "Curious Pair"); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Treats to Share"); + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + assertAllCommandsUsed(); + assertHandCount(playerA, 0); + assertPermanentCount(playerA, "Food", 1); + assertPermanentCount(playerA, "Curious Pair", 0); + assertExileCount(playerA, "Curious Pair", 1); + assertGraveyardCount(playerA, 0); + } + + @Test + public void testCastCuriousPairWithEdgewallInnkeeper() { + setStrictChooseMode(true); + addCard(Zone.BATTLEFIELD, playerA, "Forest"); + addCard(Zone.BATTLEFIELD, playerA, "Forest"); + addCard(Zone.BATTLEFIELD, playerA, "Edgewall Innkeeper"); + addCard(Zone.HAND, playerA, "Curious Pair"); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Curious Pair"); + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + assertHandCount(playerA, 1); + assertPermanentCount(playerA, "Food", 0); + assertPermanentCount(playerA, "Curious Pair", 1); + assertExileCount(playerA, "Curious Pair", 0); + assertGraveyardCount(playerA,0); + } + + @Test + public void testCastTreatsToShareAndCuriousPairWithEdgewallInnkeeper() { + setStrictChooseMode(true); + addCard(Zone.BATTLEFIELD, playerA, "Forest"); + addCard(Zone.BATTLEFIELD, playerA, "Forest"); + addCard(Zone.BATTLEFIELD, playerA, "Forest"); + addCard(Zone.BATTLEFIELD, playerA, "Edgewall Innkeeper"); + addCard(Zone.HAND, playerA, "Curious Pair"); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Treats to Share"); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Curious Pair"); + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + assertAllCommandsUsed(); + assertHandCount(playerA, 1); + assertPermanentCount(playerA, "Food", 1); + assertPermanentCount(playerA, "Curious Pair", 1); + assertExileCount(playerA, "Curious Pair", 0); + assertGraveyardCount(playerA, 0); + } + + @Test + public void testCastMemoryTheft() { + /* + * Memory Theft {2}{B} + * Sorcery + * Target opponent reveals their hand. You choose a nonland card from it. That player discards that card. + * You may put a card that has an Adventure that player owns from exile into that player's graveyard. + */ + setStrictChooseMode(true); + addCard(Zone.BATTLEFIELD, playerA, "Forest"); + addCard(Zone.HAND, playerA, "Curious Pair"); + addCard(Zone.HAND, playerA, "Opt"); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Treats to Share"); + + addCard(Zone.BATTLEFIELD, playerB, "Swamp"); + addCard(Zone.BATTLEFIELD, playerB, "Swamp"); + addCard(Zone.BATTLEFIELD, playerB, "Swamp"); + addCard(Zone.HAND, playerB, "Memory Theft"); + castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Memory Theft", playerA); + playerB.addChoice("Opt"); + playerB.addChoice("Curious Pair"); + + setStopAt(2, PhaseStep.BEGIN_COMBAT); + execute(); + assertAllCommandsUsed(); + + assertHandCount(playerA, 0); + assertExileCount(playerA, "Curious Pair", 0); + assertGraveyardCount(playerA, 2); + } + + @Test + public void testCastTreatsToShareWithLuckyClover() { + /* + * Lucky Clover {2} + * Artifact + * Whenever you cast an Adventure instant or sorcery spell, copy it. You may choose new targets for the copy. + */ + setStrictChooseMode(true); + addCard(Zone.BATTLEFIELD, playerA, "Forest"); + addCard(Zone.BATTLEFIELD, playerA, "Lucky Clover"); + addCard(Zone.HAND, playerA, "Curious Pair"); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Treats to Share"); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + assertAllCommandsUsed(); + + assertHandCount(playerA, 0); + assertPermanentCount(playerA, "Food", 2); + assertPermanentCount(playerA, "Curious Pair", 0); + assertExileCount(playerA, "Curious Pair", 1); + assertGraveyardCount(playerA, 0); + } + + @Test + public void testCastTreatsToShareAndCopy() { + /* + * Fork {R}{R} + * Instant + * Copy target instant or sorcery spell, except that the copy is red. You may choose new targets for the copy. + */ + setStrictChooseMode(true); + addCard(Zone.BATTLEFIELD, playerA, "Forest"); + addCard(Zone.BATTLEFIELD, playerA, "Mountain"); + addCard(Zone.BATTLEFIELD, playerA, "Mountain"); + addCard(Zone.HAND, playerA, "Curious Pair"); + addCard(Zone.HAND, playerA, "Fork"); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Treats to Share"); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Fork", "Treats to Share"); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + assertAllCommandsUsed(); + + assertHandCount(playerA, 0); + assertPermanentCount(playerA, "Food", 2); + assertPermanentCount(playerA, 5); + assertExileCount(playerA, "Curious Pair", 1); + assertExileCount(playerA, 1); + assertGraveyardCount(playerA, "Fork", 1); + assertGraveyardCount(playerA, 1); + } + + @Test + public void testCastTreatsToShareAndCounter() { + /* + * Counterspell {U}{U} + * Instant + * Counter target spell. + */ + setStrictChooseMode(true); + addCard(Zone.BATTLEFIELD, playerA, "Forest"); + addCard(Zone.BATTLEFIELD, playerB, "Island"); + addCard(Zone.BATTLEFIELD, playerB, "Island"); + addCard(Zone.HAND, playerA, "Curious Pair"); + addCard(Zone.HAND, playerB, "Counterspell"); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Treats to Share"); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Counterspell", "Treats to Share"); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + assertAllCommandsUsed(); + + assertHandCount(playerA, 0); + assertPermanentCount(playerA, "Food", 0); + assertPermanentCount(playerA, 1); + assertExileCount(playerA, 0); + assertGraveyardCount(playerA, "Curious Pair", 1); + assertGraveyardCount(playerA, 1); + assertGraveyardCount(playerB, "Counterspell", 1); + assertGraveyardCount(playerB, 1); + } + + @Test + public void testCastOpponentsHandTreatsToShare() { + /* + * Psychic Intrusion {3}{U}{B} + * Sorcery + * Target opponent reveals their hand. You choose a nonland card from that player's graveyard or hand and exile it. + * You may cast that card for as long as it remains exiled, and you may spend mana as though it were mana of any color to cast that spell. + */ + setStrictChooseMode(true); + addCard(Zone.BATTLEFIELD, playerA, "Island", 1); + addCard(Zone.BATTLEFIELD, playerA, "Swamp", 1); + addCard(Zone.BATTLEFIELD, playerA, "Forest", 6); + addCard(Zone.HAND, playerA, "Psychic Intrusion"); + addCard(Zone.HAND, playerB, "Curious Pair"); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Psychic Intrusion", playerB); + playerA.addChoice("Curious Pair"); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Treats to Share"); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Curious Pair"); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertAllCommandsUsed(); + assertHandCount(playerA, 0); + assertHandCount(playerB, 0); + assertPermanentCount(playerB, 0); + assertPermanentCount(playerA, "Food", 1); + assertPermanentCount(playerA, "Curious Pair", 1); + assertExileCount(playerA, 0); + assertExileCount(playerB, 0); + assertGraveyardCount(playerA, "Psychic Intrusion", 1); + assertGraveyardCount(playerA, 1); + } + + @Test + public void testMultipleAdventures() { + /* + * Eager Cadet + * Creature — Human Soldier + * 1/1 + */ + /* + * Rimrock Knight {1}{R} + * Creature — Dwarf Knight + * Rimrock Knight can't block. + * 3/1 + * ---- + * Boulder Rush {R} + * Instant — Adventure + * Target creature gets +2/+0 until end of turn. + */ + + setStrictChooseMode(true); + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 6); + addCard(Zone.BATTLEFIELD, playerA, "Eager Cadet"); + addCard(Zone.HAND, playerA, "Rimrock Knight", 2); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Boulder Rush", "Eager Cadet"); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Boulder Rush", "Eager Cadet"); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Rimrock Knight"); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Rimrock Knight"); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertAllCommandsUsed(); + assertHandCount(playerA, 0); + assertPermanentCount(playerA, "Rimrock Knight", 2); + assertPermanentCount(playerA, "Eager Cadet", 1); + assertPowerToughness(playerA, "Eager Cadet", 5, 1); + assertExileCount(playerA, 0); + assertGraveyardCount(playerA, 0); + } + + @Test + public void testRimrockKnightPermanentText() { + setStrictChooseMode(true); + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2); + addCard(Zone.HAND, playerA, "Rimrock Knight"); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Rimrock Knight"); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertAllCommandsUsed(); + assertHandCount(playerA, 0); + assertPermanentCount(playerA, "Rimrock Knight", 1); + assertExileCount(playerA, 0); + assertGraveyardCount(playerA, 0); + + Permanent rimrock = getPermanent("Rimrock Knight"); + Assert.assertEquals(rimrock.getRules(currentGame).get(0), "{this} can't block."); + } + + /* + * Tests for Rule 601.3e: + * 601.3e If a rule or effect states that only an alternative set of characteristics or a subset of characteristics + * are considered to determine if a card or copy of a card is legal to cast, those alternative characteristics + * replace the object’s characteristics prior to determining whether the player may begin to cast it. + * Example: Garruk’s Horde says, in part, “You may cast the top card of your library if it’s a creature card.” If + * you control Garruk’s Horde and the top card of your library is a noncreature card with morph, you may cast it + * using its morph ability. + * Example: Melek, Izzet Paragon says, in part, “You may cast the top card of your library if it’s an instant or + * sorcery card.” If you control Melek, Izzet Paragon and the top card of your library is Giant Killer, an + * adventurer creature card whose Adventure is an instant named Chop Down, you may cast Chop Down but not Giant + * Killer. If instead you control Garruk’s Horde and the top card of your library is Giant Killer, you may cast + * Giant Killer but not Chop Down. + */ + + @Test + public void testCastTreatsToShareWithMelek() { + /* + * Melek, Izzet Paragon {4}{U}{R} + * Legendary Creature — Weird Wizard + * Play with the top card of your library revealed. + * You may cast the top card of your library if it's an instant or sorcery card. + * Whenever you cast an instant or sorcery spell from your library, copy it. You may choose new targets for the copy. + * 2/4 + */ + setStrictChooseMode(true); + addCard(Zone.BATTLEFIELD, playerA, "Melek, Izzet Paragon"); + addCard(Zone.BATTLEFIELD, playerA, "Forest"); + removeAllCardsFromLibrary(playerA); + addCard(Zone.LIBRARY, playerA, "Curious Pair"); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Treats to Share"); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertAllCommandsUsed(); + assertHandCount(playerA, 0); + assertPermanentCount(playerA, 4); + assertPermanentCount(playerA, "Food", 2); + assertPermanentCount(playerA, "Curious Pair", 0); + assertExileCount(playerA, "Curious Pair", 1); + assertGraveyardCount(playerA, 0); + } + + @Test + public void testCantCastCuriousPairWithMelek() { + setStrictChooseMode(true); + addCard(Zone.BATTLEFIELD, playerA, "Melek, Izzet Paragon"); + addCard(Zone.BATTLEFIELD, playerA, "Forest", 2); + removeAllCardsFromLibrary(playerA); + addCard(Zone.LIBRARY, playerA, "Curious Pair"); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Curious Pair"); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertActionsCount(playerA, 1); + assertPermanentCount(playerA, "Curious Pair", 0); + assertLibraryCount(playerA, 1); + } + + @Test + public void testCastCuriousPairWithGarruksHorde() { + /* + * Garruk's Horde {5}{G}{G} + * Creature — Beast + * Trample + * Play with the top card of your library revealed. + * You may cast the top card of your library if it's a creature card. + * 7/7 + */ + setStrictChooseMode(true); + addCard(Zone.BATTLEFIELD, playerA, "Garruk's Horde"); + addCard(Zone.BATTLEFIELD, playerA, "Forest", 2); + removeAllCardsFromLibrary(playerA); + addCard(Zone.LIBRARY, playerA, "Curious Pair"); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Curious Pair"); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertAllCommandsUsed(); + assertHandCount(playerA, 0); + assertPermanentCount(playerA, "Food", 0); + assertPermanentCount(playerA, "Curious Pair", 1); + assertExileCount(playerA, 0); + assertGraveyardCount(playerA, 0); + } + + @Test + public void testCantCastTreatsToShareWithGarruksHorde() { + setStrictChooseMode(true); + addCard(Zone.BATTLEFIELD, playerA, "Garruk's Horde"); + addCard(Zone.BATTLEFIELD, playerA, "Forest"); + removeAllCardsFromLibrary(playerA); + addCard(Zone.LIBRARY, playerA, "Curious Pair"); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Treats to Share"); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertActionsCount(playerA, 1); + assertPermanentCount(playerA, "Food", 0); + assertLibraryCount(playerA, 1); + } + + @Test + @Ignore("Not yet working correctly.") + public void testCastTreatsToShareWithWrennAndSixEmblem() { + /* + * Wrenn and Six {R}{G} + * Legendary Planeswalker — Wrenn + * +1: Return up to one target land card from your graveyard to your hand. + * −1: Wrenn and Six deals 1 damage to any target. + * −7: You get an emblem with "Instant and sorcery cards in your graveyard have retrace." + * Loyalty: 3 + */ + setStrictChooseMode(true); + addCard(Zone.BATTLEFIELD, playerA, "Forest"); + addCard(Zone.BATTLEFIELD, playerA, "Wrenn and Six"); + addCard(Zone.GRAVEYARD, playerA, "Curious Pair"); + addCard(Zone.HAND, playerA, "Forest"); + + addCounters(1, PhaseStep.UPKEEP, playerA, "Wrenn and Six", CounterType.LOYALTY, 5); + activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "-7: You get an emblem"); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Treats to Share"); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertAllCommandsUsed(); + assertHandCount(playerA, 0); + assertPermanentCount(playerA, "Food", 1); + assertPermanentCount(playerA, "Curious Pair", 0); + assertPermanentCount(playerA, "Wrenn and Six", 1); + assertEmblemCount(playerA, 1); + assertExileCount(playerA, "Curious Pair", 1); + assertGraveyardCount(playerA, "Forest", 1); + assertGraveyardCount(playerA, 1); + } + + @Test + public void testCastTreatsToShareWithTeferiTimeRaveler() { + /* + * Teferi, Time Raveler {1}{W}{U} + * Legendary Planeswalker — Teferi + * Each opponent can cast spells only any time they could cast a sorcery. + * +1: Until your next turn, you may cast sorcery spells as though they had flash. + * −3: Return up to one target artifact, creature, or enchantment to its owner's hand. Draw a card. + * Loyalty: 4 + */ + setStrictChooseMode(true); + addCard(Zone.BATTLEFIELD, playerA, "Teferi, Time Raveler"); + addCard(Zone.BATTLEFIELD, playerA, "Forest"); + addCard(Zone.HAND, playerA, "Curious Pair"); + + activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "+1: Until your next"); + castSpell(1, PhaseStep.BEGIN_COMBAT, playerA, "Treats to Share"); + + setStopAt(1, PhaseStep.POSTCOMBAT_MAIN); + execute(); + + assertAllCommandsUsed(); + assertHandCount(playerA, 0); + assertPermanentCount(playerA, 3); + assertPermanentCount(playerA, "Food", 1); + assertPermanentCount(playerA, "Curious Pair", 0); + assertExileCount(playerA, "Curious Pair", 1); + assertGraveyardCount(playerA, 0); + } +} diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/cost/alternate/BolassCitadelTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/cost/alternate/BolassCitadelTest.java new file mode 100644 index 00000000000..f5932c74015 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/cost/alternate/BolassCitadelTest.java @@ -0,0 +1,64 @@ +package org.mage.test.cards.cost.alternate; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Ignore; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +public class BolassCitadelTest extends CardTestPlayerBase { + @Test + public void testCastEagerCadet() { + /* + * Eager Cadet + * Creature — Human Soldier + * 1/1 + */ + setStrictChooseMode(true); + addCard(Zone.BATTLEFIELD, playerA, "Forest"); + addCard(Zone.BATTLEFIELD, playerA, "Bolas's Citadel"); + removeAllCardsFromLibrary(playerA); + addCard(Zone.LIBRARY, playerA, "Eager Cadet"); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Eager Cadet"); + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertAllCommandsUsed(); + assertHandCount(playerA, 0); + assertPermanentCount(playerA, "Eager Cadet", 1); + assertGraveyardCount(playerA,0); + assertLife(playerA, 19); + } + + @Test + @Ignore("This is broken for now.") + public void testCastAdventure() { + /* + * Curious Pair {1}{G} + * Creature — Human Peasant + * 1/3 + * ---- + * Treats to Share {G} + * Sorcery — Adventure + * Create a Food token. + */ + setStrictChooseMode(true); + addCard(Zone.BATTLEFIELD, playerA, "Forest"); + addCard(Zone.BATTLEFIELD, playerA, "Bolas's Citadel"); + removeAllCardsFromLibrary(playerA); + addCard(Zone.LIBRARY, playerA, "Curious Pair"); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Treats to Share"); + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertAllCommandsUsed(); + assertTapped("Forest", false); + assertHandCount(playerA, 0); + assertPermanentCount(playerA, "Food", 1); + assertExileCount(playerA, "Curious Pair", 1); + assertGraveyardCount(playerA,0); + assertLife(playerA, 19); + } +} diff --git a/Mage/src/main/java/mage/abilities/effects/ContinuousEffects.java b/Mage/src/main/java/mage/abilities/effects/ContinuousEffects.java index 5d3456dc21f..598a4c2eabc 100644 --- a/Mage/src/main/java/mage/abilities/effects/ContinuousEffects.java +++ b/Mage/src/main/java/mage/abilities/effects/ContinuousEffects.java @@ -5,10 +5,7 @@ import mage.MageObjectReference; import mage.abilities.*; import mage.abilities.effects.common.continuous.BecomesFaceDownCreatureEffect; import mage.abilities.effects.common.continuous.CommanderReplacementEffect; -import mage.cards.Card; -import mage.cards.Cards; -import mage.cards.CardsImpl; -import mage.cards.SplitCardHalf; +import mage.cards.*; import mage.constants.*; import mage.filter.FilterCard; import mage.filter.predicate.Predicate; @@ -509,8 +506,12 @@ public class ContinuousEffects implements Serializable { if (affectedAbility != null && affectedAbility.getSourceObject(game) instanceof SplitCardHalf) { idToCheck = ((SplitCardHalf) affectedAbility.getSourceObject(game)).getParentCard().getId(); } else { - if (game.getObject(objectId) instanceof SplitCardHalf) { - idToCheck = ((SplitCardHalf) game.getObject(objectId)).getParentCard().getId(); + Card card = game.getCard(objectId); + if (card != null && card instanceof SplitCardHalf) { + idToCheck = ((SplitCardHalf) card).getParentCard().getId(); + } else if (card != null && type == AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE + && card instanceof AdventureCardSpell) { + idToCheck = ((AdventureCardSpell) card).getParentCard().getId(); } else { idToCheck = objectId; } diff --git a/Mage/src/main/java/mage/abilities/effects/common/ExileAdventureSpellEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ExileAdventureSpellEffect.java new file mode 100644 index 00000000000..abc8b88b923 --- /dev/null +++ b/Mage/src/main/java/mage/abilities/effects/common/ExileAdventureSpellEffect.java @@ -0,0 +1,107 @@ +package mage.abilities.effects.common; + +import mage.abilities.Ability; +import mage.abilities.MageSingleton; +import mage.abilities.effects.AsThoughEffectImpl; +import mage.abilities.effects.ContinuousEffect; +import mage.abilities.effects.OneShotEffect; +import mage.cards.AdventureCardSpell; +import mage.cards.Card; +import mage.constants.AsThoughEffectType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.game.ExileZone; +import mage.game.Game; +import mage.game.stack.Spell; +import mage.players.Player; +import mage.target.targetpointer.FixedTarget; +import mage.util.CardUtil; + +import java.util.UUID; + +/** + * @author phulin + */ +public class ExileAdventureSpellEffect extends OneShotEffect implements MageSingleton { + + private static final ExileAdventureSpellEffect instance = new ExileAdventureSpellEffect(); + + public static ExileAdventureSpellEffect getInstance() { + return instance; + } + + public static UUID adventureExileId(UUID controllerId, Game game) { + return CardUtil.getExileZoneId(controllerId.toString() + "- On an Adventure", game); + } + + private ExileAdventureSpellEffect() { + super(Outcome.Exile); + staticText = ""; + } + + @Override + public ExileAdventureSpellEffect copy() { + return instance; + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + Spell spell = game.getStack().getSpell(source.getId()); + if (spell != null && !spell.isCopy()) { + Card spellCard = spell.getCard(); + if (spellCard != null && spellCard instanceof AdventureCardSpell) { + UUID exileId = adventureExileId(controller.getId(), game); + game.getExile().createZone(exileId, "On an Adventure"); + AdventureCardSpell adventureSpellCard = (AdventureCardSpell) spellCard; + Card parentCard = adventureSpellCard.getParentCard(); + if (controller.moveCardsToExile(parentCard, source, game, true, exileId, "On an Adventure")) { + ContinuousEffect effect = new AdventureCastFromExileEffect(); + effect.setTargetPointer(new FixedTarget(parentCard.getId(), game)); + game.addEffect(effect, source); + } + } + } + return true; + } + return false; + } +} + +class AdventureCastFromExileEffect extends AsThoughEffectImpl { + + public AdventureCastFromExileEffect() { + super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, Duration.Custom, Outcome.Benefit); + staticText = "Then exile this card. You may cast the creature later from exile."; + } + + public AdventureCastFromExileEffect(final AdventureCastFromExileEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } + + @Override + public AdventureCastFromExileEffect copy() { + return new AdventureCastFromExileEffect(this); + } + + @Override + public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { + UUID targetId = getTargetPointer().getFirst(game, source); + ExileZone adventureExileZone = game.getExile().getExileZone(ExileAdventureSpellEffect.adventureExileId(affectedControllerId, game)); + if (targetId == null) { + this.discard(); + } else if (objectId.equals(targetId) + && affectedControllerId.equals(source.getControllerId()) + && adventureExileZone.contains(objectId)) { + Card card = game.getCard(objectId); + return card != null; + } + return false; + } +} \ No newline at end of file diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/PlayTheTopCardEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/PlayTheTopCardEffect.java index 35e63cc3619..446876b1a5e 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/PlayTheTopCardEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/PlayTheTopCardEffect.java @@ -2,7 +2,10 @@ package mage.abilities.effects.common.continuous; import java.util.UUID; + +import mage.MageObject; import mage.abilities.Ability; +import mage.abilities.SpellAbility; import mage.abilities.effects.AsThoughEffectImpl; import mage.cards.Card; import mage.constants.AsThoughEffectType; @@ -47,12 +50,27 @@ public class PlayTheTopCardEffect extends AsThoughEffectImpl { @Override public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { + return applies(objectId, null, source, game, affectedControllerId); + } + + @Override + public boolean applies(UUID objectId, Ability affectedAbility, Ability source, Game game, UUID playerId) { Card cardOnTop = game.getCard(objectId); + Card cardToCheckProperties = cardOnTop; + + // Check each ability individually, as e.g. Adventures and associated creatures may get different results from the filter. + if (affectedAbility != null) { + MageObject sourceObject = affectedAbility.getSourceObject(game); + if (sourceObject != null && sourceObject instanceof Card) { + cardToCheckProperties = (Card) sourceObject; + } + } + if (cardOnTop != null - && affectedControllerId.equals(source.getControllerId()) + && playerId.equals(source.getControllerId()) && cardOnTop.isOwnedBy(source.getControllerId()) - && (!cardOnTop.getManaCost().isEmpty() || cardOnTop.isLand()) - && filter.match(cardOnTop, game)) { + && (!cardToCheckProperties.getManaCost().isEmpty() || cardToCheckProperties.isLand()) + && filter.match(cardToCheckProperties, game)) { Player player = game.getPlayer(cardOnTop.getOwnerId()); if (player != null && cardOnTop.equals(player.getLibrary().getFromTop(game))) { return true; diff --git a/Mage/src/main/java/mage/cards/AdventureCard.java b/Mage/src/main/java/mage/cards/AdventureCard.java index af213591bb5..3df44282d8d 100644 --- a/Mage/src/main/java/mage/cards/AdventureCard.java +++ b/Mage/src/main/java/mage/cards/AdventureCard.java @@ -1,8 +1,13 @@ package mage.cards; +import mage.abilities.Abilities; +import mage.abilities.AbilitiesImpl; +import mage.abilities.Ability; import mage.abilities.SpellAbility; -import mage.constants.CardType; +import mage.constants.*; +import mage.game.Game; +import java.util.List; import java.util.UUID; /** @@ -10,17 +15,87 @@ import java.util.UUID; */ public abstract class AdventureCard extends CardImpl { - protected SpellAbility adventureSpellAbility = new SpellAbility(null, null); + /* The adventure spell card, i.e. Swift End. */ + protected Card spellCard; - public AdventureCard(UUID ownerId, CardSetInfo setInfo, CardType[] typesLeft, CardType[] typesRight, String costsLeft, String adventureName, String costsRight) { - super(ownerId, setInfo, typesLeft, costsLeft); + public AdventureCard(UUID ownerId, CardSetInfo setInfo, CardType[] types, CardType[] typesSpell, String costs, String adventureName, String costsSpell) { + super(ownerId, setInfo, types, costs); + this.spellCard = new AdventureCardSpellImpl(ownerId, setInfo, adventureName, typesSpell, costsSpell, this); } public AdventureCard(AdventureCard card) { super(card); + this.spellCard = card.getSpellCard().copy(); + ((AdventureCardSpell)this.spellCard).setParentCard(this); } - public SpellAbility getAdventureSpellAbility() { - return adventureSpellAbility; + public Card getSpellCard() { + return spellCard; + } + + @Override + public void assignNewId() { + super.assignNewId(); + spellCard.assignNewId(); + } + + @Override + public boolean moveToZone(Zone toZone, UUID sourceId, Game game, boolean flag, List appliedEffects) { + if (super.moveToZone(toZone, sourceId, game, flag, appliedEffects)) { + game.getState().setZone(getSpellCard().getId(), toZone); + return true; + } + return false; + } + + @Override + public void setZone(Zone zone, Game game) { + super.setZone(zone, game); + game.setZone(getSpellCard().getId(), zone); + } + + @Override + public boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game, List appliedEffects) { + if (super.moveToExile(exileId, name, sourceId, game, appliedEffects)) { + Zone currentZone = game.getState().getZone(getId()); + game.getState().setZone(getSpellCard().getId(), currentZone); + return true; + } + return false; + } + + @Override + public boolean cast(Game game, Zone fromZone, SpellAbility ability, UUID controllerId) { + switch (ability.getSpellAbilityType()) { + case ADVENTURE_SPELL: + return this.getSpellCard().cast(game, fromZone, ability, controllerId); + default: + this.getSpellCard().getSpellAbility().setControllerId(controllerId); + return super.cast(game, fromZone, ability, controllerId); + } + } + + @Override + public Abilities getAbilities() { + Abilities allAbilities = new AbilitiesImpl<>(); + allAbilities.addAll(spellCard.getAbilities()); + allAbilities.addAll(super.getAbilities()); + return allAbilities; + } + + @Override + public Abilities getAbilities(Game game) { + Abilities allAbilities = new AbilitiesImpl<>(); + allAbilities.addAll(spellCard.getAbilities(game)); + allAbilities.addAll(super.getAbilities(game)); + return allAbilities; + } + + @Override + public void setOwnerId(UUID ownerId) { + super.setOwnerId(ownerId); + abilities.setControllerId(ownerId); + spellCard.getAbilities().setControllerId(ownerId); + spellCard.setOwnerId(ownerId); } } diff --git a/Mage/src/main/java/mage/cards/AdventureCardSpell.java b/Mage/src/main/java/mage/cards/AdventureCardSpell.java new file mode 100644 index 00000000000..5b873acc8d3 --- /dev/null +++ b/Mage/src/main/java/mage/cards/AdventureCardSpell.java @@ -0,0 +1,20 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package mage.cards; + +/** + * + * @author phulin + */ +public interface AdventureCardSpell extends Card { + + @Override + AdventureCardSpell copy(); + + void setParentCard(AdventureCard card); + + AdventureCard getParentCard(); +} diff --git a/Mage/src/main/java/mage/cards/AdventureCardSpellImpl.java b/Mage/src/main/java/mage/cards/AdventureCardSpellImpl.java new file mode 100644 index 00000000000..16b94a10dbc --- /dev/null +++ b/Mage/src/main/java/mage/cards/AdventureCardSpellImpl.java @@ -0,0 +1,155 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package mage.cards; + +import mage.abilities.Modes; +import mage.abilities.SpellAbility; +import mage.abilities.effects.common.ExileAdventureSpellEffect; +import mage.constants.CardType; +import mage.constants.SpellAbilityType; +import mage.constants.SubType; +import mage.constants.Zone; +import mage.game.ExileZone; +import mage.game.Game; + +import java.util.List; +import java.util.UUID; + +/** + * + * @author phulin + */ +public class AdventureCardSpellImpl extends CardImpl implements AdventureCardSpell { + + private AdventureCard adventureCardParent; + + public AdventureCardSpellImpl(UUID ownerId, CardSetInfo setInfo, String adventureName, CardType[] cardTypes, String costs, AdventureCard adventureCardParent) { + super(ownerId, setInfo, cardTypes, costs, SpellAbilityType.ADVENTURE_SPELL); + this.subtype.add(SubType.ADVENTURE); + + AdventureCardSpellAbility newSpellAbility = new AdventureCardSpellAbility(getSpellAbility()); + newSpellAbility.setName(adventureName, costs); + newSpellAbility.addEffect(ExileAdventureSpellEffect.getInstance()); + newSpellAbility.setCardName(adventureName); + this.replaceSpellAbility(newSpellAbility); + spellAbility = newSpellAbility; + + this.setName(adventureName); + this.adventureCardParent = adventureCardParent; + } + + public AdventureCardSpellImpl(final AdventureCardSpellImpl card) { + super(card); + this.adventureCardParent = card.adventureCardParent; + } + + @Override + public UUID getOwnerId() { + return adventureCardParent.getOwnerId(); + } + + @Override + public String getImageName() { + return adventureCardParent.getImageName(); + } + + @Override + public String getExpansionSetCode() { + return adventureCardParent.getExpansionSetCode(); + } + + @Override + public String getCardNumber() { + return adventureCardParent.getCardNumber(); + } + + @Override + public boolean moveToZone(Zone toZone, UUID sourceId, Game game, boolean flag, List appliedEffects) { + return adventureCardParent.moveToZone(toZone, sourceId, game, flag, appliedEffects); + } + + @Override + public boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game, List appliedEffects) { + return adventureCardParent.moveToExile(exileId, name, sourceId, game, appliedEffects); + } + + @Override + public AdventureCard getMainCard() { + return adventureCardParent; + } + + @Override + public void setZone(Zone zone, Game game) { + game.setZone(adventureCardParent.getId(), zone); + game.setZone(adventureCardParent.getSpellCard().getId(), zone); + } + + @Override + public AdventureCardSpell copy() { + return new AdventureCardSpellImpl(this); + } + + @Override + public void setParentCard(AdventureCard card) { + this.adventureCardParent = card; + } + + @Override + public AdventureCard getParentCard() { + return this.adventureCardParent; + } +} + +class AdventureCardSpellAbility extends SpellAbility { + public AdventureCardSpellAbility(final SpellAbility ability) { + super(ability); + } + + @Override + public ActivationStatus canActivate(UUID playerId, Game game) { + ExileZone adventureExileZone = game.getExile().getExileZone(ExileAdventureSpellEffect.adventureExileId(playerId, game)); + Card spellCard = game.getCard(this.getSourceId()); + if (spellCard != null && spellCard instanceof AdventureCardSpell) { + Card card = ((AdventureCardSpell) spellCard).getParentCard(); + if (adventureExileZone != null && adventureExileZone.contains(card.getId())) { + return ActivationStatus.getFalse(); + } + } + return super.canActivate(playerId, game); + } + + public void setName(String name, String costs) { + this.name = "Adventure — " + name + " " + costs; + } + + @Override + public String getRule(boolean all) { + return this.getRule(); + } + + @Override + public String getRule() { + StringBuilder sbRule = new StringBuilder(); + sbRule.append("Adventure — "); + sbRule.append(this.getCardName()); + sbRule.append(" "); + sbRule.append(manaCosts.getText()); + sbRule.append(" — "); + Modes modes = this.getModes(); + if (modes.size() <= 1) { + sbRule.append(modes.getMode().getEffects().getTextStartingUpperCase(modes.getMode())); + } else { + sbRule.append(getModes().getText()); + } + sbRule.append(" (Then exile this card. You may cast the creature later from exile.)"); + return sbRule.toString(); + } + + @Override + public SpellAbility copy() { + return new AdventureCardSpellAbility(this); + } +} \ No newline at end of file diff --git a/Mage/src/main/java/mage/cards/Card.java b/Mage/src/main/java/mage/cards/Card.java index bac8f59d403..a4ea5154a5f 100644 --- a/Mage/src/main/java/mage/cards/Card.java +++ b/Mage/src/main/java/mage/cards/Card.java @@ -150,7 +150,7 @@ public interface Card extends MageObject { /** * - * @return The main card of a split half card, otherwise the card itself is + * @return The main card of a split half card or adventure spell card, otherwise the card itself is * returned */ Card getMainCard(); diff --git a/Mage/src/main/java/mage/cards/CardImpl.java b/Mage/src/main/java/mage/cards/CardImpl.java index 6e5d5dc589c..4648b7980a3 100644 --- a/Mage/src/main/java/mage/cards/CardImpl.java +++ b/Mage/src/main/java/mage/cards/CardImpl.java @@ -505,6 +505,9 @@ public abstract class CardImpl extends MageObjectImpl implements Card { stackObject = game.getStack().getSpell(((SplitCard) this).getRightHalfCard().getId()); } } + if (stackObject == null && (this instanceof AdventureCard)) { + stackObject = game.getStack().getSpell(((AdventureCard) this).getSpellCard().getId()); + } if (stackObject == null) { stackObject = game.getStack().getSpell(getId()); } diff --git a/Mage/src/main/java/mage/constants/SpellAbilityType.java b/Mage/src/main/java/mage/constants/SpellAbilityType.java index 509796a2a7a..22427d77be4 100644 --- a/Mage/src/main/java/mage/constants/SpellAbilityType.java +++ b/Mage/src/main/java/mage/constants/SpellAbilityType.java @@ -15,7 +15,7 @@ public enum SpellAbilityType { SPLIT_RIGHT("RightSplit SpellAbility"), MODE("Mode SpellAbility"), SPLICE("Spliced SpellAbility"), - ADVENTURE("Adventure SpellAbility"); + ADVENTURE_SPELL("Adventure SpellAbility"); private final String text; diff --git a/Mage/src/main/java/mage/filter/predicate/mageobject/AdventurePredicate.java b/Mage/src/main/java/mage/filter/predicate/mageobject/AdventurePredicate.java index 90927d92ca6..98544c800f6 100644 --- a/Mage/src/main/java/mage/filter/predicate/mageobject/AdventurePredicate.java +++ b/Mage/src/main/java/mage/filter/predicate/mageobject/AdventurePredicate.java @@ -1,19 +1,27 @@ package mage.filter.predicate.mageobject; import mage.MageObject; +import mage.cards.AdventureCard; +import mage.cards.Card; import mage.filter.predicate.Predicate; import mage.game.Game; +import mage.game.stack.Spell; /** * @author TheElk801 - * TODO: make this actually work */ public enum AdventurePredicate implements Predicate { instance; @Override public boolean apply(MageObject input, Game game) { - return false; + if (input instanceof Spell) { + return ((Spell) input).getCard() instanceof AdventureCard; + } else if (input instanceof Card) { + return input instanceof AdventureCard; + } else { + return false; + } } @Override diff --git a/Mage/src/main/java/mage/filter/predicate/other/CardTextPredicate.java b/Mage/src/main/java/mage/filter/predicate/other/CardTextPredicate.java index e09d8560049..1c2af8afdbd 100644 --- a/Mage/src/main/java/mage/filter/predicate/other/CardTextPredicate.java +++ b/Mage/src/main/java/mage/filter/predicate/other/CardTextPredicate.java @@ -3,6 +3,8 @@ package mage.filter.predicate.other; import java.util.HashMap; import java.util.Locale; + +import mage.cards.AdventureCard; import mage.cards.Card; import mage.cards.SplitCard; import mage.constants.SubType; @@ -76,6 +78,14 @@ public class CardTextPredicate implements Predicate { } } } + if (input instanceof AdventureCard) { + for (String rule : ((AdventureCard) input).getSpellCard().getRules(game)) { + if (rule.toLowerCase(Locale.ENGLISH).contains(token)) { + found = true; + break; + } + } + } for (String rule : input.getRules(game)) { if (rule.toLowerCase(Locale.ENGLISH).contains(token)) { found = true; diff --git a/Mage/src/main/java/mage/game/GameImpl.java b/Mage/src/main/java/mage/game/GameImpl.java index c0c8c8a6865..8f4eafff6b1 100644 --- a/Mage/src/main/java/mage/game/GameImpl.java +++ b/Mage/src/main/java/mage/game/GameImpl.java @@ -230,6 +230,12 @@ public abstract class GameImpl implements Game, Serializable { gameCards.put(rightCard.getId(), rightCard); state.addCard(rightCard); } + if (card instanceof AdventureCard) { + Card spellCard = ((AdventureCard) card).getSpellCard(); + spellCard.setOwnerId(ownerId); + gameCards.put(spellCard.getId(), spellCard); + state.addCard(spellCard); + } } } @@ -1767,7 +1773,7 @@ public abstract class GameImpl implements Game, Serializable { Iterator copiedCards = this.getState().getCopiedCards().iterator(); while (copiedCards.hasNext()) { Card card = copiedCards.next(); - if (card instanceof SplitCardHalf) { + if (card instanceof SplitCardHalf || card instanceof AdventureCardSpell) { continue; // only the main card is moves, not the halves } Zone zone = state.getZone(card.getId()); diff --git a/Mage/src/main/java/mage/game/GameState.java b/Mage/src/main/java/mage/game/GameState.java index 21efc769a75..14f9de51ea3 100644 --- a/Mage/src/main/java/mage/game/GameState.java +++ b/Mage/src/main/java/mage/game/GameState.java @@ -5,6 +5,7 @@ import mage.abilities.*; import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.ContinuousEffects; import mage.abilities.effects.Effect; +import mage.cards.AdventureCard; import mage.cards.Card; import mage.cards.SplitCard; import mage.constants.Zone; @@ -811,6 +812,9 @@ public class GameState implements Serializable, Copyable { removeCopiedCard(((SplitCard) card).getLeftHalfCard()); removeCopiedCard(((SplitCard) card).getRightHalfCard()); } + if (card instanceof AdventureCard) { + removeCopiedCard(((AdventureCard) card).getSpellCard()); + } } /** @@ -1166,6 +1170,11 @@ public class GameState implements Serializable, Copyable { copiedCards.put(rightCard.getId(), rightCard); addCard(rightCard); } + if (copiedCard instanceof AdventureCard) { + Card spellCard = ((AdventureCard) copiedCard).getSpellCard(); + copiedCards.put(spellCard.getId(), spellCard); + addCard(spellCard); + } return copiedCard; } diff --git a/Mage/src/main/java/mage/game/command/emblems/WrennAndSixEmblem.java b/Mage/src/main/java/mage/game/command/emblems/WrennAndSixEmblem.java index 8ca6f0b2125..cda33d8faa7 100644 --- a/Mage/src/main/java/mage/game/command/emblems/WrennAndSixEmblem.java +++ b/Mage/src/main/java/mage/game/command/emblems/WrennAndSixEmblem.java @@ -4,6 +4,7 @@ import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.keyword.RetraceAbility; +import mage.cards.AdventureCard; import mage.cards.Card; import mage.constants.*; import mage.game.Game; @@ -42,7 +43,14 @@ class WrennAndSixEmblemEffect extends ContinuousEffectImpl { } for (UUID cardId : controller.getGraveyard()) { Card card = game.getCard(cardId); - if (card == null || !card.isInstantOrSorcery()) { + if (card == null) { + continue; + } + if (card instanceof AdventureCard) { + // Adventure cards are castable per https://twitter.com/elishffrn/status/1179047911729946624 + card = ((AdventureCard) card).getSpellCard(); + } + if (!card.isInstantOrSorcery()) { continue; } Ability ability = new RetraceAbility(card); diff --git a/Mage/src/main/java/mage/game/permanent/PermanentCard.java b/Mage/src/main/java/mage/game/permanent/PermanentCard.java index f6436ee4511..1f2bf0ccfb1 100644 --- a/Mage/src/main/java/mage/game/permanent/PermanentCard.java +++ b/Mage/src/main/java/mage/game/permanent/PermanentCard.java @@ -1,15 +1,20 @@ package mage.game.permanent; +import java.util.ArrayList; +import java.util.List; import java.util.UUID; import mage.MageObject; import mage.abilities.Abilities; import mage.abilities.Ability; +import mage.abilities.SpellAbility; import mage.abilities.costs.mana.ManaCost; import mage.abilities.costs.mana.ManaCosts; import mage.abilities.keyword.TransformAbility; +import mage.cards.AdventureCard; import mage.cards.Card; import mage.cards.LevelerCard; +import mage.constants.SpellAbilityType; import mage.game.Game; import mage.game.events.ZoneChangeEvent; @@ -87,6 +92,18 @@ public class PermanentCard extends PermanentImpl { } else { this.abilities = card.getAbilities().copy(); } + if (card instanceof AdventureCard) { + // Adventure card spell abilities should not appear on permanents. + List toRemove = new ArrayList(); + for (Ability ability : this.abilities) { + if (ability instanceof SpellAbility) { + if (((SpellAbility) ability).getSpellAbilityType() == SpellAbilityType.ADVENTURE_SPELL) { + toRemove.add(ability); + } + } + } + toRemove.forEach(ability -> this.abilities.remove(ability)); + } this.abilities.setControllerId(this.controllerId); this.abilities.setSourceId(objectId); this.cardType.clear(); diff --git a/Mage/src/main/java/mage/players/PlayerImpl.java b/Mage/src/main/java/mage/players/PlayerImpl.java index 3b7bfae4942..33584270c14 100644 --- a/Mage/src/main/java/mage/players/PlayerImpl.java +++ b/Mage/src/main/java/mage/players/PlayerImpl.java @@ -3215,6 +3215,37 @@ public abstract class PlayerImpl implements Player, Serializable { } } + private List cardPlayableAbilities(Game game, Card card, boolean setControllerId) { + List playable = new ArrayList(); + if (card != null) { + for (ActivatedAbility ability : card.getAbilities().getActivatedAbilities(Zone.HAND)) { + if (!ability.canActivate(playerId, game).canActivate()) { + continue; + } + + UUID savedControllerId = null; + if (setControllerId) { + // For when owner != caster, e.g. with Psychic Intrusion and similar effects. + savedControllerId = getId(); + ability.setControllerId(getId()); + } + if (ability instanceof SpellAbility + && null != game.getContinuousEffects().asThough(card.getId(), + AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, ability, getId(), game)) { + playable.add(ability); + } else if (ability instanceof PlayLandAbility + && null != game.getContinuousEffects().asThough(card.getId(), + AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, card.getSpellAbility(), getId(), game)) { + playable.add(ability); + } + if (setControllerId) { + ability.setControllerId(savedControllerId); + } + } + } + return playable; + } + @Override public List getPlayable(Game game, boolean hidden) { return getPlayable(game, hidden, Zone.ALL, true); @@ -3277,6 +3308,11 @@ public abstract class PlayerImpl implements Player, Serializable { splitCard.getRightHalfCard().getAbilities(), availableMana, playable); getPlayableFromGraveyardCard(game, splitCard, splitCard.getSharedAbilities(), availableMana, playable); + } else if (card instanceof AdventureCard) { + AdventureCard adventureCard = (AdventureCard) card; + getPlayableFromGraveyardCard(game, adventureCard.getSpellCard(), + adventureCard.getSpellCard().getAbilities(), availableMana, playable); + getPlayableFromGraveyardCard(game, adventureCard, adventureCard.getAbilities(), availableMana, playable); } else { getPlayableFromGraveyardCard(game, card, card.getAbilities(), availableMana, playable); } @@ -3291,20 +3327,7 @@ public abstract class PlayerImpl implements Player, Serializable { if (fromAll || fromZone == Zone.EXILED) { for (ExileZone exile : game.getExile().getExileZones()) { for (Card card : exile.getCards(game)) { - if (null != game.getContinuousEffects().asThough(card.getId(), - AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, null, this.getId(), game)) { - for (Ability ability : card.getAbilities()) { - if (ability.getZone().match(Zone.HAND)) { - ability.setControllerId(this.getId()); // controller must be set for case owner != caster - if (ability instanceof ActivatedAbility) { - if (((ActivatedAbility) ability).canActivate(playerId, game).canActivate()) { - playable.add(ability); - } - } - ability.setControllerId(card.getOwnerId()); - } - } - } + playable.addAll(cardPlayableAbilities(game, card, true)); } } } @@ -3313,14 +3336,7 @@ public abstract class PlayerImpl implements Player, Serializable { if (fromAll) { for (Cards revealedCards : game.getState().getRevealed().values()) { for (Card card : revealedCards.getCards(game)) { - if (null != game.getContinuousEffects().asThough(card.getId(), - AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, null, this.getId(), game)) { - for (ActivatedAbility ability : card.getAbilities().getActivatedAbilities(Zone.HAND)) { - if (ability instanceof SpellAbility || ability instanceof PlayLandAbility) { - playable.add(ability); - } - } - } + playable.addAll(cardPlayableAbilities(game, card, false)); } } } @@ -3332,14 +3348,7 @@ public abstract class PlayerImpl implements Player, Serializable { if (player != null) { if (/*player.isTopCardRevealed() &&*/player.getLibrary().hasCards()) { Card card = player.getLibrary().getFromTop(game); - if (card != null && null != game.getContinuousEffects().asThough(card.getId(), - AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, card.getSpellAbility(), getId(), game)) { - for (ActivatedAbility ability : card.getAbilities().getActivatedAbilities(Zone.HAND)) { - if (ability instanceof SpellAbility || ability instanceof PlayLandAbility) { - playable.add(ability); - } - } - } + playable.addAll(cardPlayableAbilities(game, card, false)); } } } @@ -3413,10 +3422,10 @@ public abstract class PlayerImpl implements Player, Serializable { playableObjects.add(ability.getSourceId()); // main card must be marked playable in GUI - MageObject object = game.getObject(ability.getSourceId()); - if (object instanceof SplitCardHalf) { - UUID splitCardId = ((Card) object).getMainCard().getId(); - playableObjects.add(splitCardId); + Card card = game.getCard(ability.getSourceId()); + if (card != null && card.getMainCard().getId() != card.getId()) { + UUID mainCardId = card.getMainCard().getId(); + playableObjects.add(mainCardId); } } }