Begin implementing adventures.

This commit is contained in:
Patrick Hulin 2019-12-09 11:30:11 -05:00
parent b0c01da007
commit 04a4b91a59
39 changed files with 495 additions and 69 deletions

View file

@ -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) {

View file

@ -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) {

View file

@ -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))
);
}

View file

@ -34,9 +34,9 @@ public final class BonecrusherGiant extends AdventureCard {
// Stomp
// Damage cant 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) {

View file

@ -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) {

View file

@ -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) {

View file

@ -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) {

View file

@ -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) {

View file

@ -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) {

View file

@ -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) {

View file

@ -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) {

View file

@ -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) {

View file

@ -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) {

View file

@ -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) {

View file

@ -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) {

View file

@ -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) {

View file

@ -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()
));
}

View file

@ -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) {

View file

@ -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) {

View file

@ -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) {

View file

@ -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) {

View file

@ -39,10 +39,10 @@ public final class QueenOfIce extends AdventureCard {
// Rage of Winter
// Tap target creature. It doesnt untap during its controllers 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) {

View file

@ -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) {

View file

@ -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) {

View file

@ -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) {

View file

@ -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) {

View file

@ -25,8 +25,8 @@ public final class ShepherdOfTheFlock extends AdventureCard {
// Usher to Safety
// Return target permanent you control to its owners 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) {

View file

@ -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) {

View file

@ -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) {

View file

@ -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) {

View file

@ -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()));
}
}

View file

@ -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()));
}
}

View file

@ -0,0 +1,20 @@
package org.mage.test.cards.cost.adventure;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
public class CastAdventureCardsTest extends CardTestPlayerBase {
@Test
public void testCastCuriousPair() {
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();
assertPermanentCount(playerA, "Food", 1);
assertExileCount(playerA, "Curious Pair", 1);
assertGraveyardCount(playerA,0);
}
}

View file

@ -0,0 +1,98 @@
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.AdventureCard;
import mage.cards.AdventureCardSpell;
import mage.cards.Card;
import mage.constants.AsThoughEffectType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.stack.Spell;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
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;
}
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) {
AdventureCardSpell adventureSpellCard = (AdventureCardSpell) spellCard;
if (controller.moveCards(adventureSpellCard, Zone.EXILED, source, game)) {
ContinuousEffect effect = new AdventureCastFromExileEffect();
effect.setTargetPointer(new FixedTarget(adventureSpellCard.getParentCard().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);
if (targetId == null) {
this.discard();
} else if (objectId.equals(targetId)
&& affectedControllerId.equals(source.getControllerId())) {
Card card = game.getCard(objectId);
return card != null;
}
return false;
}
}

View file

@ -0,0 +1,124 @@
package mage.abilities.keyword;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.Costs;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.cards.Card;
import mage.cards.SplitCard;
import mage.constants.*;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
import java.util.UUID;
/**
* 702.32. Flashback
*
* 702.32a. Flashback appears on some instants and sorceries. It represents two
* static abilities: one that functions while the card is in a players
* graveyard and the other that functions while the card is on the stack.
* Flashback [cost] means, "You may cast this card from your graveyard by paying
* [cost] rather than paying its mana cost" and, "If the flashback cost was
* paid, exile this card instead of putting it anywhere else any time it would
* leave the stack." Casting a spell using its flashback ability follows the
* rules for paying alternative costs in rules 601.2b and 601.2eg.
*
* @author phulin
*/
public class AdventureCreatureAbility extends SpellAbility {
private String abilityName;
private SpellAbility spellAbilityToResolve;
public AdventureCreatureAbility(Cost cost) {
super(null, "", Zone.EXILED, SpellAbilityType.BASE, SpellAbilityCastMode.NORMAL);
this.setAdditionalCostsRuleVisible(false);
this.name = "Cast creature " + cost.getText();
this.addCost(cost);
this.timing = TimingRule.SORCERY;
}
public AdventureCreatureAbility(final AdventureCreatureAbility 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, and it must have been cast as an adventure.
if (game.getState().getZone(card.getId()) != Zone.EXILED) {
return ActivationStatus.getFalse();
}
// FIXME: Make sure it was cast as an adventure.
return card.getSpellAbility().canActivate(playerId, game);
}
}
return ActivationStatus.getFalse();
}
@Override
public Costs<Cost> getCosts() {
if (spellAbilityToResolve == null) {
return super.getCosts();
}
return spellAbilityToResolve.getCosts();
}
@Override
public AdventureCreatureAbility copy() {
return new AdventureCreatureAbility(this);
}
@Override
public String getRule(boolean all) {
return this.getRule();
}
@Override
public String getRule() {
StringBuilder sbRule = new StringBuilder("Cast from Adventure");
/*if (!costs.isEmpty()) {
sbRule.append("&mdash;");
} else {
sbRule.append(' ');
}
if (!manaCosts.isEmpty()) {
sbRule.append(manaCosts.getText());
}
if (!costs.isEmpty()) {
if (!manaCosts.isEmpty()) {
sbRule.append(", ");
}
sbRule.append(costs.getText());
sbRule.append('.');
}
if (abilityName != null) {
sbRule.append(' ');
sbRule.append(abilityName);
}
sbRule.append(" <i>(You may cast this card from your graveyard for its flashback cost. Then exile it.)</i>");*/
return sbRule.toString();
}
/**
* Used for split card in PlayerImpl method:
* getOtherUseableActivatedAbilities
*
* @param abilityName
*/
public void setAbilityName(String abilityName) {
this.abilityName = abilityName;
}
}

