Implemented Ignite the Future

This commit is contained in:
Evan Kranzler 2019-08-06 14:55:26 -04:00
parent 994777c7bf
commit 36a0a34585
2 changed files with 150 additions and 0 deletions

View file

@ -0,0 +1,149 @@
package mage.cards.i;
import mage.abilities.Ability;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.AsThoughEffectImpl;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.FlashbackAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.game.Game;
import mage.game.stack.Spell;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
import java.util.Set;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class IgniteTheFuture extends CardImpl {
public IgniteTheFuture(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{R}");
// Exile the top three cards of your library. Until the end of your next turn, you may play those cards. If this spell was cast from a graveyard, you may play cards this way without paying their mana costs.
this.getSpellAbility().addEffect(new IgniteTheFutureEffect());
// Flashback {7}{R}
this.addAbility(new FlashbackAbility(new ManaCostsImpl("{7}{R}"), TimingRule.SORCERY));
}
private IgniteTheFuture(final IgniteTheFuture card) {
super(card);
}
@Override
public IgniteTheFuture copy() {
return new IgniteTheFuture(this);
}
}
class IgniteTheFutureEffect extends OneShotEffect {
IgniteTheFutureEffect() {
super(Outcome.PlayForFree);
this.staticText = "Exile the top three cards of your library. " +
"Until the end of your next turn, you may play those cards. " +
"If this spell was cast from a graveyard, " +
"you may play cards this way without paying their mana costs.";
}
private IgniteTheFutureEffect(final IgniteTheFutureEffect effect) {
super(effect);
}
@Override
public IgniteTheFutureEffect copy() {
return new IgniteTheFutureEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Spell spell = (Spell) game.getStack().getStackObject(source.getSourceId());
if (controller == null || spell == null) {
return false;
}
boolean forFree = spell.getFromZone() == Zone.GRAVEYARD;
Set<Card> cards = controller.getLibrary().getTopCards(game, 3);
controller.moveCards(cards, Zone.EXILED, source, game);
cards.stream().forEach(card -> {
ContinuousEffect effect = new IgniteTheFutureMayPlayEffect(forFree);
effect.setTargetPointer(new FixedTarget(card.getId(), game));
game.addEffect(effect, source);
});
return true;
}
}
class IgniteTheFutureMayPlayEffect extends AsThoughEffectImpl {
private int castOnTurn = 0;
private final boolean forFree;
IgniteTheFutureMayPlayEffect(boolean forFree) {
super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, Duration.Custom, Outcome.Benefit);
this.forFree = forFree;
if (forFree) {
this.staticText = "Until the end of your next turn, you may play that card without playing its mana cost.";
} else {
this.staticText = "Until the end of your next turn, you may play that card.";
}
}
private IgniteTheFutureMayPlayEffect(final IgniteTheFutureMayPlayEffect effect) {
super(effect);
castOnTurn = effect.castOnTurn;
this.forFree = effect.forFree;
}
@Override
public IgniteTheFutureMayPlayEffect copy() {
return new IgniteTheFutureMayPlayEffect(this);
}
@Override
public void init(Ability source, Game game) {
super.init(source, game);
castOnTurn = game.getTurnNum();
}
@Override
public boolean isInactive(Ability source, Game game) {
return castOnTurn != game.getTurnNum()
&& game.getPhase().getStep().getType() == PhaseStep.END_TURN
&& game.isActivePlayer(source.getControllerId());
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
if (!source.isControlledBy(affectedControllerId)
|| !getTargetPointer().getTargets(game, source).contains(objectId)) {
return false;
}
if (!forFree) {
return true;
}
Card card = game.getCard(objectId);
if (card == null || card.isLand() || card.getSpellAbility().getCosts() == null) {
return true;
}
Player player = game.getPlayer(affectedControllerId);
if (player != null) {
player.setCastSourceIdWithAlternateMana(objectId, null, card.getSpellAbility().getCosts());
}
return true;
}
}

View file

@ -38,6 +38,7 @@ public final class Commander2019Edition extends ExpansionSet {
cards.add(new SetCardInfo("Great Oak Guardian", 170, Rarity.UNCOMMON, mage.cards.g.GreatOakGuardian.class));
cards.add(new SetCardInfo("Grismold, the Dreadsower", 44, Rarity.RARE, mage.cards.g.GrismoldTheDreadsower.class));
cards.add(new SetCardInfo("Hooded Hydra", 172, Rarity.MYTHIC, mage.cards.h.HoodedHydra.class));
cards.add(new SetCardInfo("Ignite the Future", 27, Rarity.RARE, mage.cards.i.IgniteTheFuture.class));
cards.add(new SetCardInfo("Island", 291, Rarity.LAND, mage.cards.basiclands.Island.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Ixidron", 87, Rarity.RARE, mage.cards.i.Ixidron.class));
cards.add(new SetCardInfo("Kadena's Silencer", 8, Rarity.RARE, mage.cards.k.KadenasSilencer.class));