diff --git a/Mage.Sets/src/mage/cards/p/PistonFistCyclops.java b/Mage.Sets/src/mage/cards/p/PistonFistCyclops.java new file mode 100644 index 00000000000..2aa04190912 --- /dev/null +++ b/Mage.Sets/src/mage/cards/p/PistonFistCyclops.java @@ -0,0 +1,85 @@ +package mage.cards.p; + +import java.util.List; +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.condition.Condition; +import mage.abilities.decorator.ConditionalContinuousEffect; +import mage.abilities.effects.common.combat.CanAttackAsThoughItDidntHaveDefenderSourceEffect; +import mage.constants.SubType; +import mage.abilities.keyword.DefenderAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.stack.Spell; +import mage.watchers.common.SpellsCastWatcher; + +/** + * + * @author TheElk801 + */ +public final class PistonFistCyclops extends CardImpl { + + public PistonFistCyclops(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{U/R}{U/R}"); + + this.subtype.add(SubType.CYCLOPS); + this.power = new MageInt(4); + this.toughness = new MageInt(3); + + // Defender + this.addAbility(DefenderAbility.getInstance()); + + // As long as you've cast an instant or sorcery spell this turn, Piston-Fist Cyclops can attack as though it didn't have defender. + this.addAbility(new SimpleStaticAbility( + Zone.BATTLEFIELD, + new ConditionalContinuousEffect( + new CanAttackAsThoughItDidntHaveDefenderSourceEffect( + Duration.WhileOnBattlefield + ), PistonFistCyclopsCondition.instance, + "As long as you've cast an instant or sorcery spell this turn, " + + "{this} can attack as though it didn't have defender." + ) + ), new SpellsCastWatcher()); + } + + public PistonFistCyclops(final PistonFistCyclops card) { + super(card); + } + + @Override + public PistonFistCyclops copy() { + return new PistonFistCyclops(this); + } +} + +enum PistonFistCyclopsCondition implements Condition { + instance; + + @Override + public boolean apply(Game game, Ability source) { + SpellsCastWatcher watcher + = (SpellsCastWatcher) game.getState().getWatchers().get( + SpellsCastWatcher.class.getSimpleName() + ); + if (watcher == null) { + return false; + } + List spells = watcher.getSpellsCastThisTurn(source.getControllerId()); + if (spells == null) { + return false; + } + for (Spell spell : spells) { + if (!spell.getSourceId().equals(source.getSourceId()) + && spell.isInstantOrSorcery()) { + return true; + } + } + return false; + } +} diff --git a/Mage.Sets/src/mage/sets/GuildsOfRavnica.java b/Mage.Sets/src/mage/sets/GuildsOfRavnica.java index eaa6f56b15b..513f70c44e3 100644 --- a/Mage.Sets/src/mage/sets/GuildsOfRavnica.java +++ b/Mage.Sets/src/mage/sets/GuildsOfRavnica.java @@ -128,6 +128,7 @@ public final class GuildsOfRavnica extends ExpansionSet { cards.add(new SetCardInfo("Overgrown Tomb", 253, Rarity.RARE, mage.cards.o.OvergrownTomb.class)); cards.add(new SetCardInfo("Parhelion Patrol", 22, Rarity.COMMON, mage.cards.p.ParhelionPatrol.class)); cards.add(new SetCardInfo("Passwall Adept", 50, Rarity.COMMON, mage.cards.p.PasswallAdept.class)); + cards.add(new SetCardInfo("Piston-Fist Cyclops", 217, Rarity.COMMON, mage.cards.p.PistonFistCyclops.class)); cards.add(new SetCardInfo("Plains", 260, Rarity.LAND, mage.cards.basiclands.Plains.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Price of Fame", 83, Rarity.UNCOMMON, mage.cards.p.PriceOfFame.class)); cards.add(new SetCardInfo("Quasiduplicate", 51, Rarity.RARE, mage.cards.q.Quasiduplicate.class));