Added Epic Ability and add the 5 cards that use it. Did not get the chance to test it well due to some memory issues with the client/server.

This commit is contained in:
Jeff 2014-02-07 17:27:50 -06:00
parent e6f55d3b80
commit 1c2f0ae65d
7 changed files with 733 additions and 0 deletions

View file

@ -0,0 +1,68 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.saviorsofkamigawa;
import java.util.UUID;
import mage.abilities.dynamicvalue.common.CardsInControllerHandCount;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.EpicEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.game.permanent.token.SnakeToken;
/**
*
* @author jeffwadsworth
*/
public class EndlessSwarm extends CardImpl<EndlessSwarm> {
public EndlessSwarm(UUID ownerId) {
super(ownerId, 129, "Endless Swarm", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{G}");
this.expansionSetCode = "SOK";
this.color.setGreen(true);
// Put a 1/1 green Snake creature token onto the battlefield for each card in your hand.
this.getSpellAbility().addEffect(new CreateTokenEffect(new SnakeToken(), new CardsInControllerHandCount()));
// Epic
this.getSpellAbility().addEffect(new EpicEffect());
}
public EndlessSwarm(final EndlessSwarm card) {
super(card);
}
@Override
public EndlessSwarm copy() {
return new EndlessSwarm(this);
}
}

View file

@ -0,0 +1,114 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.saviorsofkamigawa;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.EpicEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetCardInLibrary;
/**
*
* @author jeffwadsworth
*/
public class EnduringIdeal extends CardImpl<EnduringIdeal> {
public EnduringIdeal(UUID ownerId) {
super(ownerId, 9, "Enduring Ideal", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{W}");
this.expansionSetCode = "SOK";
this.color.setWhite(true);
// Search your library for an enchantment card and put it onto the battlefield. Then shuffle your library.
this.getSpellAbility().addEffect(new EnduringIdealEffect());
// Epic
this.getSpellAbility().addEffect(new EpicEffect());
}
public EnduringIdeal(final EnduringIdeal card) {
super(card);
}
@Override
public EnduringIdeal copy() {
return new EnduringIdeal(this);
}
}
class EnduringIdealEffect extends OneShotEffect<EnduringIdealEffect> {
private static final FilterCard filter = new FilterCard();
static {
filter.add(new CardTypePredicate(CardType.ENCHANTMENT));
}
public EnduringIdealEffect() {
super(Outcome.Benefit);
staticText = "Search your library for an enchantment card and put it onto the battlefield. Then shuffle your library";
}
public EnduringIdealEffect(final EnduringIdealEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
boolean applied = false;
Player you = game.getPlayer(source.getControllerId());
if (you != null) {
TargetCardInLibrary target = new TargetCardInLibrary(filter);
you.searchLibrary(target, game);
Card targetCard = game.getCard(target.getFirstTarget());
if (targetCard != null) {
applied = targetCard.putOntoBattlefield(game, Zone.LIBRARY, source.getSourceId(), you.getId());
}
you.shuffleLibrary(game);
}
return applied;
}
@Override
public EnduringIdealEffect copy() {
return new EnduringIdealEffect(this);
}
}

View file

@ -0,0 +1,122 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.saviorsofkamigawa;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.EpicEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetCardInLibrary;
import mage.target.common.TargetOpponent;
/**
*
* @author jeffwadsworth
*
*/
public class EternalDominion extends CardImpl<EternalDominion> {
public EternalDominion(UUID ownerId) {
super(ownerId, 36, "Eternal Dominion", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{7}{U}{U}{U}");
this.expansionSetCode = "SOK";
this.color.setBlue(true);
// Search target opponent's library for an artifact, creature, enchantment, or land card. Put that card onto the battlefield under your control. Then that player shuffles his or her library.
this.getSpellAbility().addEffect(new EternalDominionEffect());
this.getSpellAbility().addTarget(new TargetOpponent(true));
// Epic
this.getSpellAbility().addEffect(new EpicEffect());
}
public EternalDominion(final EternalDominion card) {
super(card);
}
@Override
public EternalDominion copy() {
return new EternalDominion(this);
}
}
class EternalDominionEffect extends OneShotEffect<EternalDominionEffect> {
private static final FilterCard filter = new FilterCard();
static {
filter.add(Predicates.or(new CardTypePredicate(CardType.ARTIFACT),
new CardTypePredicate(CardType.CREATURE),
new CardTypePredicate(CardType.ENCHANTMENT),
new CardTypePredicate(CardType.LAND)));
}
public EternalDominionEffect() {
super(Outcome.Benefit);
staticText = "Search target opponent's library for an artifact, creature, enchantment, or land card. Put that card onto the battlefield under your control. Then that player shuffles his or her library";
}
public EternalDominionEffect(final EternalDominionEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
boolean applied = false;
Player opponent = game.getPlayer(source.getFirstTarget());
Player you = game.getPlayer(source.getControllerId());
if (opponent != null
&& you != null) {
TargetCardInLibrary target = new TargetCardInLibrary(filter);
you.searchLibrary(target, game, opponent.getId());
Card targetCard = game.getCard(target.getFirstTarget());
if (targetCard != null) {
applied = targetCard.putOntoBattlefield(game, Zone.LIBRARY, source.getSourceId(), you.getId());
}
opponent.shuffleLibrary(game);
}
return applied;
}
@Override
public EternalDominionEffect copy() {
return new EternalDominionEffect(this);
}
}

View file

@ -0,0 +1,114 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.saviorsofkamigawa;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.common.CardsInControllerHandCount;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.EpicEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.filter.FilterCard;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetPlayer;
import mage.target.common.TargetCardInLibrary;
import mage.util.CardUtil;
/**
*
* @author jeffwadsworth
*
*/
public class NeverendingTorment extends CardImpl<NeverendingTorment> {
public NeverendingTorment(UUID ownerId) {
super(ownerId, 83, "Neverending Torment", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{B}");
this.expansionSetCode = "SOK";
this.color.setBlack(true);
// Search target player's library for X cards, where X is the number of cards in your hand, and exile them. Then that player shuffles his or her library.
this.getSpellAbility().addEffect(new NeverendingTormentEffect());
this.getSpellAbility().addTarget(new TargetPlayer(true));
// Epic
this.getSpellAbility().addEffect(new EpicEffect());
}
public NeverendingTorment(final NeverendingTorment card) {
super(card);
}
@Override
public NeverendingTorment copy() {
return new NeverendingTorment(this);
}
}
class NeverendingTormentEffect extends OneShotEffect<NeverendingTormentEffect> {
public NeverendingTormentEffect() {
super(Outcome.Benefit);
staticText = "Search target player's library for X cards, where X is the number of cards in your hand, and exile them. Then that player shuffles his or her library";
}
public NeverendingTormentEffect(final NeverendingTormentEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
UUID exileId = CardUtil.getCardExileZoneId(game, source);
boolean applied = false;
Player targetPlayer = game.getPlayer(source.getFirstTarget());
Player you = game.getPlayer(source.getControllerId());
if (targetPlayer != null
&& you != null) {
TargetCardInLibrary target = new TargetCardInLibrary(new CardsInControllerHandCount().calculate(game, source), new FilterCard());
you.searchLibrary(target, game, targetPlayer.getId());
for (UUID cardId : target.getTargets()) {
final Card targetCard = game.getCard(cardId);
if (targetCard != null) {
applied = targetCard.moveToExile(exileId, "Neverending Torment", source.getSourceId(), game);
}
}
targetPlayer.shuffleLibrary(game);
}
return applied;
}
@Override
public NeverendingTormentEffect copy() {
return new NeverendingTormentEffect(this);
}
}

View file

@ -0,0 +1,125 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.saviorsofkamigawa;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.EpicEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.Target;
import mage.target.common.TargetCreatureOrPlayer;
import mage.util.CardUtil;
/**
*
* @author jeffwadsworth
*
*/
public class UndyingFlames extends CardImpl<UndyingFlames> {
public UndyingFlames(UUID ownerId) {
super(ownerId, 119, "Undying Flames", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{R}");
this.expansionSetCode = "SOK";
this.color.setRed(true);
// Exile cards from the top of your library until you exile a nonland card. Undying Flames deals damage to target creature or player equal to that card's converted mana cost.
this.getSpellAbility().addEffect(new UndyingFlamesEffect());
// Epic
this.getSpellAbility().addEffect(new EpicEffect());
}
public UndyingFlames(final UndyingFlames card) {
super(card);
}
@Override
public UndyingFlames copy() {
return new UndyingFlames(this);
}
}
class UndyingFlamesEffect extends OneShotEffect<UndyingFlamesEffect> {
public UndyingFlamesEffect() {
super(Outcome.Benefit);
staticText = "Exile cards from the top of your library until you exile a nonland card. Undying Flames deals damage to target creature or player equal to that card's converted mana cost";
}
public UndyingFlamesEffect(final UndyingFlamesEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
UUID exileId = CardUtil.getCardExileZoneId(game, source);
boolean applied = false;
Player you = game.getPlayer(source.getControllerId());
while (you != null
&& you.getLibrary().size() > 0) {
Card card = you.getLibrary().removeFromTop(game);
if (card != null) {
if (card.getCardType().contains(CardType.LAND)) {
card.moveToExile(exileId, "Undying Flames", source.getSourceId(), game);
} else {
Target target = new TargetCreatureOrPlayer();
if (you.chooseTarget(Outcome.Damage, target, source, game)) {
Permanent creature = game.getPermanent(target.getFirstTarget());
if (creature != null) {
creature.damage(card.getManaCost().convertedManaCost(), source.getSourceId(), game, true, false);
applied = true;
break;
}
Player player = game.getPlayer(target.getFirstTarget());
if (player != null) {
player.damage(card.getManaCost().convertedManaCost(), source.getSourceId(), game, true, false);
applied = true;
break;
}
}
}
}
}
return applied;
}
@Override
public UndyingFlamesEffect copy() {
return new UndyingFlamesEffect(this);
}
}

View file

@ -0,0 +1,41 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package mage.abilities.common.delayed;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.constants.Duration;
import mage.game.Game;
import mage.game.events.GameEvent;
/**
*
* @author jeffwadsworth
*/
public class AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility extends DelayedTriggeredAbility<AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility> {
public AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility(Effect effect) {
this(effect, Duration.Custom, true);
}
public AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility(Effect effect, Duration duration, Boolean triggerOnlyOnce) {
super(effect, duration, triggerOnlyOnce);
}
public AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility(AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility ability) {
super(ability);
}
@Override
public AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility copy() {
return new AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility(this);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.UPKEEP_STEP_PRE && event.getPlayerId().equals(this.controllerId);
}
}

View file

@ -0,0 +1,149 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package mage.abilities.effects.common;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.common.delayed.AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.stack.Spell;
import mage.game.stack.StackObject;
import mage.players.Player;
/**
*
* @author jeffwadsworth
*
* 702.49. Epic 702.49a Epic represents two spell abilities, one of which
* creates a delayed triggered ability. Epic means For the rest of the game,
* you cant cast spells, and At the beginning of each of your upkeeps for the
* rest of the game, copy this spell except for its epic ability. If the spell
* has any targets, you may choose new targets for the copy. See rule 706.10.
* 702.49b A player cant cast spells once a spell with epic he or she controls
* resolves, but effects (such as the epic ability itself) can still put copies
* of spells onto the stack. *
*/
public class EpicEffect extends OneShotEffect<EpicEffect> {
final String rule = "<br><br/>Epic <i>(For the rest of the game, you can't cast spells. At the beginning of each of your upkeeps for the rest of the game, copy this spell except for its epic ability. If the spell has targets, you may choose new targets for the copy)";
public EpicEffect() {
super(Outcome.Benefit);
staticText = rule;
}
public EpicEffect(final EpicEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
StackObject stackObject = game.getStack().getStackObject(source.getId());
Spell spell = (Spell) stackObject;
spell = spell.copySpell();
spell.setCopiedSpell(true);
spell.setControllerId(source.getControllerId());
// Remove Epic effect from the spell
Effect epicEffect = null;
for (Effect effect : spell.getSpellAbility().getEffects()) {
if (effect instanceof EpicEffect) {
epicEffect = effect;
}
}
spell.getSpellAbility().getEffects().remove(epicEffect);
DelayedTriggeredAbility ability = new AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility(new EpicPushEffect(spell, rule), Duration.EndOfGame, false);
ability.setSourceId(source.getSourceId());
ability.setControllerId(source.getControllerId());
game.addDelayedTriggeredAbility(ability);
game.addEffect(new EpicReplacementEffect(), source);
return true;
}
return false;
}
@Override
public EpicEffect copy() {
return new EpicEffect(this);
}
}
class EpicReplacementEffect extends ReplacementEffectImpl<EpicReplacementEffect> {
public EpicReplacementEffect() {
super(Duration.EndOfGame, Outcome.Neutral);
staticText = "For the rest of the game, you can't cast spells";
}
public EpicReplacementEffect(final EpicReplacementEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public EpicReplacementEffect copy() {
return new EpicReplacementEffect(this);
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
return true;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == GameEvent.EventType.CAST_SPELL
&& source.getControllerId() == event.getPlayerId()) {
MageObject object = game.getObject(event.getSourceId());
if (object != null) {
return true;
}
}
return false;
}
}
class EpicPushEffect extends OneShotEffect<EpicPushEffect> {
final private Spell spell;
public EpicPushEffect(Spell spell, String ruleText) {
super(Outcome.Copy);
this.spell = spell;
staticText = ruleText;
}
public EpicPushEffect(final EpicPushEffect effect) {
super(effect);
this.spell = effect.spell;
}
@Override
public boolean apply(Game game, Ability source) {
if (spell != null) {
game.getStack().push(spell);
spell.chooseNewTargets(game, spell.getControllerId());
}
return false;
}
@Override
public EpicPushEffect copy() {
return new EpicPushEffect(this);
}
}