From 554e8076cf151c951aaff9366aafeffe2ddd4e6b Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sun, 6 Jan 2019 11:11:09 +0100 Subject: [PATCH] * Fixed that the becomes land effects of Gaea's Liege and Graceful Antelope did not end when the source left the battlefield. --- Mage.Sets/src/mage/cards/g/GaeasLiege.java | 16 +++++++--------- .../src/mage/cards/g/GracefulAntelope.java | 12 ++++-------- .../effects/ContinuousEffectsList.java | 18 +++++++++++------- .../src/main/java/mage/constants/Duration.java | 1 + 4 files changed, 23 insertions(+), 24 deletions(-) diff --git a/Mage.Sets/src/mage/cards/g/GaeasLiege.java b/Mage.Sets/src/mage/cards/g/GaeasLiege.java index b5c0f24259..0b4a5d87de 100644 --- a/Mage.Sets/src/mage/cards/g/GaeasLiege.java +++ b/Mage.Sets/src/mage/cards/g/GaeasLiege.java @@ -1,6 +1,6 @@ - package mage.cards.g; +import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; @@ -28,14 +28,12 @@ import mage.game.combat.CombatGroup; import mage.game.permanent.Permanent; import mage.target.common.TargetLandPermanent; -import java.util.UUID; - /** * * @author anonymous */ public final class GaeasLiege extends CardImpl { - + final static FilterControlledPermanent filterLands = new FilterControlledPermanent("Forests you control"); static { @@ -44,7 +42,7 @@ public final class GaeasLiege extends CardImpl { public GaeasLiege(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{G}{G}{G}"); - + this.subtype.add(SubType.AVATAR); this.power = new MageInt(0); this.toughness = new MageInt(0); @@ -55,8 +53,8 @@ public final class GaeasLiege extends CardImpl { new SetPowerToughnessSourceEffect(new DefendersForestCount(), Duration.EndOfCombat), new InvertCondition(SourceAttackingCondition.instance), "As long as {this} isn't attacking, its power and toughness are each equal to the number of Forests you control. As long as {this} is attacking, its power and toughness are each equal to the number of Forests defending player controls."))); - // {tap}: Target land becomes a Forest until Gaea's Liege leaves the battlefield. - Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BecomesBasicLandTargetEffect(Duration.WhileOnBattlefield, SubType.FOREST), new TapSourceCost()); + // {T}: Target land becomes a Forest until Gaea's Liege leaves the battlefield. + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BecomesBasicLandTargetEffect(Duration.UntilSourceLeavesBattlefield, SubType.FOREST), new TapSourceCost()); ability.addTarget(new TargetLandPermanent()); this.addAbility(ability); } @@ -75,7 +73,7 @@ class DefendersForestCount implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { - for (CombatGroup group :game.getCombat().getGroups()) { + for (CombatGroup group : game.getCombat().getGroups()) { if (group.getAttackers().contains(sourceAbility.getSourceId())) { UUID defenderId = group.getDefenderId(); if (group.isDefenderIsPlaneswalker()) { @@ -84,7 +82,7 @@ class DefendersForestCount implements DynamicValue { defenderId = permanent.getControllerId(); } } - + FilterLandPermanent filter = new FilterLandPermanent("forest"); filter.add(new SubtypePredicate(SubType.FOREST)); return game.getBattlefield().countAll(filter, defenderId, game); diff --git a/Mage.Sets/src/mage/cards/g/GracefulAntelope.java b/Mage.Sets/src/mage/cards/g/GracefulAntelope.java index ec57976938..2269ccbcf6 100644 --- a/Mage.Sets/src/mage/cards/g/GracefulAntelope.java +++ b/Mage.Sets/src/mage/cards/g/GracefulAntelope.java @@ -1,6 +1,6 @@ - package mage.cards.g; +import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility; @@ -11,11 +11,8 @@ import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Duration; import mage.constants.SubType; -import mage.target.Target; import mage.target.common.TargetLandPermanent; -import java.util.UUID; - /** * * @author cbt33, Loki (Contaminated Ground), Plopman (Larceny) @@ -23,7 +20,7 @@ import java.util.UUID; public final class GracefulAntelope extends CardImpl { public GracefulAntelope(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{W}{W}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{W}{W}"); this.subtype.add(SubType.ANTELOPE); this.power = new MageInt(1); @@ -32,9 +29,8 @@ public final class GracefulAntelope extends CardImpl { // Plainswalk this.addAbility(new PlainswalkAbility()); // Whenever Graceful Antelope deals combat damage to a player, you may have target land become a Plains until Graceful Antelope leaves the battlefield. - Ability ability = new DealsCombatDamageToAPlayerTriggeredAbility(new BecomesBasicLandTargetEffect(Duration.WhileOnBattlefield, SubType.PLAINS), true); - Target target = new TargetLandPermanent(); - ability.addTarget(target); + Ability ability = new DealsCombatDamageToAPlayerTriggeredAbility(new BecomesBasicLandTargetEffect(Duration.UntilSourceLeavesBattlefield, SubType.PLAINS), true); + ability.addTarget(new TargetLandPermanent()); this.addAbility(ability); } diff --git a/Mage/src/main/java/mage/abilities/effects/ContinuousEffectsList.java b/Mage/src/main/java/mage/abilities/effects/ContinuousEffectsList.java index 7b1c66c19c..69837a16b7 100644 --- a/Mage/src/main/java/mage/abilities/effects/ContinuousEffectsList.java +++ b/Mage/src/main/java/mage/abilities/effects/ContinuousEffectsList.java @@ -1,14 +1,13 @@ - package mage.abilities.effects; +import java.util.*; import mage.abilities.Ability; import mage.abilities.MageSingleton; import mage.constants.Duration; +import mage.constants.Zone; import mage.game.Game; import org.apache.log4j.Logger; -import java.util.*; - /** * @param * @author BetaSteward_at_googlemail.com @@ -42,7 +41,7 @@ public class ContinuousEffectsList extends ArrayList } public void removeEndOfTurnEffects() { - for (Iterator i = this.iterator(); i.hasNext(); ) { + for (Iterator i = this.iterator(); i.hasNext();) { T entry = i.next(); if (entry.getDuration() == Duration.EndOfTurn) { i.remove(); @@ -53,7 +52,7 @@ public class ContinuousEffectsList extends ArrayList public void removeEndOfCombatEffects() { - for (Iterator i = this.iterator(); i.hasNext(); ) { + for (Iterator i = this.iterator(); i.hasNext();) { T entry = i.next(); if (entry.getDuration() == Duration.EndOfCombat) { i.remove(); @@ -63,7 +62,7 @@ public class ContinuousEffectsList extends ArrayList } public void removeInactiveEffects(Game game) { - for (Iterator i = this.iterator(); i.hasNext(); ) { + for (Iterator i = this.iterator(); i.hasNext();) { T entry = i.next(); if (isInactive(entry, game)) { i.remove(); @@ -106,6 +105,11 @@ public class ContinuousEffectsList extends ArrayList if (effect.isInactive(ability, game)) { it.remove(); } + break; + case UntilSourceLeavesBattlefield: + if (Zone.BATTLEFIELD != game.getState().getZone(ability.getSourceId())) { + it.remove(); + } } } } @@ -147,7 +151,7 @@ public class ContinuousEffectsList extends ArrayList abilities.removeAll(abilitiesToRemove); } if (abilities == null || abilities.isEmpty()) { - for (Iterator iterator = this.iterator(); iterator.hasNext(); ) { + for (Iterator iterator = this.iterator(); iterator.hasNext();) { ContinuousEffect effect = iterator.next(); if (effect.getId().equals(effectIdToRemove)) { iterator.remove(); diff --git a/Mage/src/main/java/mage/constants/Duration.java b/Mage/src/main/java/mage/constants/Duration.java index e23951b8e1..1c462cbb3d 100644 --- a/Mage/src/main/java/mage/constants/Duration.java +++ b/Mage/src/main/java/mage/constants/Duration.java @@ -12,6 +12,7 @@ public enum Duration { WhileInGraveyard("", false), EndOfTurn("until end of turn", true), UntilYourNextTurn("until your next turn", true), + UntilSourceLeavesBattlefield("until {source} leaves the battlefield", true), // supported for continuous layered effects EndOfCombat("until end of combat", true), EndOfStep("until end of phase step", true), Custom("", true);