* Fixed that the becomes land effects of Gaea's Liege and Graceful Antelope did not end when the source left the battlefield.

This commit is contained in:
LevelX2 2019-01-06 11:11:09 +01:00
parent ca18c6a283
commit 554e8076cf
4 changed files with 23 additions and 24 deletions

View file

@ -1,6 +1,6 @@
package mage.cards.g; package mage.cards.g;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
@ -28,14 +28,12 @@ import mage.game.combat.CombatGroup;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.target.common.TargetLandPermanent; import mage.target.common.TargetLandPermanent;
import java.util.UUID;
/** /**
* *
* @author anonymous * @author anonymous
*/ */
public final class GaeasLiege extends CardImpl { public final class GaeasLiege extends CardImpl {
final static FilterControlledPermanent filterLands = new FilterControlledPermanent("Forests you control"); final static FilterControlledPermanent filterLands = new FilterControlledPermanent("Forests you control");
static { static {
@ -44,7 +42,7 @@ public final class GaeasLiege extends CardImpl {
public GaeasLiege(UUID ownerId, CardSetInfo setInfo) { public GaeasLiege(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{G}{G}{G}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{G}{G}{G}");
this.subtype.add(SubType.AVATAR); this.subtype.add(SubType.AVATAR);
this.power = new MageInt(0); this.power = new MageInt(0);
this.toughness = 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 SetPowerToughnessSourceEffect(new DefendersForestCount(), Duration.EndOfCombat),
new InvertCondition(SourceAttackingCondition.instance), 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."))); "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. // {T}: 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()); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BecomesBasicLandTargetEffect(Duration.UntilSourceLeavesBattlefield, SubType.FOREST), new TapSourceCost());
ability.addTarget(new TargetLandPermanent()); ability.addTarget(new TargetLandPermanent());
this.addAbility(ability); this.addAbility(ability);
} }
@ -75,7 +73,7 @@ class DefendersForestCount implements DynamicValue {
@Override @Override
public int calculate(Game game, Ability sourceAbility, Effect effect) { 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())) { if (group.getAttackers().contains(sourceAbility.getSourceId())) {
UUID defenderId = group.getDefenderId(); UUID defenderId = group.getDefenderId();
if (group.isDefenderIsPlaneswalker()) { if (group.isDefenderIsPlaneswalker()) {
@ -84,7 +82,7 @@ class DefendersForestCount implements DynamicValue {
defenderId = permanent.getControllerId(); defenderId = permanent.getControllerId();
} }
} }
FilterLandPermanent filter = new FilterLandPermanent("forest"); FilterLandPermanent filter = new FilterLandPermanent("forest");
filter.add(new SubtypePredicate(SubType.FOREST)); filter.add(new SubtypePredicate(SubType.FOREST));
return game.getBattlefield().countAll(filter, defenderId, game); return game.getBattlefield().countAll(filter, defenderId, game);

View file

@ -1,6 +1,6 @@
package mage.cards.g; package mage.cards.g;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility; import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
@ -11,11 +11,8 @@ import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.SubType; import mage.constants.SubType;
import mage.target.Target;
import mage.target.common.TargetLandPermanent; import mage.target.common.TargetLandPermanent;
import java.util.UUID;
/** /**
* *
* @author cbt33, Loki (Contaminated Ground), Plopman (Larceny) * @author cbt33, Loki (Contaminated Ground), Plopman (Larceny)
@ -23,7 +20,7 @@ import java.util.UUID;
public final class GracefulAntelope extends CardImpl { public final class GracefulAntelope extends CardImpl {
public GracefulAntelope(UUID ownerId, CardSetInfo setInfo) { 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.subtype.add(SubType.ANTELOPE);
this.power = new MageInt(1); this.power = new MageInt(1);
@ -32,9 +29,8 @@ public final class GracefulAntelope extends CardImpl {
// Plainswalk // Plainswalk
this.addAbility(new PlainswalkAbility()); 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. // 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); Ability ability = new DealsCombatDamageToAPlayerTriggeredAbility(new BecomesBasicLandTargetEffect(Duration.UntilSourceLeavesBattlefield, SubType.PLAINS), true);
Target target = new TargetLandPermanent(); ability.addTarget(new TargetLandPermanent());
ability.addTarget(target);
this.addAbility(ability); this.addAbility(ability);
} }

View file

@ -1,14 +1,13 @@
package mage.abilities.effects; package mage.abilities.effects;
import java.util.*;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.MageSingleton; import mage.abilities.MageSingleton;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import java.util.*;
/** /**
* @param <T> * @param <T>
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
@ -42,7 +41,7 @@ public class ContinuousEffectsList<T extends ContinuousEffect> extends ArrayList
} }
public void removeEndOfTurnEffects() { public void removeEndOfTurnEffects() {
for (Iterator<T> i = this.iterator(); i.hasNext(); ) { for (Iterator<T> i = this.iterator(); i.hasNext();) {
T entry = i.next(); T entry = i.next();
if (entry.getDuration() == Duration.EndOfTurn) { if (entry.getDuration() == Duration.EndOfTurn) {
i.remove(); i.remove();
@ -53,7 +52,7 @@ public class ContinuousEffectsList<T extends ContinuousEffect> extends ArrayList
public void removeEndOfCombatEffects() { public void removeEndOfCombatEffects() {
for (Iterator<T> i = this.iterator(); i.hasNext(); ) { for (Iterator<T> i = this.iterator(); i.hasNext();) {
T entry = i.next(); T entry = i.next();
if (entry.getDuration() == Duration.EndOfCombat) { if (entry.getDuration() == Duration.EndOfCombat) {
i.remove(); i.remove();
@ -63,7 +62,7 @@ public class ContinuousEffectsList<T extends ContinuousEffect> extends ArrayList
} }
public void removeInactiveEffects(Game game) { public void removeInactiveEffects(Game game) {
for (Iterator<T> i = this.iterator(); i.hasNext(); ) { for (Iterator<T> i = this.iterator(); i.hasNext();) {
T entry = i.next(); T entry = i.next();
if (isInactive(entry, game)) { if (isInactive(entry, game)) {
i.remove(); i.remove();
@ -106,6 +105,11 @@ public class ContinuousEffectsList<T extends ContinuousEffect> extends ArrayList
if (effect.isInactive(ability, game)) { if (effect.isInactive(ability, game)) {
it.remove(); it.remove();
} }
break;
case UntilSourceLeavesBattlefield:
if (Zone.BATTLEFIELD != game.getState().getZone(ability.getSourceId())) {
it.remove();
}
} }
} }
} }
@ -147,7 +151,7 @@ public class ContinuousEffectsList<T extends ContinuousEffect> extends ArrayList
abilities.removeAll(abilitiesToRemove); abilities.removeAll(abilitiesToRemove);
} }
if (abilities == null || abilities.isEmpty()) { if (abilities == null || abilities.isEmpty()) {
for (Iterator<T> iterator = this.iterator(); iterator.hasNext(); ) { for (Iterator<T> iterator = this.iterator(); iterator.hasNext();) {
ContinuousEffect effect = iterator.next(); ContinuousEffect effect = iterator.next();
if (effect.getId().equals(effectIdToRemove)) { if (effect.getId().equals(effectIdToRemove)) {
iterator.remove(); iterator.remove();

View file

@ -12,6 +12,7 @@ public enum Duration {
WhileInGraveyard("", false), WhileInGraveyard("", false),
EndOfTurn("until end of turn", true), EndOfTurn("until end of turn", true),
UntilYourNextTurn("until your next 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), EndOfCombat("until end of combat", true),
EndOfStep("until end of phase step", true), EndOfStep("until end of phase step", true),
Custom("", true); Custom("", true);