From fb4e23e9be2739a91d83f240e4a28356844163b0 Mon Sep 17 00:00:00 2001 From: spjspj Date: Thu, 19 Apr 2018 17:28:14 +1000 Subject: [PATCH] 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 0000000000..8c811de610 --- /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 84e63a30d2..b78fd48789 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.