From 4e3709fb89b714e3b6fbeed47f13d2d1b4aae867 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Tue, 6 Aug 2019 15:23:33 -0400 Subject: [PATCH] Implemented Pramikon, Sky Rampart --- Mage.Sets/src/mage/cards/m/MysticBarrier.java | 84 ++++++----- .../src/mage/cards/p/PramikonSkyRampart.java | 137 ++++++++++++++++++ .../src/mage/sets/Commander2019Edition.java | 1 + 3 files changed, 182 insertions(+), 40 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/p/PramikonSkyRampart.java diff --git a/Mage.Sets/src/mage/cards/m/MysticBarrier.java b/Mage.Sets/src/mage/cards/m/MysticBarrier.java index a3f34a5f7c2..a4cdd926392 100644 --- a/Mage.Sets/src/mage/cards/m/MysticBarrier.java +++ b/Mage.Sets/src/mage/cards/m/MysticBarrier.java @@ -30,16 +30,17 @@ public final class MysticBarrier extends CardImpl { super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{4}{W}"); // When Mystic Barrier enters the battlefield or at the beginning of your upkeep, choose left or right. - this.addAbility(new OrTriggeredAbility(Zone.BATTLEFIELD, new ChooseModeEffect("Choose a direction to allow attacking in.", + this.addAbility(new OrTriggeredAbility(Zone.BATTLEFIELD, new ChooseModeEffect( + "Choose a direction to allow attacking in.", ALLOW_ATTACKING_LEFT, ALLOW_ATTACKING_RIGHT), new EntersBattlefieldTriggeredAbility(null, false), new BeginningOfUpkeepTriggeredAbility(null, TargetController.YOU, false))); // Each player may attack only the opponent seated nearest him or her in the last chosen direction and planeswalkers controlled by that player. - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new MysticBarrierReplacementEffect())); + this.addAbility(new SimpleStaticAbility(new MysticBarrierReplacementEffect())); } - public MysticBarrier(final MysticBarrier card) { + private MysticBarrier(final MysticBarrier card) { super(card); } @@ -53,10 +54,11 @@ class MysticBarrierReplacementEffect extends ReplacementEffectImpl { MysticBarrierReplacementEffect() { super(Duration.WhileOnBattlefield, Outcome.Benefit); - staticText = "Each player may attack only the opponent seated nearest him or her in the last chosen direction and planeswalkers controlled by that player"; + staticText = "Each player may attack only the nearest opponent in the " + + "last chosen direction and planeswalkers controlled by that player."; } - MysticBarrierReplacementEffect(MysticBarrierReplacementEffect effect) { + private MysticBarrierReplacementEffect(MysticBarrierReplacementEffect effect) { super(effect); } @@ -74,43 +76,45 @@ class MysticBarrierReplacementEffect extends ReplacementEffectImpl { public boolean applies(GameEvent event, Ability source, Game game) { if (game.getPlayers().size() > 2) { Player controller = game.getPlayer(source.getControllerId()); - if (controller != null) { - if (game.getState().getPlayersInRange(controller.getId(), game).contains(event.getPlayerId())) { - String allowedDirection = (String) game.getState().getValue(source.getSourceId() + "_modeChoice"); - if (allowedDirection != null) { - Player defender = game.getPlayer(event.getTargetId()); - if (defender == null) { - Permanent planeswalker = game.getPermanent(event.getTargetId()); - if (planeswalker != null) { - defender = game.getPlayer(planeswalker.getControllerId()); - } - } - if (defender != null) { - PlayerList playerList = game.getState().getPlayerList(event.getPlayerId()); - if (allowedDirection.equals(MysticBarrier.ALLOW_ATTACKING_LEFT)) { - if (!playerList.getNext().equals(defender.getId())) { - // the defender is not the player to the left - Player attacker = game.getPlayer(event.getPlayerId()); - if (attacker != null) { - game.informPlayer(attacker, "You can only attack to the left!"); - } - return true; - } - } - if (allowedDirection.equals(MysticBarrier.ALLOW_ATTACKING_RIGHT)) { - if (!playerList.getPrevious().equals(defender.getId())) { - // the defender is not the player to the right - Player attacker = game.getPlayer(event.getPlayerId()); - if (attacker != null) { - game.informPlayer(attacker, "You can only attack to the right!"); - } - return true; - } - } - } - } + if (controller == null) { + return false; + } + if (!game.getState().getPlayersInRange(controller.getId(), game).contains(event.getPlayerId())) { + return false; + } + String allowedDirection = (String) game.getState().getValue(source.getSourceId() + "_modeChoice"); + if (allowedDirection == null) { + return false; + } + Player defender = game.getPlayer(event.getTargetId()); + if (defender == null) { + Permanent planeswalker = game.getPermanent(event.getTargetId()); + if (planeswalker != null) { + defender = game.getPlayer(planeswalker.getControllerId()); } } + if (defender == null) { + return false; + } + PlayerList playerList = game.getState().getPlayerList(event.getPlayerId()); + if (allowedDirection.equals(MysticBarrier.ALLOW_ATTACKING_LEFT) + && !playerList.getNext().equals(defender.getId())) { + // the defender is not the player to the left + Player attacker = game.getPlayer(event.getPlayerId()); + if (attacker != null) { + game.informPlayer(attacker, "You can only attack to the left!"); + } + return true; + } + if (allowedDirection.equals(MysticBarrier.ALLOW_ATTACKING_RIGHT) + && !playerList.getPrevious().equals(defender.getId())) { + // the defender is not the player to the right + Player attacker = game.getPlayer(event.getPlayerId()); + if (attacker != null) { + game.informPlayer(attacker, "You can only attack to the right!"); + } + return true; + } } return false; } diff --git a/Mage.Sets/src/mage/cards/p/PramikonSkyRampart.java b/Mage.Sets/src/mage/cards/p/PramikonSkyRampart.java new file mode 100644 index 00000000000..4f061fb863c --- /dev/null +++ b/Mage.Sets/src/mage/cards/p/PramikonSkyRampart.java @@ -0,0 +1,137 @@ +package mage.cards.p; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.AsEntersBattlefieldAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.effects.common.ChooseModeEffect; +import mage.abilities.keyword.DefenderAbility; +import mage.abilities.keyword.FlyingAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.players.PlayerList; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class PramikonSkyRampart extends CardImpl { + + static final String ALLOW_ATTACKING_LEFT = "Allow attacking left"; + static final String ALLOW_ATTACKING_RIGHT = "Allow attacking right"; + + public PramikonSkyRampart(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{U}{R}{W}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.WALL); + this.power = new MageInt(1); + this.toughness = new MageInt(5); + + // Flying + this.addAbility(FlyingAbility.getInstance()); + + // Defender + this.addAbility(DefenderAbility.getInstance()); + + // As Pramikon, Sky Rampart enters the battlefield, choose left or right. + this.addAbility(new AsEntersBattlefieldAbility(new ChooseModeEffect( + "Choose a direction to allow attacking in.", + ALLOW_ATTACKING_LEFT, ALLOW_ATTACKING_RIGHT + ))); + + // Each player may attack only the nearest opponent in the chosen direction and planeswalkers controlled by that opponent. + this.addAbility(new SimpleStaticAbility(new PramikonSkyRampartReplacementEffect())); + } + + private PramikonSkyRampart(final PramikonSkyRampart card) { + super(card); + } + + @Override + public PramikonSkyRampart copy() { + return new PramikonSkyRampart(this); + } +} + +class PramikonSkyRampartReplacementEffect extends ReplacementEffectImpl { + + PramikonSkyRampartReplacementEffect() { + super(Duration.WhileOnBattlefield, Outcome.Benefit); + staticText = "Each player may attack only the nearest opponent " + + "in the chosen direction and planeswalkers controlled by that opponent."; + } + + private PramikonSkyRampartReplacementEffect(PramikonSkyRampartReplacementEffect effect) { + super(effect); + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + return true; + } + + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.DECLARE_ATTACKER; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + if (game.getPlayers().size() > 2) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller == null) { + return false; + } + if (!game.getState().getPlayersInRange(controller.getId(), game).contains(event.getPlayerId())) { + return false; + } + String allowedDirection = (String) game.getState().getValue(source.getSourceId() + "_modeChoice"); + if (allowedDirection == null) { + return false; + } + Player defender = game.getPlayer(event.getTargetId()); + if (defender == null) { + Permanent planeswalker = game.getPermanent(event.getTargetId()); + if (planeswalker != null) { + defender = game.getPlayer(planeswalker.getControllerId()); + } + } + if (defender == null) { + return false; + } + PlayerList playerList = game.getState().getPlayerList(event.getPlayerId()); + if (allowedDirection.equals(PramikonSkyRampart.ALLOW_ATTACKING_LEFT) + && !playerList.getNext().equals(defender.getId())) { + // the defender is not the player to the left + Player attacker = game.getPlayer(event.getPlayerId()); + if (attacker != null) { + game.informPlayer(attacker, "You can only attack to the left!"); + } + return true; + } + if (allowedDirection.equals(PramikonSkyRampart.ALLOW_ATTACKING_RIGHT) + && !playerList.getPrevious().equals(defender.getId())) { + // the defender is not the player to the right + Player attacker = game.getPlayer(event.getPlayerId()); + if (attacker != null) { + game.informPlayer(attacker, "You can only attack to the right!"); + } + return true; + } + } + return false; + } + + @Override + public PramikonSkyRampartReplacementEffect copy() { + return new PramikonSkyRampartReplacementEffect(this); + } +} diff --git a/Mage.Sets/src/mage/sets/Commander2019Edition.java b/Mage.Sets/src/mage/sets/Commander2019Edition.java index b315b97a143..585bea7a054 100644 --- a/Mage.Sets/src/mage/sets/Commander2019Edition.java +++ b/Mage.Sets/src/mage/sets/Commander2019Edition.java @@ -50,6 +50,7 @@ public final class Commander2019Edition extends ExpansionSet { cards.add(new SetCardInfo("Nantuko Vigilante", 174, Rarity.COMMON, mage.cards.n.NantukoVigilante.class)); cards.add(new SetCardInfo("Plains", 288, Rarity.LAND, mage.cards.basiclands.Plains.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Prairie Stream", 265, Rarity.RARE, mage.cards.p.PrairieStream.class)); + cards.add(new SetCardInfo("Pramikon, Sky Rampart", 47, Rarity.MYTHIC, mage.cards.p.PramikonSkyRampart.class)); cards.add(new SetCardInfo("Prismatic Strands", 69, Rarity.COMMON, mage.cards.p.PrismaticStrands.class)); cards.add(new SetCardInfo("Ral Zarek", 198, Rarity.MYTHIC, mage.cards.r.RalZarek.class)); cards.add(new SetCardInfo("Reality Shift", 92, Rarity.UNCOMMON, mage.cards.r.RealityShift.class));