View file

@ -1,8 +1,17 @@
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.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.AsThoughEffectImpl;
import mage.abilities.effects.common.ExileAdventureSpellEffect;
import mage.abilities.keyword.AdventureCreatureAbility;
import mage.constants.*;
import mage.game.Game;
import java.util.List;
import java.util.UUID;
/**
@ -10,17 +19,89 @@ 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;
/* The ability to cast the creature from exile. */
protected SpellAbility adventureCreatureAbility;
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);
spellCard = new AdventureCardSpellImpl(ownerId, setInfo, typesSpell, costsSpell, this);
spellCard.getSpellAbility().addEffect(ExileAdventureSpellEffect.getInstance());
adventureCreatureAbility = new AdventureCreatureAbility(new ManaCostsImpl(costs));
}
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<UUID> 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<UUID> 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<Ability> getAbilities(Game game) {
Abilities<Ability> allAbilities = new AbilitiesImpl<>();
for (Ability ability : super.getAbilities(game)) {
if (ability instanceof SpellAbility
&& ((SpellAbility) ability).getSpellAbilityType() != SpellAbilityType.SPLIT
&& ((SpellAbility) ability).getSpellAbilityType() != SpellAbilityType.SPLIT_AFTERMATH) {
allAbilities.add(ability);
}
}
allAbilities.addAll(spellCard.getAbilities(game));
return allAbilities;
}
@Override
public void setOwnerId(UUID ownerId) {
super.setOwnerId(ownerId);
abilities.setControllerId(ownerId);
spellCard.getAbilities().setControllerId(ownerId);
spellCard.setOwnerId(ownerId);
}
}

View file

@ -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();
}

View file

@ -0,0 +1,89 @@
/*
* 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.constants.CardType;
import mage.constants.SpellAbilityType;
import mage.constants.Zone;
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, CardType[] cardTypes, String costs, AdventureCard adventureCardParent) {
super(ownerId, setInfo, cardTypes, costs, SpellAbilityType.ADVENTURE_SPELL);
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<UUID> appliedEffects) {
return adventureCardParent.moveToZone(toZone, sourceId, game, flag, appliedEffects);
}
@Override
public boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game, List<UUID> 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;
}
}

View file

@ -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;