From 405a6d7c2a0ed8d348655853071d2bdc7a0f2bef Mon Sep 17 00:00:00 2001 From: theelk801 Date: Wed, 13 Nov 2024 17:15:45 -0500 Subject: [PATCH] [J25] Implement Gornog, the Red Reaper --- .../src/mage/cards/b/BoldwyrIntimidator.java | 58 ++------- .../src/mage/cards/g/GornogTheRedReaper.java | 117 ++++++++++++++++++ .../src/mage/cards/k/KarganIntimidator.java | 42 +------ .../src/mage/sets/FoundationsJumpstart.java | 1 + .../CowardsCantBlockWarriorsEffect.java | 41 ++++++ 5 files changed, 174 insertions(+), 85 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/g/GornogTheRedReaper.java create mode 100644 Mage/src/main/java/mage/abilities/effects/common/combat/CowardsCantBlockWarriorsEffect.java diff --git a/Mage.Sets/src/mage/cards/b/BoldwyrIntimidator.java b/Mage.Sets/src/mage/cards/b/BoldwyrIntimidator.java index bfc8b26b727..8e79d57b584 100644 --- a/Mage.Sets/src/mage/cards/b/BoldwyrIntimidator.java +++ b/Mage.Sets/src/mage/cards/b/BoldwyrIntimidator.java @@ -5,17 +5,13 @@ import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.effects.Effect; -import mage.abilities.effects.RestrictionEffect; +import mage.abilities.effects.common.combat.CowardsCantBlockWarriorsEffect; import mage.abilities.effects.common.continuous.BecomesCreatureTypeTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Duration; import mage.constants.SubType; -import mage.constants.Zone; -import mage.game.Game; -import mage.game.permanent.Permanent; import mage.target.common.TargetCreaturePermanent; import java.util.UUID; @@ -32,19 +28,23 @@ public final class BoldwyrIntimidator extends CardImpl { this.toughness = new MageInt(5); // Cowards can't block Warriors. - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoldwyrIntimidatorEffect())); + this.addAbility(new SimpleStaticAbility(new CowardsCantBlockWarriorsEffect())); // {R}: Target creature becomes a Coward until end of turn. - Effect effect = new BecomesCreatureTypeTargetEffect(Duration.EndOfTurn, SubType.COWARD); - effect.setText("Target creature becomes a Coward until end of turn"); - Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new ManaCostsImpl<>("{R}")); + Ability ability = new SimpleActivatedAbility( + new BecomesCreatureTypeTargetEffect(Duration.EndOfTurn, SubType.COWARD) + .setText("target creature becomes a Coward until end of turn"), + new ManaCostsImpl<>("{R}") + ); ability.addTarget(new TargetCreaturePermanent()); this.addAbility(ability); // {2}{R}: Target creature becomes a Warrior until end of turn. - effect = new BecomesCreatureTypeTargetEffect(Duration.EndOfTurn, SubType.WARRIOR); - effect.setText("Target creature becomes a Warrior until end of turn"); - ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new ManaCostsImpl<>("{2}{R}")); + ability = new SimpleActivatedAbility( + new BecomesCreatureTypeTargetEffect(Duration.EndOfTurn, SubType.WARRIOR) + .setText("target creature becomes a Warrior until end of turn"), + new ManaCostsImpl<>("{2}{R}") + ); ability.addTarget(new TargetCreaturePermanent()); this.addAbility(ability); } @@ -58,37 +58,3 @@ public final class BoldwyrIntimidator extends CardImpl { return new BoldwyrIntimidator(this); } } - -class BoldwyrIntimidatorEffect extends RestrictionEffect { - - BoldwyrIntimidatorEffect() { - super(Duration.WhileOnBattlefield); - staticText = "Cowards can't block Warriors"; - } - - private BoldwyrIntimidatorEffect(final BoldwyrIntimidatorEffect effect) { - super(effect); - } - - @Override - public boolean applies(Permanent permanent, Ability source, Game game) { - Permanent sourcePermanent = game.getPermanent(source.getSourceId()); - return sourcePermanent != null; - } - - @Override - public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) { - if (attacker != null && blocker != null) { - Permanent sourcePermanent = game.getPermanent(source.getSourceId()); - if (sourcePermanent != null && attacker.hasSubtype(SubType.WARRIOR, game)) { - return !blocker.hasSubtype(SubType.COWARD, game); - } - } - return true; - } - - @Override - public BoldwyrIntimidatorEffect copy() { - return new BoldwyrIntimidatorEffect(this); - } -} diff --git a/Mage.Sets/src/mage/cards/g/GornogTheRedReaper.java b/Mage.Sets/src/mage/cards/g/GornogTheRedReaper.java new file mode 100644 index 00000000000..31b916ad596 --- /dev/null +++ b/Mage.Sets/src/mage/cards/g/GornogTheRedReaper.java @@ -0,0 +1,117 @@ +package mage.cards.g; + +import mage.MageInt; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount; +import mage.abilities.dynamicvalue.common.StaticValue; +import mage.abilities.effects.common.combat.CowardsCantBlockWarriorsEffect; +import mage.abilities.effects.common.continuous.BecomesCreatureTypeTargetEffect; +import mage.abilities.effects.common.continuous.BoostControlledEffect; +import mage.abilities.hint.Hint; +import mage.abilities.hint.ValueHint; +import mage.abilities.keyword.HasteAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.permanent.AttackingPredicate; +import mage.filter.predicate.permanent.PermanentIdPredicate; +import mage.game.Game; +import mage.game.events.DefenderAttackedEvent; +import mage.game.events.GameEvent; +import mage.target.TargetPermanent; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class GornogTheRedReaper extends CardImpl { + + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent(SubType.WARRIOR, "Attacking Warriors"); + private static final FilterPermanent filter2 = new FilterPermanent(SubType.COWARD, "Cowards your opponents control"); + + static { + filter.add(AttackingPredicate.instance); + filter2.add(TargetController.OPPONENT.getControllerPredicate()); + } + + private static final DynamicValue xValue = new PermanentsOnBattlefieldCount(filter2, null); + private static final Hint hint = new ValueHint(filter2.getMessage(), xValue); + + public GornogTheRedReaper(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{R}"); + + this.supertype.add(SuperType.LEGENDARY); + this.subtype.add(SubType.MINOTAUR); + this.subtype.add(SubType.WARRIOR); + this.power = new MageInt(2); + this.toughness = new MageInt(3); + + // Haste + this.addAbility(HasteAbility.getInstance()); + + // Cowards can't block Warriors. + this.addAbility(new SimpleStaticAbility(new CowardsCantBlockWarriorsEffect())); + + // Whenever one or more Warriors you control attack a player, target creature that player controls becomes a Coward. + this.addAbility(new GornogTheRedReaperTriggeredAbility()); + + // Attacking Warriors you control get +X/+0, where X is the number of Cowards your opponents control. + this.addAbility(new SimpleStaticAbility(new BoostControlledEffect( + xValue, StaticValue.get(0), Duration.WhileOnBattlefield, filter, false + )).addHint(hint)); + } + + private GornogTheRedReaper(final GornogTheRedReaper card) { + super(card); + } + + @Override + public GornogTheRedReaper copy() { + return new GornogTheRedReaper(this); + } +} + +class GornogTheRedReaperTriggeredAbility extends TriggeredAbilityImpl { + + GornogTheRedReaperTriggeredAbility() { + super(Zone.BATTLEFIELD, new BecomesCreatureTypeTargetEffect(Duration.EndOfTurn, SubType.COWARD) + .setText("target creature that player controls becomes a Coward")); + this.setTriggerPhrase("Whenever one or more Warriors you control attack a player, "); + } + + private GornogTheRedReaperTriggeredAbility(final GornogTheRedReaperTriggeredAbility ability) { + super(ability); + } + + @Override + public GornogTheRedReaperTriggeredAbility copy() { + return new GornogTheRedReaperTriggeredAbility(this); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.DEFENDER_ATTACKED; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (!isControlledBy(event.getPlayerId()) + || game.getPlayer(event.getTargetId()) == null + || ((DefenderAttackedEvent) event) + .getAttackers(game) + .stream() + .noneMatch(permanent -> permanent.hasSubtype(SubType.WARRIOR, game))) { + return false; + } + FilterPermanent filter = new FilterCreaturePermanent("creature controlled by defending player"); + filter.add(new PermanentIdPredicate(event.getTargetId())); + this.getTargets().clear(); + this.addTarget(new TargetPermanent(filter)); + return true; + } +} diff --git a/Mage.Sets/src/mage/cards/k/KarganIntimidator.java b/Mage.Sets/src/mage/cards/k/KarganIntimidator.java index 98207fe74cb..6ed5775b387 100644 --- a/Mage.Sets/src/mage/cards/k/KarganIntimidator.java +++ b/Mage.Sets/src/mage/cards/k/KarganIntimidator.java @@ -6,7 +6,7 @@ import mage.abilities.Mode; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.costs.mana.GenericManaCost; -import mage.abilities.effects.RestrictionEffect; +import mage.abilities.effects.common.combat.CowardsCantBlockWarriorsEffect; import mage.abilities.effects.common.continuous.BecomesCreatureTypeTargetEffect; import mage.abilities.effects.common.continuous.BoostSourceEffect; import mage.abilities.effects.common.continuous.GainAbilityTargetEffect; @@ -18,8 +18,6 @@ import mage.constants.CardType; import mage.constants.Duration; import mage.constants.SubType; import mage.filter.FilterPermanent; -import mage.game.Game; -import mage.game.permanent.Permanent; import mage.target.TargetPermanent; import mage.target.common.TargetCreaturePermanent; @@ -41,7 +39,7 @@ public final class KarganIntimidator extends CardImpl { this.toughness = new MageInt(1); // Cowards can't block Warriors. - this.addAbility(new SimpleStaticAbility(new KarganIntimidatorEffect())); + this.addAbility(new SimpleStaticAbility(new CowardsCantBlockWarriorsEffect())); // {1}: Choose one that hasn't been chosen this turn — // • Kargan Intimidator gets +1/+1 until end of turn. @@ -54,7 +52,7 @@ public final class KarganIntimidator extends CardImpl { // • Target creature becomes a Coward until end of turn. Mode mode = new Mode(new BecomesCreatureTypeTargetEffect( Duration.EndOfTurn, SubType.COWARD - ).setText("Target creature becomes a Coward until end of turn")); + ).setText("target creature becomes a Coward until end of turn")); mode.addTarget(new TargetCreaturePermanent()); mode.setModeTag("target becomes a Coward"); ability.addMode(mode); @@ -78,37 +76,3 @@ public final class KarganIntimidator extends CardImpl { return new KarganIntimidator(this); } } - -class KarganIntimidatorEffect extends RestrictionEffect { - - KarganIntimidatorEffect() { - super(Duration.WhileOnBattlefield); - staticText = "Cowards can't block Warriors"; - } - - private KarganIntimidatorEffect(final KarganIntimidatorEffect effect) { - super(effect); - } - - @Override - public boolean applies(Permanent permanent, Ability source, Game game) { - Permanent sourcePermanent = game.getPermanent(source.getSourceId()); - return sourcePermanent != null; - } - - @Override - public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) { - if (attacker != null && blocker != null) { - Permanent sourcePermanent = game.getPermanent(source.getSourceId()); - if (sourcePermanent != null && attacker.hasSubtype(SubType.WARRIOR, game)) { - return !blocker.hasSubtype(SubType.COWARD, game); - } - } - return true; - } - - @Override - public KarganIntimidatorEffect copy() { - return new KarganIntimidatorEffect(this); - } -} diff --git a/Mage.Sets/src/mage/sets/FoundationsJumpstart.java b/Mage.Sets/src/mage/sets/FoundationsJumpstart.java index a1f49a93eda..97349715655 100644 --- a/Mage.Sets/src/mage/sets/FoundationsJumpstart.java +++ b/Mage.Sets/src/mage/sets/FoundationsJumpstart.java @@ -325,6 +325,7 @@ public final class FoundationsJumpstart extends ExpansionSet { cards.add(new SetCardInfo("Gorex, the Tombshell", 67, Rarity.RARE, mage.cards.g.GorexTheTombshell.class)); cards.add(new SetCardInfo("Gorging Vulture", 449, Rarity.COMMON, mage.cards.g.GorgingVulture.class)); cards.add(new SetCardInfo("Gorgon Flail", 752, Rarity.UNCOMMON, mage.cards.g.GorgonFlail.class)); + cards.add(new SetCardInfo("Gornog, the Red Reaper", 49, Rarity.RARE, mage.cards.g.GornogTheRedReaper.class)); cards.add(new SetCardInfo("Grave Strength", 450, Rarity.UNCOMMON, mage.cards.g.GraveStrength.class)); cards.add(new SetCardInfo("Graveblade Marauder", 451, Rarity.UNCOMMON, mage.cards.g.GravebladeMarauder.class)); cards.add(new SetCardInfo("Gravedigger", 452, Rarity.COMMON, mage.cards.g.Gravedigger.class)); diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CowardsCantBlockWarriorsEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CowardsCantBlockWarriorsEffect.java new file mode 100644 index 00000000000..6e53e26c3eb --- /dev/null +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CowardsCantBlockWarriorsEffect.java @@ -0,0 +1,41 @@ +package mage.abilities.effects.common.combat; + +import mage.abilities.Ability; +import mage.abilities.effects.RestrictionEffect; +import mage.constants.Duration; +import mage.constants.SubType; +import mage.game.Game; +import mage.game.permanent.Permanent; + +/** + * @author TheElk801 + */ +public class CowardsCantBlockWarriorsEffect extends RestrictionEffect { + + public CowardsCantBlockWarriorsEffect() { + super(Duration.WhileOnBattlefield); + staticText = "Cowards can't block Warriors"; + } + + private CowardsCantBlockWarriorsEffect(final CowardsCantBlockWarriorsEffect effect) { + super(effect); + } + + @Override + public boolean applies(Permanent permanent, Ability source, Game game) { + return true; + } + + @Override + public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) { + return attacker == null + || blocker == null + || !attacker.hasSubtype(SubType.WARRIOR, game) + || !blocker.hasSubtype(SubType.COWARD, game); + } + + @Override + public CowardsCantBlockWarriorsEffect copy() { + return new CowardsCantBlockWarriorsEffect(this); + } +}