From e3df7b95f9b1ef51723155df42e4252b64d371a2 Mon Sep 17 00:00:00 2001 From: "Alex W. Jackson" Date: Thu, 8 Sep 2022 17:15:18 -0400 Subject: [PATCH] [SCG] Implemented Rock Jockey --- Mage.Sets/src/mage/cards/r/RockJockey.java | 89 ++++++++++++++++++++++ Mage.Sets/src/mage/sets/Scourge.java | 1 + 2 files changed, 90 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/r/RockJockey.java diff --git a/Mage.Sets/src/mage/cards/r/RockJockey.java b/Mage.Sets/src/mage/cards/r/RockJockey.java new file mode 100644 index 00000000000..ae2e5f69c6a --- /dev/null +++ b/Mage.Sets/src/mage/cards/r/RockJockey.java @@ -0,0 +1,89 @@ +package mage.cards.r; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.CastOnlyIfConditionIsTrueAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.condition.InvertCondition; +import mage.abilities.condition.common.PlayLandCondition; +import mage.abilities.effects.ContinuousRuleModifyingEffectImpl; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.watchers.common.PlayLandWatcher; +import mage.watchers.common.SpellsCastWatcher; + +import java.util.Objects; +import java.util.UUID; + +/** + * + * @author awjackson + */ +public final class RockJockey extends CardImpl { + + public RockJockey(UUID ownerId, CardSetInfo setInfo) { + super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{R}"); + this.subtype.add(SubType.GOBLIN); + + this.power = new MageInt(3); + this.toughness = new MageInt(3); + + // You can't cast this spell if you've played a land this turn. + this.addAbility(new CastOnlyIfConditionIsTrueAbility( + new InvertCondition(PlayLandCondition.instance), + "You can't cast this spell if you've played a land this turn" + ), new PlayLandWatcher()); + + // You can't play lands if you've cast Rock Jockey this turn. + this.addAbility(new SimpleStaticAbility(new RockJockeyEffect()), new SpellsCastWatcher()); + } + + private RockJockey(final RockJockey card) { + super(card); + } + + @Override + public RockJockey copy() { + return new RockJockey(this); + } +} + +class RockJockeyEffect extends ContinuousRuleModifyingEffectImpl { + + public RockJockeyEffect() { + super(Duration.WhileOnBattlefield, Outcome.Detriment); + this.staticText = "You can't play lands if you've cast {this} this turn"; + } + + public RockJockeyEffect(final RockJockeyEffect effect) { + super(effect); + } + + @Override + public RockJockeyEffect copy() { + return new RockJockeyEffect(this); + } + + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.PLAY_LAND; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + if (!event.getPlayerId().equals(source.getControllerId())) { + return false; + } + SpellsCastWatcher watcher = game.getState().getWatcher(SpellsCastWatcher.class); + if (watcher == null) { + return false; + } + return watcher.getSpellsCastThisTurn(source.getControllerId()) + .stream() + .filter(Objects::nonNull) + .anyMatch(spell -> spell.getSourceId().equals(source.getSourceId())); + } +} diff --git a/Mage.Sets/src/mage/sets/Scourge.java b/Mage.Sets/src/mage/sets/Scourge.java index 2ac19bcedc7..d9cb2429dc9 100644 --- a/Mage.Sets/src/mage/sets/Scourge.java +++ b/Mage.Sets/src/mage/sets/Scourge.java @@ -130,6 +130,7 @@ public final class Scourge extends ExpansionSet { cards.add(new SetCardInfo("Recuperate", 21, Rarity.COMMON, mage.cards.r.Recuperate.class)); cards.add(new SetCardInfo("Reward the Faithful", 22, Rarity.UNCOMMON, mage.cards.r.RewardTheFaithful.class)); cards.add(new SetCardInfo("Riptide Survivor", 48, Rarity.UNCOMMON, mage.cards.r.RiptideSurvivor.class)); + cards.add(new SetCardInfo("Rock Jockey", 101, Rarity.COMMON, mage.cards.r.RockJockey.class)); cards.add(new SetCardInfo("Root Elemental", 127, Rarity.RARE, mage.cards.r.RootElemental.class)); cards.add(new SetCardInfo("Rush of Knowledge", 49, Rarity.COMMON, mage.cards.r.RushOfKnowledge.class)); cards.add(new SetCardInfo("Scattershot", 102, Rarity.COMMON, mage.cards.s.Scattershot.class));