From fb4e23e9be2739a91d83f240e4a28356844163b0 Mon Sep 17 00:00:00 2001 From: spjspj Date: Thu, 19 Apr 2018 17:28:14 +1000 Subject: [PATCH 1/5] Fix for BantPlane (Adding in new condition). --- .../common/IsStillOnPlaneCondition.java | 61 +++++++++++++++++++ .../mage/game/command/planes/BantPlane.java | 11 +++- 2 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 Mage/src/main/java/mage/abilities/condition/common/IsStillOnPlaneCondition.java diff --git a/Mage/src/main/java/mage/abilities/condition/common/IsStillOnPlaneCondition.java b/Mage/src/main/java/mage/abilities/condition/common/IsStillOnPlaneCondition.java new file mode 100644 index 00000000000..8c811de610f --- /dev/null +++ b/Mage/src/main/java/mage/abilities/condition/common/IsStillOnPlaneCondition.java @@ -0,0 +1,61 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.abilities.condition.common; + +import mage.abilities.Ability; +import mage.abilities.condition.Condition; +import mage.game.Game; +import mage.game.command.Plane; + +/** + * @author spjspj + */ +public class IsStillOnPlaneCondition implements Condition { + + private String planeName; + + public IsStillOnPlaneCondition(String planeName) { + this.planeName = planeName; + } + + public IsStillOnPlaneCondition(IsStillOnPlaneCondition condition) { + this.planeName = condition.planeName; + } + + @Override + public boolean apply(Game game, Ability source) { + + Plane plane = game.getState().getCurrentPlane(); + if (plane != null) { + if (plane.getName().equalsIgnoreCase(planeName)) { + return true; + } + } + return false; + } +} diff --git a/Mage/src/main/java/mage/game/command/planes/BantPlane.java b/Mage/src/main/java/mage/game/command/planes/BantPlane.java index 84e63a30d22..b78fd48789e 100644 --- a/Mage/src/main/java/mage/game/command/planes/BantPlane.java +++ b/Mage/src/main/java/mage/game/command/planes/BantPlane.java @@ -34,6 +34,7 @@ import mage.ObjectColor; import mage.abilities.Ability; import mage.abilities.common.ActivateIfConditionActivatedAbility; import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.condition.common.IsStillOnPlaneCondition; import mage.abilities.condition.common.MainPhaseStackEmptyCondition; import mage.abilities.condition.common.TargetHasCounterCondition; import mage.abilities.costs.mana.GenericManaCost; @@ -78,13 +79,19 @@ public class BantPlane extends Plane { } private static final String rule = "{this} has indestructible as long as it has a divinity counter on it"; + private static final String exaltedRule = "All creatures have exalted"; public BantPlane() { this.setName("Plane - Bant"); this.setExpansionSetCodeForImage("PCA"); - // All creatures have exalted - Ability ability = new SimpleStaticAbility(Zone.COMMAND, new GainAbilityAllEffect(new ExaltedAbility(), Duration.Custom, StaticFilters.FILTER_PERMANENT_CREATURE)); + // All creatures have exalted + SimpleStaticAbility ability + = new SimpleStaticAbility(Zone.COMMAND, new ConditionalContinuousEffect( + new GainAbilityAllEffect(new ExaltedAbility(), Duration.Custom, StaticFilters.FILTER_PERMANENT_CREATURE), + new IsStillOnPlaneCondition(this.getName()), + exaltedRule)); + this.getAbilities().add(ability); // Active player can roll the planar die: Whenever you roll {CHAOS}, put a divinity counter on target green, white, or blue creature. That creature gains indestructible for as long as it has a divinity counter on it. From 8db079f430e78c1fe264f25855b5ce975dce6824 Mon Sep 17 00:00:00 2001 From: spjspj Date: Thu, 19 Apr 2018 18:01:46 +1000 Subject: [PATCH 2/5] Fix for Planes (Incorrectly appending continuous effects) --- .../planes/AcademyAtTolariaWestPlane.java | 10 ++++++---- .../game/command/planes/AstralArenaPlane.java | 19 +++++++++++++++++++ .../command/planes/EdgeOfMalacolPlane.java | 8 ++++++-- .../command/planes/FieldsOfSummerPlane.java | 9 +++++++++ .../planes/HedronFieldsOfAgadeemPlane.java | 8 ++++++-- .../game/command/planes/TheEonFogPlane.java | 8 ++++++-- .../command/planes/UndercityReachesPlane.java | 10 ++++++++++ 7 files changed, 62 insertions(+), 10 deletions(-) diff --git a/Mage/src/main/java/mage/game/command/planes/AcademyAtTolariaWestPlane.java b/Mage/src/main/java/mage/game/command/planes/AcademyAtTolariaWestPlane.java index 63b68946924..3e8085dc3cb 100644 --- a/Mage/src/main/java/mage/game/command/planes/AcademyAtTolariaWestPlane.java +++ b/Mage/src/main/java/mage/game/command/planes/AcademyAtTolariaWestPlane.java @@ -110,12 +110,15 @@ class DrawCardsActivePlayerEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - if (game.getState().getCurrentPlane() != null) { - if (!game.getState().getCurrentPlane().getName().equalsIgnoreCase("Plane - Academy at Tolaria West")) { + Plane cPlane = game.getState().getCurrentPlane(); + if (cPlane == null) { + return false; + } + if (cPlane != null) { + if (!cPlane.getName().equalsIgnoreCase("Plane - Academy at Tolaria West")) { return false; } } - Player player = game.getPlayer(game.getActivePlayerId()); if (player != null) { player.drawCards(amount.calculate(game, source, this), game); @@ -129,7 +132,6 @@ class DrawCardsActivePlayerEffect extends OneShotEffect { sb.append("draw ").append(CardUtil.numberToText(amount.toString())).append(" cards"); staticText = sb.toString(); } - } enum HellbentAPCondition implements Condition { diff --git a/Mage/src/main/java/mage/game/command/planes/AstralArenaPlane.java b/Mage/src/main/java/mage/game/command/planes/AstralArenaPlane.java index 22af6de23d5..cd34a0acbda 100644 --- a/Mage/src/main/java/mage/game/command/planes/AstralArenaPlane.java +++ b/Mage/src/main/java/mage/game/command/planes/AstralArenaPlane.java @@ -103,6 +103,16 @@ class AstralArenaAttackRestrictionEffect extends RestrictionEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { + Plane cPlane = game.getState().getCurrentPlane(); + if (cPlane == null) { + return false; + } + if (cPlane != null) { + if (!cPlane.getName().equalsIgnoreCase("Plane - Astral Arena")) { + return false; + } + } + return true; } @@ -130,6 +140,15 @@ class AstralArenaBlockRestrictionEffect extends RestrictionEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { + Plane cPlane = game.getState().getCurrentPlane(); + if (cPlane == null) { + return false; + } + if (cPlane != null) { + if (!cPlane.getName().equalsIgnoreCase("Plane - Astral Arena")) { + return false; + } + } return true; } diff --git a/Mage/src/main/java/mage/game/command/planes/EdgeOfMalacolPlane.java b/Mage/src/main/java/mage/game/command/planes/EdgeOfMalacolPlane.java index 56cf30cd309..9caa2b5677e 100644 --- a/Mage/src/main/java/mage/game/command/planes/EdgeOfMalacolPlane.java +++ b/Mage/src/main/java/mage/game/command/planes/EdgeOfMalacolPlane.java @@ -122,8 +122,12 @@ class EdgeOfMalacolEffect extends ContinuousRuleModifyingEffectImpl { public boolean applies(GameEvent event, Ability source, Game game) { // Prevent untap event of creatures of target player if (game.getTurn().getStepType() == PhaseStep.UNTAP) { - if (game.getState().getCurrentPlane() != null) { - if (!game.getState().getCurrentPlane().getName().equalsIgnoreCase("Plane - Edge of Malacol")) { + Plane cPlane = game.getState().getCurrentPlane(); + if (cPlane == null) { + return false; + } + if (cPlane != null) { + if (!cPlane.getName().equalsIgnoreCase("Plane - Edge of Malacol")) { return false; } } diff --git a/Mage/src/main/java/mage/game/command/planes/FieldsOfSummerPlane.java b/Mage/src/main/java/mage/game/command/planes/FieldsOfSummerPlane.java index aa8bc003bcd..1880011cd38 100644 --- a/Mage/src/main/java/mage/game/command/planes/FieldsOfSummerPlane.java +++ b/Mage/src/main/java/mage/game/command/planes/FieldsOfSummerPlane.java @@ -103,6 +103,15 @@ class FieldsOfSummerEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { + Plane cPlane = game.getState().getCurrentPlane(); + if (cPlane == null) { + return false; + } + if (cPlane != null) { + if (!cPlane.getName().equalsIgnoreCase("Plane - Fields of Summer")) { + return false; + } + } Player controller = game.getPlayer(source.getControllerId()); Player owner = game.getPlayer(this.getTargetPointer().getFirst(game, source)); if (owner != null && owner.canRespond() && owner.chooseUse(Outcome.Benefit, "Gain 2 life?", source, game)) { diff --git a/Mage/src/main/java/mage/game/command/planes/HedronFieldsOfAgadeemPlane.java b/Mage/src/main/java/mage/game/command/planes/HedronFieldsOfAgadeemPlane.java index 0b3b3ca70f6..201595b857c 100644 --- a/Mage/src/main/java/mage/game/command/planes/HedronFieldsOfAgadeemPlane.java +++ b/Mage/src/main/java/mage/game/command/planes/HedronFieldsOfAgadeemPlane.java @@ -117,8 +117,12 @@ class HedronFieldsOfAgadeemRestrictionEffect extends RestrictionEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { - if (game.getState().getCurrentPlane() != null) { - if (!game.getState().getCurrentPlane().getName().equalsIgnoreCase("Plane - Hedron Fields of Agadeem")) { + Plane cPlane = game.getState().getCurrentPlane(); + if (cPlane == null) { + return false; + } + if (cPlane != null) { + if (!cPlane.getName().equalsIgnoreCase("Plane - Hedron Fields of Agadeem")) { return false; } } diff --git a/Mage/src/main/java/mage/game/command/planes/TheEonFogPlane.java b/Mage/src/main/java/mage/game/command/planes/TheEonFogPlane.java index f952056ac72..9f00d535f52 100644 --- a/Mage/src/main/java/mage/game/command/planes/TheEonFogPlane.java +++ b/Mage/src/main/java/mage/game/command/planes/TheEonFogPlane.java @@ -109,8 +109,12 @@ class TheEonFogSkipUntapStepEffect extends ContinuousRuleModifyingEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { - if (game.getState().getCurrentPlane() != null) { - if (!game.getState().getCurrentPlane().getName().equalsIgnoreCase("Plane - The Eon Fog")) { + Plane cPlane = game.getState().getCurrentPlane(); + if (cPlane == null) { + return false; + } + if (cPlane != null) { + if (!cPlane.getName().equalsIgnoreCase("Plane - The Eon Fog")) { return false; } } diff --git a/Mage/src/main/java/mage/game/command/planes/UndercityReachesPlane.java b/Mage/src/main/java/mage/game/command/planes/UndercityReachesPlane.java index d15724ba1b7..b95470634b8 100644 --- a/Mage/src/main/java/mage/game/command/planes/UndercityReachesPlane.java +++ b/Mage/src/main/java/mage/game/command/planes/UndercityReachesPlane.java @@ -118,6 +118,16 @@ class UndercityReachesTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { + Plane cPlane = game.getState().getCurrentPlane(); + if (cPlane == null) { + return false; + } + if (cPlane != null) { + if (!cPlane.getName().equalsIgnoreCase("Plane - Undercity Reaches")) { + return false; + } + } + if (((DamagedPlayerEvent) event).isCombatDamage()) { Permanent creature = game.getPermanent(event.getSourceId()); if (creature != null) { From 0c4f487db59b666d631d32549954492a969f457e Mon Sep 17 00:00:00 2001 From: spjspj Date: Thu, 19 Apr 2018 18:36:09 +1000 Subject: [PATCH 3/5] Fix for TrugaJunglePlane (Adding in new condition). --- .../mage/game/command/planes/TrugaJunglePlane.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Mage/src/main/java/mage/game/command/planes/TrugaJunglePlane.java b/Mage/src/main/java/mage/game/command/planes/TrugaJunglePlane.java index dde38661955..e1a9b507bd0 100644 --- a/Mage/src/main/java/mage/game/command/planes/TrugaJunglePlane.java +++ b/Mage/src/main/java/mage/game/command/planes/TrugaJunglePlane.java @@ -29,11 +29,12 @@ package mage.game.command.planes; import java.util.ArrayList; import java.util.List; -import mage.abilities.Ability; import mage.abilities.common.ActivateIfConditionActivatedAbility; import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.condition.common.IsStillOnPlaneCondition; import mage.abilities.condition.common.MainPhaseStackEmptyCondition; import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.decorator.ConditionalContinuousEffect; import mage.abilities.effects.Effect; import mage.abilities.effects.common.RevealLibraryPutIntoHandEffect; import mage.abilities.effects.common.RollPlanarDieEffect; @@ -54,12 +55,17 @@ import mage.watchers.common.PlanarRollWatcher; */ public class TrugaJunglePlane extends Plane { + private static final String rule = "All lands have '{t}: Add one mana of any color to your mana pool"; + public TrugaJunglePlane() { this.setName("Plane - Truga Jungle"); this.setExpansionSetCodeForImage("PCA"); - // All lands have '{t}: Add one mana of any color to your mana pool" - Ability ability = new SimpleStaticAbility(Zone.COMMAND, new GainAbilityAllEffect(new AnyColorManaAbility(), Duration.Custom, StaticFilters.FILTER_LANDS, false)); + SimpleStaticAbility ability + = new SimpleStaticAbility(Zone.COMMAND, new ConditionalContinuousEffect( + new GainAbilityAllEffect(new AnyColorManaAbility(), Duration.Custom, StaticFilters.FILTER_LANDS), + new IsStillOnPlaneCondition(this.getName()), + rule)); this.getAbilities().add(ability); // Active player can roll the planar die: Whenever you roll {CHAOS}, reveal the top three cards of your libary. Put all land cards revealed this way into your hand the rest on the bottom of your library in any order. From 96472332a4e1b701fe01bd8754bfe31ba29d57df Mon Sep 17 00:00:00 2001 From: spjspj Date: Thu, 19 Apr 2018 18:57:32 +1000 Subject: [PATCH 4/5] Fix for AkoumPlane (Any player). --- Mage/src/main/java/mage/game/command/planes/AkoumPlane.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mage/src/main/java/mage/game/command/planes/AkoumPlane.java b/Mage/src/main/java/mage/game/command/planes/AkoumPlane.java index b748bf7395e..52bbe6c9117 100644 --- a/Mage/src/main/java/mage/game/command/planes/AkoumPlane.java +++ b/Mage/src/main/java/mage/game/command/planes/AkoumPlane.java @@ -70,7 +70,7 @@ public class AkoumPlane extends Plane { this.setExpansionSetCodeForImage("PCA"); // Players may cast enchantment spells as if they had flash - SimpleStaticAbility ability = new SimpleStaticAbility(Zone.COMMAND, new CastAsThoughItHadFlashAllEffect(Duration.Custom, filterCard, false)); + SimpleStaticAbility ability = new SimpleStaticAbility(Zone.COMMAND, new CastAsThoughItHadFlashAllEffect(Duration.Custom, filterCard, true)); this.getAbilities().add(ability); // Active player can roll the planar die: Whenever you roll {CHAOS}, destroy target creature that isn't enchanted From bc77b825cb64fa00994a773da17a6d0bd261d896 Mon Sep 17 00:00:00 2001 From: spjspj Date: Thu, 19 Apr 2018 20:08:43 +1000 Subject: [PATCH 5/5] Fix for Darkbarony plane (1 life) --- Mage/src/main/java/mage/game/GameImpl.java | 6 +++--- .../java/mage/game/command/planes/TheDarkBaronyPlane.java | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Mage/src/main/java/mage/game/GameImpl.java b/Mage/src/main/java/mage/game/GameImpl.java index 86cc1bd201d..a4602536931 100644 --- a/Mage/src/main/java/mage/game/GameImpl.java +++ b/Mage/src/main/java/mage/game/GameImpl.java @@ -1078,7 +1078,7 @@ public abstract class GameImpl implements Game, Serializable { if (gameOptions.planeChase) { Plane plane = Plane.getRandomPlane(); plane.setControllerId(startingPlayerId); - addPlane(plane, null, getActivePlayerId()); + addPlane(plane, null, startingPlayerId); state.setPlaneChase(this, gameOptions.planeChase); } } @@ -1565,14 +1565,14 @@ public abstract class GameImpl implements Game, Serializable { } state.addCommandObject(newPlane); informPlayers("You have planeswalked to " + newPlane.getLogName()); - + // Fire off the planeswalked event GameEvent event = new GameEvent(GameEvent.EventType.PLANESWALK, newPlane.getId(), null, newPlane.getId(), 0, true); if (!replaceEvent(event)) { GameEvent ge = new GameEvent(GameEvent.EventType.PLANESWALKED, newPlane.getId(), null, newPlane.getId(), 0, true); fireEvent(ge); } - + return true; } diff --git a/Mage/src/main/java/mage/game/command/planes/TheDarkBaronyPlane.java b/Mage/src/main/java/mage/game/command/planes/TheDarkBaronyPlane.java index 4cfeecf70de..c626ad08280 100644 --- a/Mage/src/main/java/mage/game/command/planes/TheDarkBaronyPlane.java +++ b/Mage/src/main/java/mage/game/command/planes/TheDarkBaronyPlane.java @@ -66,9 +66,9 @@ public class TheDarkBaronyPlane extends Plane { this.setName("Plane - The Dark Barony"); this.setExpansionSetCodeForImage("PCA"); - // Whenever a nonblack card is put into a player's graveyard from anywhere, that player loses 2 life + // Whenever a nonblack card is put into a player's graveyard from anywhere, that player loses 1 life Ability ability = new PutCardIntoGraveFromAnywhereAllTriggeredAbility(Zone.COMMAND, - new LoseLifeTargetEffect(2), false, filter, TargetController.ANY, SetTargetPointer.PLAYER); + new LoseLifeTargetEffect(1), false, filter, TargetController.ANY, SetTargetPointer.PLAYER); this.getAbilities().add(ability); // Active player can roll the planar die: Whenever you roll {CHAOS}, each player dicards a card