Implemented Irencrag Feat

This commit is contained in:
Evan Kranzler 2019-09-14 10:08:59 -04:00
parent 5579407144
commit 23c6bf5bd2
2 changed files with 98 additions and 0 deletions

View file

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

View file

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