* Starfield of Nyx - Fixed that the continuous effect's dependancy to continuousEffects that add subtype aura was not checked. Reworked the dependency check to be a bit more generic (#1259).

This commit is contained in:
LevelX2 2015-09-12 19:35:02 +02:00
parent daea667cbf
commit 0ca991c4ba
22 changed files with 408 additions and 185 deletions

View file

@ -34,10 +34,12 @@ import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.common.SacrificeTargetCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.common.continuous.BecomesCreatureAllEffect;
import mage.abilities.effects.common.continuous.BoostTargetEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.DependencyType;
import mage.constants.Duration;
import mage.constants.Rarity;
import mage.constants.Zone;
@ -71,8 +73,9 @@ public class AmbushCommander extends CardImpl {
this.toughness = new MageInt(2);
// Forests you control are 1/1 green Elf creatures that are still lands.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BecomesCreatureAllEffect(new AmbushCommanderToken(),
"lands", filter2, Duration.WhileOnBattlefield)));
ContinuousEffect effect = new BecomesCreatureAllEffect(new AmbushCommanderToken(), "lands", filter2, Duration.WhileOnBattlefield);
effect.getDependencyTypes().add(DependencyType.BecomeForest);
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
// {1}{G}, Sacrifice an Elf: Target creature gets +3/+3 until end of turn.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BoostTargetEffect(3, 3, Duration.EndOfTurn),
new ManaCostsImpl("{1}{G}"));
@ -92,6 +95,7 @@ public class AmbushCommander extends CardImpl {
}
class AmbushCommanderToken extends Token {
public AmbushCommanderToken() {
super("Elf", "1/1 green Elf creatures");
subtype.add("Elf");

View file

@ -28,15 +28,11 @@
package mage.sets.fatereforged;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.BecomesAuraAttachToManifestSourceEffect;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
import mage.abilities.keyword.DoubleStrikeAbility;
import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.LifelinkAbility;
import mage.cards.CardImpl;
import mage.constants.AttachmentType;
import mage.constants.CardType;

View file

@ -35,6 +35,7 @@ import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.mana.RedManaAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.DependencyType;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
@ -86,6 +87,7 @@ public class MagusOfTheMoon extends CardImpl {
MagusOfTheMoonEffect() {
super(Duration.WhileOnBattlefield, Outcome.Detriment);
this.staticText = "Nonbasic lands are Mountains";
dependencyTypes.add(DependencyType.BecomeMountain);
}
MagusOfTheMoonEffect(final MagusOfTheMoonEffect effect) {

View file

@ -41,6 +41,7 @@ import mage.abilities.effects.common.SacrificeSourceUnlessPaysEffect;
import mage.abilities.mana.WhiteManaAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.DependencyType;
import mage.constants.Duration;
import mage.constants.Layer;
import static mage.constants.Layer.AbilityAddingRemovingEffects_6;
@ -53,7 +54,6 @@ import mage.constants.Zone;
import mage.filter.common.FilterLandPermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.sets.futuresight.MagusOfTheMoon;
/**
*
@ -133,7 +133,7 @@ public class Conversion extends CardImpl {
Set<UUID> dependentTo = null;
for (ContinuousEffect effect : allEffectsInLayer) {
// http://www.mtgsalvation.com/forums/magic-fundamentals/magic-rulings/magic-rulings-archives/286046-conversion-magus-of-the-moon
if (MagusOfTheMoon.class.equals(effect.getClass().getEnclosingClass())) {
if (effect.getDependencyTypes().contains(DependencyType.BecomeMountain)) {
if (dependentTo == null) {
dependentTo = new HashSet<>();
}

View file

@ -29,24 +29,22 @@ package mage.sets.limitedalpha;
import java.util.UUID;
import mage.MageInt;
import mage.ObjectColor;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.common.continuous.BecomesCreatureAllEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.DependencyType;
import mage.constants.Duration;
import mage.constants.Rarity;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.game.permanent.token.Token;
/**
*
* @author KholdFuzion
*
*/
public class KormusBell extends CardImpl {
@ -55,7 +53,9 @@ public class KormusBell extends CardImpl {
this.expansionSetCode = "LEA";
// All Swamps are 1/1 black creatures that are still lands.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BecomesCreatureAllEffect(new KormusBellToken(), "lands", new FilterPermanent("Swamp", "Swamps"), Duration.WhileOnBattlefield)));
ContinuousEffect effect = new BecomesCreatureAllEffect(new KormusBellToken(), "lands", new FilterPermanent("Swamp", "Swamps"), Duration.WhileOnBattlefield);
effect.getDependencyTypes().add(DependencyType.BecomeSwamp);
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
}
public KormusBell(final KormusBell card) {
@ -69,6 +69,7 @@ public class KormusBell extends CardImpl {
}
class KormusBellToken extends Token {
public KormusBellToken() {
super("", "1/1 creature");
cardType.add(CardType.CREATURE);

View file

@ -30,9 +30,11 @@ package mage.sets.limitedalpha;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.common.continuous.BecomesCreatureAllEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.DependencyType;
import mage.constants.Duration;
import mage.constants.Rarity;
import mage.constants.Zone;
@ -56,9 +58,10 @@ public class LivingLands extends CardImpl {
super(ownerId, 118, "Living Lands", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{3}{G}");
this.expansionSetCode = "LEA";
// All Forests are 1/1 creatures that are still lands.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BecomesCreatureAllEffect(new LivingLandsToken(), "lands", filter, Duration.WhileOnBattlefield)));
ContinuousEffect effect = new BecomesCreatureAllEffect(new LivingLandsToken(), "lands", filter, Duration.WhileOnBattlefield);
effect.getDependencyTypes().add(DependencyType.BecomeForest);
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
}
public LivingLands(final LivingLands card) {

View file

@ -27,16 +27,21 @@
*/
package mage.sets.magicorigins;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition;
import mage.abilities.decorator.ConditionalContinuousEffect;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.DependencyType;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
@ -70,6 +75,7 @@ public class StarfieldOfNyx extends CardImpl {
static {
filterEnchantmentYouControl.add(new ControllerPredicate(TargetController.YOU));
}
static {
filterGraveyardEnchantment.add(new CardTypePredicate(CardType.ENCHANTMENT));
filterGraveyardEnchantment.add(new OwnerPredicate(TargetController.YOU));
@ -86,7 +92,8 @@ public class StarfieldOfNyx extends CardImpl {
this.addAbility(ability);
// As long as you control five or more enchantments, each other non-Aura enchantment you control is a creature in addition to its other types and has base power and base toughness each equal to its converted mana cost.
ConditionalContinuousEffect effect = new ConditionalContinuousEffect(new StarfieldOfNyxEffect(), new PermanentsOnTheBattlefieldCondition(filterEnchantmentYouControl, PermanentsOnTheBattlefieldCondition.CountType.MORE_THAN, 4), rule1);
ConditionalContinuousEffect effect = new ConditionalContinuousEffect(
new StarfieldOfNyxEffect(), new PermanentsOnTheBattlefieldCondition(filterEnchantmentYouControl, PermanentsOnTheBattlefieldCondition.CountType.MORE_THAN, 4), rule1);
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
}
@ -103,6 +110,7 @@ public class StarfieldOfNyx extends CardImpl {
class StarfieldOfNyxEffect extends ContinuousEffectImpl {
private static final FilterEnchantmentPermanent filter = new FilterEnchantmentPermanent("Each other non-Aura enchantment you control");
static {
filter.add(Predicates.not(new SubtypePredicate("Aura")));
filter.add(new AnotherPredicate());
@ -152,10 +160,23 @@ class StarfieldOfNyxEffect extends ContinuousEffectImpl {
return false;
}
@Override
public boolean hasLayer(Layer layer) {
return layer == Layer.PTChangingEffects_7 || layer == Layer.TypeChangingEffects_4;
}
@Override
public Set<UUID> isDependentTo(List<ContinuousEffect> allEffectsInLayer) {
Set<UUID> dependentTo = null;
for (ContinuousEffect effect : allEffectsInLayer) {
// http://www.slightlymagic.net/forum/viewtopic.php?f=70&t=17664&start=30#p185513
if (effect.getDependencyTypes().contains(DependencyType.AuraAddingRemoving)) {
if (dependentTo == null) {
dependentTo = new HashSet<>();
}
dependentTo.add(effect.getId());
}
}
return dependentTo;
}
}

View file

@ -34,9 +34,11 @@ import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.SacrificeTargetCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.common.continuous.BecomesCreatureAllEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.DependencyType;
import mage.constants.Duration;
import mage.constants.Rarity;
import mage.constants.Zone;
@ -67,8 +69,10 @@ public class TheloniteDruid extends CardImpl {
this.toughness = new MageInt(1);
// {1}{G}, {tap}, Sacrifice a creature: Forests you control become 2/3 creatures until end of turn. They're still lands.
ContinuousEffect effect = new BecomesCreatureAllEffect(new TheloniteDruidLandToken(), "Forests", filter, Duration.EndOfTurn);
effect.getDependencyTypes().add(DependencyType.BecomeForest);
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD,
new BecomesCreatureAllEffect(new TheloniteDruidLandToken(), "Forests", filter, Duration.EndOfTurn),
effect,
new ManaCostsImpl("{1}{G}"));
ability.addCost(new TapSourceCost());
ability.addCost(new SacrificeTargetCost(new TargetControlledCreaturePermanent()));
@ -86,6 +90,7 @@ public class TheloniteDruid extends CardImpl {
}
class TheloniteDruidLandToken extends Token {
public TheloniteDruidLandToken() {
super("", "2/3 creatures");
cardType.add(CardType.CREATURE);

View file

@ -34,6 +34,7 @@ import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.Effect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.DependencyType;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
@ -80,6 +81,7 @@ public class EnchantedEvening extends CardImpl {
super(duration, Layer.TypeChangingEffects_4, SubLayer.NA, Outcome.Benefit);
this.addedCardType = addedCardType;
this.filter = filter;
this.dependencyTypes.add(DependencyType.EnchantmentAddingRemoving);
}
public EnchangedEveningEffect(final EnchangedEveningEffect effect) {

View file

@ -27,6 +27,7 @@
*/
package mage.sets.urzasdestiny;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@ -37,6 +38,7 @@ import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.DependencyType;
import mage.constants.Duration;
import mage.constants.Layer;
import static mage.constants.Layer.PTChangingEffects_7;
@ -51,7 +53,6 @@ import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.filter.predicate.permanent.AnotherPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.sets.shadowmoor.EnchantedEvening;
/**
*
@ -82,10 +83,12 @@ public class Opalescence extends CardImpl {
class OpalescenceEffect extends ContinuousEffectImpl {
private static final FilterEnchantmentPermanent filter = new FilterEnchantmentPermanent("Each other non-Aura enchantment");
private static final EnumSet checkDependencyTypes;
static {
filter.add(Predicates.not(new SubtypePredicate("Aura")));
filter.add(new AnotherPredicate());
checkDependencyTypes = EnumSet.of(DependencyType.AuraAddingRemoving, DependencyType.EnchantmentAddingRemoving);
}
public OpalescenceEffect() {
@ -140,13 +143,15 @@ class OpalescenceEffect extends ContinuousEffectImpl {
public Set<UUID> isDependentTo(List<ContinuousEffect> allEffectsInLayer) {
Set<UUID> dependentTo = null;
for (ContinuousEffect effect : allEffectsInLayer) {
if (EnchantedEvening.class.equals(effect.getClass().getEnclosingClass())) {
for (DependencyType dependencyType : effect.getDependencyTypes()) {
if (checkDependencyTypes.contains(dependencyType)) {
if (dependentTo == null) {
dependentTo = new HashSet<>();
}
dependentTo.add(effect.getId());
}
}
}
return dependentTo;
}
}

View file

@ -48,6 +48,7 @@ import mage.cards.Card;
import mage.cards.CardImpl;
import mage.constants.AsThoughEffectType;
import mage.constants.CardType;
import mage.constants.DependencyType;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
@ -77,7 +78,6 @@ public class Necromancy extends CardImpl {
super(ownerId, 14, "Necromancy", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{2}{B}");
this.expansionSetCode = "VIS";
// You may cast Necromancy as though it had flash. If you cast it any time a sorcery couldn't have been cast, the controller of the permanent it becomes sacrifices it at the beginning of the next cleanup step.
this.addAbility(new SimpleStaticAbility(Zone.ALL, new CastSourceAsThoughItHadFlashEffect(this, Duration.EndOfGame, true)));
this.addAbility(new CastAtInstantTimeTriggeredAbility());
@ -104,7 +104,6 @@ public class Necromancy extends CardImpl {
}
}
class CastSourceAsThoughItHadFlashEffect extends AsThoughEffectImpl {
private final boolean sacrificeIfCastAsInstant;
@ -115,7 +114,6 @@ class CastSourceAsThoughItHadFlashEffect extends AsThoughEffectImpl {
staticText = "You may cast {this} as though it had flash";
}
public CastSourceAsThoughItHadFlashEffect(final CastSourceAsThoughItHadFlashEffect effect) {
super(effect);
this.sacrificeIfCastAsInstant = effect.sacrificeIfCastAsInstant;
@ -139,6 +137,7 @@ class CastSourceAsThoughItHadFlashEffect extends AsThoughEffectImpl {
}
class CastAtInstantTimeTriggeredAbility extends TriggeredAbilityImpl {
public CastAtInstantTimeTriggeredAbility() {
super(Zone.STACK, new CreateDelayedTriggeredAbilityEffect(new AtTheBeginOfNextCleanupDelayedTriggeredAbility(new SacrificeSourceEffect())));
}
@ -263,9 +262,9 @@ class NecromancyChangeAbilityEffect extends ContinuousEffectImpl implements Sour
super(Duration.Custom, Outcome.AddAbility);
staticText = "it becomes an Aura with \"enchant creature put onto the battlefield with {this}\"";
this.target = target;
dependencyTypes.add(DependencyType.AuraAddingRemoving);
}
public NecromancyChangeAbilityEffect(final NecromancyChangeAbilityEffect effect) {
super(effect);
this.target = effect.target;

View file

@ -0,0 +1,81 @@
/*
* 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 org.mage.test.cards.enchantments;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import mage.filter.Filter;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
*
* @author LevelX2
*/
public class StarfieldOfNyxTest extends CardTestPlayerBase {
/**
* I had Starfield of Nyx out. With the upkeep trigger, I brought back a
* Cloudform, which was the fifth enchantment. I had another Cloudform, and
* Starfield of Nyx not only turned both of them into creatures (it
* shouldn't, because they're auras), but it also destroyed them. The
* manifests stayed on the battlefield without Flying or Hexproof.
*
*/
@Test
public void testBaneAlleyBroker() {
// At the beginning of your upkeep, if you control an artifact, put a 1/1 colorless Thopter artifact creature token with flying onto the battlefield.
// Whenever one or more artifact creatures you control deal combat damage to a player, draw a card.
addCard(Zone.BATTLEFIELD, playerA, "Thopter Spy Network", 2); // {2}{U}{U} - added to come to 5 enchantments on the battlefield
addCard(Zone.BATTLEFIELD, playerA, "Island", 8);
addCard(Zone.BATTLEFIELD, playerA, "Plains", 1);
// At the beginning of your upkeep, you may return target enchantment card from your graveyard to the battlefield.
// As long as you control five or more enchantments, each other non-Aura enchantment you control is a creature in
// addition to its other types and has base power and base toughness each equal to its converted mana cost.
addCard(Zone.HAND, playerA, "Starfield of Nyx"); // "{4}{W}"
// When Cloudform enters the battlefield, it becomes an Aura with enchant creature. Manifest the top card of your library and attach Cloudform to it.
// Enchanted creature has flying and hexproof.
addCard(Zone.HAND, playerA, "Cloudform"); // {1}{U}{U}
addCard(Zone.GRAVEYARD, playerA, "Cloudform");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Starfield of Nyx");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cloudform");
addTarget(playerA, "Cloudform");
setStopAt(3, PhaseStep.PRECOMBAT_MAIN);
execute();
assertGraveyardCount(playerA, "Thopter Spy Network", 0);
assertPowerToughness(playerA, "", 2, 2, Filter.ComparisonScope.All); // the manifested cards
assertPermanentCount(playerA, "Starfield of Nyx", 1);
assertPowerToughness(playerA, "Thopter Spy Network", 4, 4, Filter.ComparisonScope.All);
assertPermanentCount(playerA, "Cloudform", 2);
}
}

View file

@ -3,9 +3,7 @@ package org.mage.test.cards.facedown;
import mage.cards.Card;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import mage.game.ExileZone;
import org.junit.Assert;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
@ -15,14 +13,12 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
public class BaneAlleyBrokerTest extends CardTestPlayerBase {
/**
* Bane Alley Broker
* Creature Human Rogue 0/3, 1UB (3)
* {T}: Draw a card, then exile a card from your hand face down.
* You may look at cards exiled with Bane Alley Broker.
* {U}{B}, {T}: Return a card exiled with Bane Alley Broker to its owner's hand.
* Bane Alley Broker Creature Human Rogue 0/3, 1UB (3) {T}: Draw a card,
* then exile a card from your hand face down. You may look at cards exiled
* with Bane Alley Broker. {U}{B}, {T}: Return a card exiled with Bane Alley
* Broker to its owner's hand.
*
*/
// test that cards exiled using Bane Alley Broker are face down
@Test
public void testBaneAlleyBroker() {

View file

@ -25,7 +25,6 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.common;
import java.util.UUID;
@ -42,6 +41,7 @@ import mage.abilities.effects.common.CreateSpecialActionEffect;
import mage.abilities.effects.common.RemoveSpecialActionEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.constants.CardType;
import mage.constants.DependencyType;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
@ -119,9 +119,10 @@ class LicidContinuousEffect extends ContinuousEffectImpl {
LicidContinuousEffect(UUID messageId) {
super(Duration.Custom, Outcome.Neutral);
this.messageId = messageId;
dependencyTypes.add(DependencyType.AuraAddingRemoving);
}
LicidContinuousEffect(LicidContinuousEffect ability) {
LicidContinuousEffect(final LicidContinuousEffect ability) {
super(ability);
this.messageId = ability.messageId;
}

View file

@ -1,5 +1,8 @@
package mage.abilities.decorator;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.condition.Condition;
@ -25,7 +28,6 @@ public class ConditionalContinuousEffect extends ContinuousEffectImpl {
protected Condition condition;
protected boolean initDone = false;
public ConditionalContinuousEffect(ContinuousEffect effect, Condition condition, String text) {
this(effect, null, condition, text);
}
@ -134,4 +136,13 @@ public class ConditionalContinuousEffect extends ContinuousEffectImpl {
public ConditionalContinuousEffect copy() {
return new ConditionalContinuousEffect(this);
}
@Override
public Set<UUID> isDependentTo(List<ContinuousEffect> allEffectsInLayer) {
if (effect != null) {
return effect.isDependentTo(allEffectsInLayer);
}
return super.isDependentTo(allEffectsInLayer);
}
}

View file

@ -32,6 +32,7 @@ import java.util.Set;
import java.util.UUID;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.constants.DependencyType;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.SubLayer;
@ -73,6 +74,8 @@ public interface ContinuousEffect extends Effect {
Set<UUID> isDependentTo(List<ContinuousEffect> allEffectsInLayer);
Set<DependencyType> getDependencyTypes();
@Override
void newId();

View file

@ -28,6 +28,7 @@
package mage.abilities.effects;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
@ -39,6 +40,7 @@ import mage.abilities.dynamicvalue.common.DomainValue;
import mage.abilities.dynamicvalue.common.SignInversionDynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.constants.AbilityType;
import mage.constants.DependencyType;
import mage.constants.Duration;
import mage.constants.EffectType;
import mage.constants.Layer;
@ -69,6 +71,7 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu
protected boolean affectedObjectsSet = false;
protected List<MageObjectReference> affectedObjectList = new ArrayList<>();
protected boolean temporary = false;
protected EnumSet<DependencyType> dependencyTypes;
// until your next turn
protected int startingTurn;
@ -79,6 +82,7 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu
this.duration = duration;
this.order = 0;
this.effectType = EffectType.CONTINUOUS;
this.dependencyTypes = EnumSet.noneOf(DependencyType.class);
}
public ContinuousEffectImpl(Duration duration, Layer layer, SubLayer sublayer, Outcome outcome) {
@ -100,6 +104,7 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu
this.temporary = effect.temporary;
this.startingTurn = effect.startingTurn;
this.startingControllerId = effect.startingControllerId;
this.dependencyTypes = effect.dependencyTypes;
}
@Override
@ -256,4 +261,9 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu
return null;
}
@Override
public EnumSet<DependencyType> getDependencyTypes() {
return dependencyTypes;
}
}

View file

@ -25,14 +25,18 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.effects.common.continuous;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.constants.*;
import mage.constants.CardType;
import mage.constants.DependencyType;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -46,6 +50,9 @@ public class AddCardTypeTargetEffect extends ContinuousEffectImpl {
public AddCardTypeTargetEffect(CardType addedCardType, Duration duration) {
super(duration, Layer.TypeChangingEffects_4, SubLayer.NA, Outcome.Benefit);
this.addedCardType = addedCardType;
if (addedCardType.equals(CardType.ENCHANTMENT)) {
dependencyTypes.add(DependencyType.EnchantmentAddingRemoving);
}
}
public AddCardTypeTargetEffect(final AddCardTypeTargetEffect effect) {

View file

@ -31,6 +31,7 @@ import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.keyword.EnchantAbility;
import mage.constants.DependencyType;
import mage.constants.Duration;
import mage.constants.Layer;
import static mage.constants.Layer.AbilityAddingRemovingEffects_6;
@ -56,10 +57,10 @@ public class BecomesAuraSourceEffect extends ContinuousEffectImpl implements Sou
newAbility = new EnchantAbility(target.getTargetName());
newAbility.setRuleAtTheTop(true);
staticText = "it becomes an Aura with enchant " + target.getTargetName();
dependencyTypes.add(DependencyType.AuraAddingRemoving);
}
public BecomesAuraSourceEffect(final BecomesAuraSourceEffect effect) {
super(effect);
this.target = effect.target;

View file

@ -40,6 +40,7 @@ import mage.abilities.mana.WhiteManaAbility;
import mage.choices.Choice;
import mage.choices.ChoiceBasicLandType;
import mage.constants.CardType;
import mage.constants.DependencyType;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
@ -73,6 +74,21 @@ public class BecomesBasicLandTargetEffect extends ContinuousEffectImpl {
public BecomesBasicLandTargetEffect(Duration duration, boolean chooseLandType, boolean loseOther, String... landNames) {
super(duration, Outcome.Detriment);
this.landTypes.addAll(Arrays.asList(landNames));
if (landTypes.contains("Mountain")) {
dependencyTypes.add(DependencyType.BecomeMountain);
}
if (landTypes.contains("Forest")) {
dependencyTypes.add(DependencyType.BecomeForest);
}
if (landTypes.contains("Swamp")) {
dependencyTypes.add(DependencyType.BecomeSwamp);
}
if (landTypes.contains("Island")) {
dependencyTypes.add(DependencyType.BecomeIsland);
}
if (landTypes.contains("Plains")) {
dependencyTypes.add(DependencyType.BecomePlains);
}
this.chooseLandType = chooseLandType;
this.staticText = setText();
this.loseOther = loseOther;

View file

@ -25,7 +25,6 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.keyword;
import mage.abilities.Ability;
@ -37,6 +36,7 @@ import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.continuous.SourceEffect;
import mage.cards.Card;
import mage.constants.CardType;
import mage.constants.DependencyType;
import mage.constants.Duration;
import mage.constants.Layer;
import static mage.constants.Layer.TypeChangingEffects_4;
@ -54,57 +54,66 @@ import mage.target.common.TargetCreaturePermanent;
*
* 702.102. Bestow
*
* 702.102a Bestow represents two static abilities, one that functions while the card with bestow is
* on the stack and another that functions both while its on stack and while its on the battlefield.
* Bestow [cost] means You may cast this card by paying [cost] rather than its mana cost. and If
* you chose to pay this spells bestow cost, it becomes an Aura enchantment and gains enchant creature.
* These effects last until one of two things happens: this spell has an illegal target as it resolves
* and or the permanent this spell becomes, becomes unattached. Paying a cards bestow cost follows the
* rules for paying alternative costs in rules 601.2b and 601.2eg.
* 702.102a Bestow represents two static abilities, one that functions while the
* card with bestow is on the stack and another that functions both while its
* on stack and while its on the battlefield. Bestow [cost] means You may
* cast this card by paying [cost] rather than its mana cost. and If you chose
* to pay this spells bestow cost, it becomes an Aura enchantment and gains
* enchant creature. These effects last until one of two things happens: this
* spell has an illegal target as it resolves and or the permanent this spell
* becomes, becomes unattached. Paying a cards bestow cost follows the rules
* for paying alternative costs in rules 601.2b and 601.2eg.
*
* 702.102b If a spells controller chooses to pay its bestow cost, that player chooses a legal target
* for that Aura spell as defined by its enchant creature ability and rule 601.2c. See also rule 303.4.
* 702.102b If a spells controller chooses to pay its bestow cost, that player
* chooses a legal target for that Aura spell as defined by its enchant creature
* ability and rule 601.2c. See also rule 303.4.
*
* 702.102c A spells controller cant choose to pay its bestow cost unless that player can choose a legal
* target for that spell after it becomes an Aura spell.
* 702.102c A spells controller cant choose to pay its bestow cost unless that
* player can choose a legal target for that spell after it becomes an Aura
* spell.
*
* 702.102d As an Aura spell with bestow begins resolving, if its target is illegal, the effect making
* it an Aura spell ends. It continues resolving as a creature spell and will be put onto the battlefield
* under the control of the spells controller. This is an exception to rule 608.3a.
* 702.102d As an Aura spell with bestow begins resolving, if its target is
* illegal, the effect making it an Aura spell ends. It continues resolving as a
* creature spell and will be put onto the battlefield under the control of the
* spells controller. This is an exception to rule 608.3a.
*
* 702.102e If an Aura with bestow is attached to an illegal object or player, it becomes unattached.
* This is an exception to rule 704.5n.
* 702.102e If an Aura with bestow is attached to an illegal object or player,
* it becomes unattached. This is an exception to rule 704.5n.
*
* You dont choose whether the spell is going to be an Aura spell or not until the spell is already on
* the stack. Abilities that affect when you can cast a spell, such as flash, will apply to the creature
* card in whatever zone youre casting it from. For example, an effect that said you can cast creature
* spells as though they have flash will allow you to cast a creature card with bestow as an Aura spell
* anytime you could cast an instant.
* You dont choose whether the spell is going to be an Aura spell or not until
* the spell is already on the stack. Abilities that affect when you can cast a
* spell, such as flash, will apply to the creature card in whatever zone youre
* casting it from. For example, an effect that said you can cast creature
* spells as though they have flash will allow you to cast a creature card with
* bestow as an Aura spell anytime you could cast an instant.
*
* On the stack, a spell with bestow is either a creature spell or an Aura spell. Its never both.
* On the stack, a spell with bestow is either a creature spell or an Aura
* spell. Its never both.
*
* Unlike other Aura spells, an Aura spell with bestow isnt countered if its target is illegal as it
* begins to resolve. Rather, the effect making it an Aura spell ends, it loses enchant creature, it
* returns to being an enchantment creature spell, and it resolves and enters the battlefield as an
* Unlike other Aura spells, an Aura spell with bestow isnt countered if its
* target is illegal as it begins to resolve. Rather, the effect making it an
* Aura spell ends, it loses enchant creature, it returns to being an
* enchantment creature spell, and it resolves and enters the battlefield as an
* enchantment creature.
*
* Unlike other Auras, an Aura with bestow isnt put into its owners graveyard if it becomes unattached.
* Rather, the effect making it an Aura ends, it loses enchant creature, and it remains on the
* battlefield as an enchantment creature. It can attack (and its {T} abilities can be activated,
* if it has any) on the turn it becomes unattached if its been under your control continuously,
* even as an Aura, since your most recent turn began.
* Unlike other Auras, an Aura with bestow isnt put into its owners graveyard
* if it becomes unattached. Rather, the effect making it an Aura ends, it loses
* enchant creature, and it remains on the battlefield as an enchantment
* creature. It can attack (and its {T} abilities can be activated, if it has
* any) on the turn it becomes unattached if its been under your control
* continuously, even as an Aura, since your most recent turn began.
*
* If a permanent with bestow enters the battlefield by any method other than being cast, it will be
* an enchantment creature. You cant choose to pay the bestow cost and have it become an Aura.
* If a permanent with bestow enters the battlefield by any method other than
* being cast, it will be an enchantment creature. You cant choose to pay the
* bestow cost and have it become an Aura.
*
* Auras attached to a creature dont become tapped when the creature becomes tapped. Except in some
* rare cases, an Aura with bestow remains untapped when it becomes unattached and becomes a creature.
* Auras attached to a creature dont become tapped when the creature becomes
* tapped. Except in some rare cases, an Aura with bestow remains untapped when
* it becomes unattached and becomes a creature.
*
*
* @author LevelX2
*/
public class BestowAbility extends SpellAbility {
public BestowAbility(Card card, String manaString) {
@ -138,8 +147,6 @@ public class BestowAbility extends SpellAbility {
return "Bestow " + getManaCostsToPay().getText() + " <i>(If you cast this card for its bestow cost, it's an Aura spell with enchant creature. It becomes a creature again if it's not attached to a creature.)</i>";
}
}
class BestowTypeChangingEffect extends ContinuousEffectImpl implements SourceEffect {
private boolean wasAttached;
@ -147,6 +154,7 @@ class BestowTypeChangingEffect extends ContinuousEffectImpl implements SourceEff
public BestowTypeChangingEffect() {
super(Duration.WhileOnBattlefield, Outcome.BoostCreature);
wasAttached = false;
dependencyTypes.add(DependencyType.AuraAddingRemoving);
}
public BestowTypeChangingEffect(final BestowTypeChangingEffect effect) {
@ -192,10 +200,11 @@ class BestowTypeChangingEffect extends ContinuousEffectImpl implements SourceEff
return false;
}
@Override
public boolean hasLayer(Layer layer) {
return layer == Layer.TypeChangingEffects_4;
}
}
}

View file

@ -0,0 +1,50 @@
/*
* 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.constants;
/**
* Dependency types are a part of a workaround solution to handle dependencies
* of continuous effects.
*
* http://magiccards.info/rule/613-interaction-of-continuous-effects.html
*
* https://github.com/magefree/mage/issues/1259
*
*
* @author LevelX2
*/
public enum DependencyType {
AuraAddingRemoving,
BecomeForest,
BecomeIsland,
BecomeMountain,
BecomePlains,
BecomeSwamp,
EnchantmentAddingRemoving;
}