From 7cf52ce1369a5b6020b1ac220a042934191c3003 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Wed, 10 Jun 2020 20:21:03 -0400 Subject: [PATCH] Implemented Pursued Whale --- Mage.Sets/src/mage/cards/p/PursuedWhale.java | 120 ++++++++++++++++++ Mage.Sets/src/mage/sets/CoreSet2021.java | 1 + .../permanent/token/PursuedWhaleToken.java | 47 +++++++ 3 files changed, 168 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/p/PursuedWhale.java create mode 100644 Mage/src/main/java/mage/game/permanent/token/PursuedWhaleToken.java diff --git a/Mage.Sets/src/mage/cards/p/PursuedWhale.java b/Mage.Sets/src/mage/cards/p/PursuedWhale.java new file mode 100644 index 0000000000..fd9ca15ab8 --- /dev/null +++ b/Mage.Sets/src/mage/cards/p/PursuedWhale.java @@ -0,0 +1,120 @@ +package mage.cards.p; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.Mode; +import mage.abilities.SpellAbility; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.cost.CostModificationEffectImpl; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.game.Game; +import mage.game.permanent.token.PursuedWhaleToken; +import mage.game.permanent.token.Token; +import mage.target.Target; +import mage.util.CardUtil; + +import java.util.Collection; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class PursuedWhale extends CardImpl { + + public PursuedWhale(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{U}{U}"); + + this.subtype.add(SubType.WHALE); + this.power = new MageInt(8); + this.toughness = new MageInt(8); + + // When Pursued Whale enters the battlefield, each opponent creates a 1/1 red Pirate creature token with "This creature can't block" and "Creatures you control attack each combat if able." + this.addAbility(new EntersBattlefieldTriggeredAbility(new PursuedWhaleTokenEffect())); + + // Spells your opponents cast that target Pursued Whale cost {3} more to cast. + this.addAbility(new SimpleStaticAbility(new PursuedWhaleCostIncreaseEffect())); + } + + private PursuedWhale(final PursuedWhale card) { + super(card); + } + + @Override + public PursuedWhale copy() { + return new PursuedWhale(this); + } +} + +class PursuedWhaleTokenEffect extends OneShotEffect { + + private static final Token token = new PursuedWhaleToken(); + + PursuedWhaleTokenEffect() { + super(Outcome.Benefit); + staticText = "each opponent creates a 1/1 red Pirate creature token with " + + "\"This creature can't block\" and \"Creatures you control attack each combat if able.\""; + } + + private PursuedWhaleTokenEffect(final PursuedWhaleTokenEffect effect) { + super(effect); + } + + @Override + public PursuedWhaleTokenEffect copy() { + return new PursuedWhaleTokenEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + for (UUID playerId : game.getOpponents(source.getControllerId())) { + token.putOntoBattlefield(1, game, source.getSourceId(), playerId); + } + return true; + } +} + +class PursuedWhaleCostIncreaseEffect extends CostModificationEffectImpl { + + PursuedWhaleCostIncreaseEffect() { + super(Duration.WhileOnBattlefield, Outcome.Benefit, CostModificationType.INCREASE_COST); + staticText = "Spells your opponents cast that target {this} cost {3} more to cast"; + } + + private PursuedWhaleCostIncreaseEffect(PursuedWhaleCostIncreaseEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source, Ability abilityToModify) { + SpellAbility spellAbility = (SpellAbility) abilityToModify; + CardUtil.adjustCost(spellAbility, -3); + return true; + } + + @Override + public boolean applies(Ability abilityToModify, Ability source, Game game) { + if (!(abilityToModify instanceof SpellAbility) + || !game.getOpponents(source.getControllerId()).contains(abilityToModify.getControllerId())) { + return false; + } + return abilityToModify + .getModes() + .getSelectedModes() + .stream() + .map(uuid -> abilityToModify.getModes().get(uuid)) + .map(Mode::getTargets) + .flatMap(Collection::stream) + .map(Target::getTargets) + .flatMap(Collection::stream) + .anyMatch(uuid -> uuid.equals(source.getSourceId())); + } + + @Override + public PursuedWhaleCostIncreaseEffect copy() { + return new PursuedWhaleCostIncreaseEffect(this); + } +} diff --git a/Mage.Sets/src/mage/sets/CoreSet2021.java b/Mage.Sets/src/mage/sets/CoreSet2021.java index 071c212fdc..2d8073f853 100644 --- a/Mage.Sets/src/mage/sets/CoreSet2021.java +++ b/Mage.Sets/src/mage/sets/CoreSet2021.java @@ -97,6 +97,7 @@ public final class CoreSet2021 extends ExpansionSet { cards.add(new SetCardInfo("Plains", 309, Rarity.LAND, mage.cards.basiclands.Plains.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Predatory Wurm", 338, Rarity.UNCOMMON, mage.cards.p.PredatoryWurm.class)); cards.add(new SetCardInfo("Pridemalkin", 196, Rarity.COMMON, mage.cards.p.Pridemalkin.class)); + cards.add(new SetCardInfo("Pursued Whale", 60, Rarity.RARE, mage.cards.p.PursuedWhale.class)); cards.add(new SetCardInfo("Quirion Dryad", 198, Rarity.UNCOMMON, mage.cards.q.QuirionDryad.class)); cards.add(new SetCardInfo("Radiant Fountain", 248, Rarity.COMMON, mage.cards.r.RadiantFountain.class)); cards.add(new SetCardInfo("Rain of Revelation", 61, Rarity.UNCOMMON, mage.cards.r.RainOfRevelation.class)); diff --git a/Mage/src/main/java/mage/game/permanent/token/PursuedWhaleToken.java b/Mage/src/main/java/mage/game/permanent/token/PursuedWhaleToken.java new file mode 100644 index 0000000000..3363fe182a --- /dev/null +++ b/Mage/src/main/java/mage/game/permanent/token/PursuedWhaleToken.java @@ -0,0 +1,47 @@ +package mage.game.permanent.token; + +import mage.MageInt; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.common.combat.AttacksIfAbleAllEffect; +import mage.abilities.effects.common.combat.CantBlockSourceEffect; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.SubType; +import mage.constants.TargetController; +import mage.filter.common.FilterCreaturePermanent; + +/** + * @author TheElk801 + */ +public final class PursuedWhaleToken extends TokenImpl { + + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creatures you control"); + + static { + filter.add(TargetController.YOU.getControllerPredicate()); + } + + public PursuedWhaleToken() { + super("Pirate", "1/1 red Pirate creature token with \"This creature can't block\" and \"Creatures you control attack each combat if able.\""); + cardType.add(CardType.CREATURE); + color.setRed(true); + subtype.add(SubType.PIRATE); + power = new MageInt(1); + toughness = new MageInt(1); + + this.addAbility(new SimpleStaticAbility(new CantBlockSourceEffect(Duration.WhileOnBattlefield) + .setText("this creature can't block"))); + this.addAbility(new SimpleStaticAbility(new AttacksIfAbleAllEffect( + filter, Duration.WhileOnBattlefield, true + ))); + } + + private PursuedWhaleToken(final PursuedWhaleToken token) { + super(token); + } + + @Override + public PursuedWhaleToken copy() { + return new PursuedWhaleToken(this); + } +}