diff --git a/Mage.Sets/src/mage/cards/i/IrencragFeat.java b/Mage.Sets/src/mage/cards/i/IrencragFeat.java new file mode 100644 index 00000000000..8ff350b5eac --- /dev/null +++ b/Mage.Sets/src/mage/cards/i/IrencragFeat.java @@ -0,0 +1,97 @@ +package mage.cards.i; + +import mage.abilities.Ability; +import mage.abilities.effects.ContinuousRuleModifyingEffectImpl; +import mage.abilities.effects.OneShotEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.watchers.common.CastSpellLastTurnWatcher; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class IrencragFeat extends CardImpl { + + public IrencragFeat(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{R}{R}{R}"); + + // Add seven {R}. You can cast only one more spell this turn. + this.getSpellAbility().addEffect(new IrencragFeatEffect()); + } + + private IrencragFeat(final IrencragFeat card) { + super(card); + } + + @Override + public IrencragFeat copy() { + return new IrencragFeat(this); + } +} + +class IrencragFeatEffect extends OneShotEffect { + + IrencragFeatEffect() { + super(Outcome.Benefit); + staticText = "Add seven {R}. You can cast only one more spell this turn."; + } + + private IrencragFeatEffect(final IrencragFeatEffect effect) { + super(effect); + } + + @Override + public IrencragFeatEffect copy() { + return new IrencragFeatEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + CastSpellLastTurnWatcher watcher = game.getState().getWatcher(CastSpellLastTurnWatcher.class); + if (watcher == null) { + return false; + } + int spellsCast = watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(source.getControllerId()); + game.addEffect(new IrencragFeatCantCastEffect(spellsCast), source); + return true; + } +} + +class IrencragFeatCantCastEffect extends ContinuousRuleModifyingEffectImpl { + + private final int spellsCast; + + IrencragFeatCantCastEffect(int spellsCast) { + super(Duration.WhileOnBattlefield, Outcome.Detriment); + this.spellsCast = spellsCast; + } + + private IrencragFeatCantCastEffect(final IrencragFeatCantCastEffect effect) { + super(effect); + this.spellsCast = effect.spellsCast; + } + + @Override + public IrencragFeatCantCastEffect copy() { + return new IrencragFeatCantCastEffect(this); + } + + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.CAST_SPELL; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + CastSpellLastTurnWatcher watcher = game.getState().getWatcher(CastSpellLastTurnWatcher.class); + return event.getPlayerId().equals(source.getControllerId()) + && watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(event.getPlayerId()) > spellsCast + 1; + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/ThroneOfEldraine.java b/Mage.Sets/src/mage/sets/ThroneOfEldraine.java index 2053f49f9c9..26abff69921 100644 --- a/Mage.Sets/src/mage/sets/ThroneOfEldraine.java +++ b/Mage.Sets/src/mage/sets/ThroneOfEldraine.java @@ -99,6 +99,7 @@ public final class ThroneOfEldraine extends ExpansionSet { cards.add(new SetCardInfo("Insatiable Appetite", 162, Rarity.COMMON, mage.cards.i.InsatiableAppetite.class)); cards.add(new SetCardInfo("Inspiring Veteran", 194, Rarity.UNCOMMON, mage.cards.i.InspiringVeteran.class)); cards.add(new SetCardInfo("Into the Story", 50, Rarity.UNCOMMON, mage.cards.i.IntoTheStory.class)); + cards.add(new SetCardInfo("Irencrag Feat", 127, Rarity.RARE, mage.cards.i.IrencragFeat.class)); cards.add(new SetCardInfo("Joust", 129, Rarity.UNCOMMON, mage.cards.j.Joust.class)); cards.add(new SetCardInfo("Jousting Dummy", 224, Rarity.COMMON, mage.cards.j.JoustingDummy.class)); cards.add(new SetCardInfo("Keeper of Fables", 163, Rarity.UNCOMMON, mage.cards.k.KeeperOfFables.class));