This commit is contained in:
Evan Kranzler 2019-01-10 18:11:48 -05:00
commit 1e5a00def7
6 changed files with 156 additions and 113 deletions

View file

@ -1,11 +1,14 @@
package mage.cards.b; package mage.cards.b;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.mana.BlackManaAbility;
import mage.abilities.mana.BlueManaAbility;
import mage.abilities.mana.GreenManaAbility;
import mage.abilities.mana.RedManaAbility; import mage.abilities.mana.RedManaAbility;
import mage.abilities.mana.WhiteManaAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.*; import mage.constants.*;
@ -22,7 +25,7 @@ import mage.game.permanent.Permanent;
public final class BloodMoon extends CardImpl { public final class BloodMoon extends CardImpl {
public BloodMoon(UUID ownerId, CardSetInfo setInfo) { public BloodMoon(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{2}{R}"); super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{R}");
// Nonbasic lands are Mountains. // Nonbasic lands are Mountains.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BloodMoonEffect())); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BloodMoonEffect()));
@ -72,12 +75,28 @@ class BloodMoonEffect extends ContinuousEffectImpl {
case TypeChangingEffects_4: case TypeChangingEffects_4:
// 305.7 Note that this doesn't remove any abilities that were granted to the land by other effects // 305.7 Note that this doesn't remove any abilities that were granted to the land by other effects
// So the ability removing has to be done before Layer 6 // So the ability removing has to be done before Layer 6
land.removeAllAbilities(source.getSourceId(), game); //land.getSubtype(game).removeAll(SubType.getLandTypes(false));
land.getSubtype(game).removeAll(SubType.getLandTypes(false)); land.getSubtype(game).clear();
land.getSubtype(game).add(SubType.MOUNTAIN); land.getSubtype(game).add(SubType.MOUNTAIN);
land.removeAllAbilities(source.getSourceId(), game);
break; break;
case AbilityAddingRemovingEffects_6: case AbilityAddingRemovingEffects_6:
land.removeAllAbilities(source.getSourceId(), game);
if (land.getSubtype(game).contains(SubType.FOREST)) {
land.addAbility(new GreenManaAbility(), source.getSourceId(), game);
}
if (land.getSubtype(game).contains(SubType.PLAINS)) {
land.addAbility(new WhiteManaAbility(), source.getSourceId(), game);
}
if (land.getSubtype(game).contains(SubType.MOUNTAIN)) {
land.addAbility(new RedManaAbility(), source.getSourceId(), game); land.addAbility(new RedManaAbility(), source.getSourceId(), game);
}
if (land.getSubtype(game).contains(SubType.ISLAND)) {
land.addAbility(new BlueManaAbility(), source.getSourceId(), game);
}
if (land.getSubtype(game).contains(SubType.SWAMP)) {
land.addAbility(new BlackManaAbility(), source.getSourceId(), game);
}
break; break;
} }
} }
@ -86,6 +105,7 @@ class BloodMoonEffect extends ContinuousEffectImpl {
@Override @Override
public boolean hasLayer(Layer layer) { public boolean hasLayer(Layer layer) {
return layer == Layer.AbilityAddingRemovingEffects_6 || layer == Layer.TypeChangingEffects_4; return layer == Layer.AbilityAddingRemovingEffects_6
|| layer == Layer.TypeChangingEffects_4;
} }
} }

View file

@ -1,4 +1,3 @@
package mage.cards.c; package mage.cards.c;
import java.util.List; import java.util.List;
@ -13,11 +12,14 @@ import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.common.SacrificeSourceUnlessPaysEffect; import mage.abilities.effects.common.SacrificeSourceUnlessPaysEffect;
import mage.abilities.mana.BlackManaAbility;
import mage.abilities.mana.BlueManaAbility;
import mage.abilities.mana.GreenManaAbility;
import mage.abilities.mana.RedManaAbility;
import mage.abilities.mana.WhiteManaAbility; import mage.abilities.mana.WhiteManaAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.*; import mage.constants.*;
import mage.filter.common.FilterLandPermanent;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
@ -27,13 +29,15 @@ import mage.game.permanent.Permanent;
*/ */
public final class Conversion extends CardImpl { public final class Conversion extends CardImpl {
private static final FilterLandPermanent filter = new FilterLandPermanent(SubType.MOUNTAIN, "Mountains");
public Conversion(UUID ownerId, CardSetInfo setInfo) { public Conversion(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{2}{W}{W}"); super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{W}{W}");
// At the beginning of your upkeep, sacrifice Conversion unless you pay {W}{W}. // At the beginning of your upkeep, sacrifice Conversion unless you pay {W}{W}.
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new SacrificeSourceUnlessPaysEffect(new ManaCostsImpl("{W}{W}")), TargetController.YOU, false)); this.addAbility(new BeginningOfUpkeepTriggeredAbility(
new SacrificeSourceUnlessPaysEffect(
new ManaCostsImpl("{W}{W}")),
TargetController.YOU,
false));
// All Mountains are Plains. // All Mountains are Plains.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ConversionEffect())); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ConversionEffect()));
@ -72,15 +76,45 @@ public final class Conversion extends CardImpl {
@Override @Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
for (Permanent land : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) { for (Permanent land : game.getBattlefield().getAllActivePermanents(CardType.LAND)) {
switch (layer) { switch (layer) {
case AbilityAddingRemovingEffects_6:
land.removeAllAbilities(source.getSourceId(), game);
land.addAbility(new WhiteManaAbility(), source.getSourceId(), game);
break;
case TypeChangingEffects_4: case TypeChangingEffects_4:
if (land.getSubtype(game).contains(SubType.MOUNTAIN)) {
land.getSubtype(game).clear(); land.getSubtype(game).clear();
land.getSubtype(game).add(SubType.PLAINS); land.getSubtype(game).add(SubType.PLAINS);
game.getState().setValue("conversion"
+ source.getId()
+ land.getId()
+ land.getZoneChangeCounter(game),
"true");
}
break;
case AbilityAddingRemovingEffects_6:
if (game.getState().getValue("conversion"
+ source.getId()
+ land.getId()
+ land.getZoneChangeCounter(game)) != null
&& game.getState().getValue("conversion"
+ source.getId()
+ land.getId()
+ land.getZoneChangeCounter(game)).equals("true")) {
land.removeAllAbilities(source.getSourceId(), game);
if (land.getSubtype(game).contains(SubType.FOREST)) {
land.addAbility(new GreenManaAbility(), source.getSourceId(), game);
}
if (land.getSubtype(game).contains(SubType.PLAINS)) {
land.addAbility(new WhiteManaAbility(), source.getSourceId(), game);
}
if (land.getSubtype(game).contains(SubType.MOUNTAIN)) {
land.addAbility(new RedManaAbility(), source.getSourceId(), game);
}
if (land.getSubtype(game).contains(SubType.ISLAND)) {
land.addAbility(new BlueManaAbility(), source.getSourceId(), game);
}
if (land.getSubtype(game).contains(SubType.SWAMP)) {
land.addAbility(new BlackManaAbility(), source.getSourceId(), game);
}
}
break; break;
} }
} }
@ -89,20 +123,17 @@ public final class Conversion extends CardImpl {
@Override @Override
public boolean hasLayer(Layer layer) { public boolean hasLayer(Layer layer) {
return layer == Layer.AbilityAddingRemovingEffects_6 || layer == Layer.TypeChangingEffects_4; return layer == Layer.AbilityAddingRemovingEffects_6
|| layer == Layer.TypeChangingEffects_4;
} }
@Override @Override
public Set<UUID> isDependentTo(List<ContinuousEffect> allEffectsInLayer) { public Set<UUID> isDependentTo(List<ContinuousEffect> allEffectsInLayer) {
// the dependent classes needs to be an enclosed class for dependent check of continuous effects
return allEffectsInLayer return allEffectsInLayer
.stream() .stream()
.filter(effect->effect.getDependencyTypes().contains(DependencyType.BecomeMountain)) .filter(effect -> effect.getDependencyTypes().contains(DependencyType.BecomePlains))
.map(Effect::getId) .map(Effect::getId)
.collect(Collectors.toSet()); .collect(Collectors.toSet());
} }
} }
} }

View file

@ -12,24 +12,23 @@ import mage.abilities.mana.WhiteManaAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.*; import mage.constants.*;
import mage.filter.common.FilterLandPermanent;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import mage.abilities.mana.BlackManaAbility;
import mage.abilities.mana.BlueManaAbility;
import mage.abilities.mana.GreenManaAbility;
import mage.abilities.mana.RedManaAbility;
/** /**
* *
* @author jmharmon * @author jmharmon
*/ */
public final class Glaciers extends CardImpl { public final class Glaciers extends CardImpl {
private static final FilterLandPermanent filter = new FilterLandPermanent(SubType.MOUNTAIN, "Mountains");
public Glaciers(UUID ownerId, CardSetInfo setInfo) { public Glaciers(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{W}{U}"); super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{W}{U}");
@ -72,15 +71,44 @@ public final class Glaciers extends CardImpl {
@Override @Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
for (Permanent land : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) { for (Permanent land : game.getBattlefield().getAllActivePermanents(CardType.LAND)) {
switch (layer) { switch (layer) {
case AbilityAddingRemovingEffects_6:
land.removeAllAbilities(source.getSourceId(), game);
land.addAbility(new WhiteManaAbility(), source.getSourceId(), game);
break;
case TypeChangingEffects_4: case TypeChangingEffects_4:
if (land.getSubtype(game).contains(SubType.MOUNTAIN)) {
land.getSubtype(game).clear(); land.getSubtype(game).clear();
land.getSubtype(game).add(SubType.PLAINS); land.getSubtype(game).add(SubType.PLAINS);
game.getState().setValue("glaciers"
+ source.getId()
+ land.getId()
+ land.getZoneChangeCounter(game), "true");
}
break;
case AbilityAddingRemovingEffects_6:
if (game.getState().getValue("glaciers"
+ source.getId()
+ land.getId()
+ land.getZoneChangeCounter(game)) != null
&& game.getState().getValue("glaciers"
+ source.getId()
+ land.getId()
+ land.getZoneChangeCounter(game)).equals("true")) {
land.removeAllAbilities(source.getSourceId(), game);
if (land.getSubtype(game).contains(SubType.FOREST)) {
land.addAbility(new GreenManaAbility(), source.getSourceId(), game);
}
if (land.getSubtype(game).contains(SubType.PLAINS)) {
land.addAbility(new WhiteManaAbility(), source.getSourceId(), game);
}
if (land.getSubtype(game).contains(SubType.MOUNTAIN)) {
land.addAbility(new RedManaAbility(), source.getSourceId(), game);
}
if (land.getSubtype(game).contains(SubType.ISLAND)) {
land.addAbility(new BlueManaAbility(), source.getSourceId(), game);
}
if (land.getSubtype(game).contains(SubType.SWAMP)) {
land.addAbility(new BlackManaAbility(), source.getSourceId(), game);
}
}
break; break;
} }
} }
@ -89,14 +117,15 @@ public final class Glaciers extends CardImpl {
@Override @Override
public boolean hasLayer(Layer layer) { public boolean hasLayer(Layer layer) {
return layer == Layer.AbilityAddingRemovingEffects_6 || layer == Layer.TypeChangingEffects_4; return layer == Layer.AbilityAddingRemovingEffects_6
|| layer == Layer.TypeChangingEffects_4;
} }
@Override @Override
public Set<UUID> isDependentTo(List<ContinuousEffect> allEffectsInLayer) { public Set<UUID> isDependentTo(List<ContinuousEffect> allEffectsInLayer) {
return allEffectsInLayer return allEffectsInLayer
.stream() .stream()
.filter(effect->effect.getDependencyTypes().contains(DependencyType.BecomeMountain)) .filter(effect -> effect.getDependencyTypes().contains(DependencyType.BecomePlains))
.map(Effect::getId) .map(Effect::getId)
.collect(Collectors.toSet()); .collect(Collectors.toSet());
} }

View file

@ -89,79 +89,49 @@ class IllusionaryTerrainEffect extends ContinuousEffectImpl {
&& firstChoice != null && firstChoice != null
&& secondChoice != null) { && secondChoice != null) {
for (Permanent land : lands) { for (Permanent land : lands) {
if (land != null if (land.isBasic()) {
&& land.isBasic()) {
switch (layer) { switch (layer) {
case TypeChangingEffects_4: case TypeChangingEffects_4:
if (sublayer == SubLayer.NA) { if (land.getSubtype(game).contains(firstChoice)) {
land.getSubtype(game).clear(); land.getSubtype(game).clear();
land.getSubtype(game).add(secondChoice); land.getSubtype(game).add(secondChoice);
game.getState().setValue("illusionaryTerrain"
+ source.getId()
+ land.getId()
+ land.getZoneChangeCounter(game),
"true");
} }
break; break;
case AbilityAddingRemovingEffects_6: case AbilityAddingRemovingEffects_6:
if (sublayer == SubLayer.NA) { if (game.getState().getValue("illusionaryTerrain"
boolean addAbility = true; + source.getId()
land.getAbilities().clear(); + land.getId()
if (secondChoice.equals(SubType.FOREST)) { + land.getZoneChangeCounter(game)) != null
for (Ability existingAbility : land.getAbilities()) { && game.getState().getValue("illusionaryTerrain"
if (existingAbility instanceof GreenManaAbility) { + source.getId()
addAbility = false; + land.getId()
break; + land.getZoneChangeCounter(game)).equals("true")) {
} land.removeAllAbilities(source.getSourceId(), game);
} if (land.getSubtype(game).contains(SubType.FOREST)) {
if (addAbility) {
land.addAbility(new GreenManaAbility(), source.getSourceId(), game); land.addAbility(new GreenManaAbility(), source.getSourceId(), game);
} }
} if (land.getSubtype(game).contains(SubType.PLAINS)) {
if (secondChoice.equals(SubType.PLAINS)) {
for (Ability existingAbility : land.getAbilities()) {
if (existingAbility instanceof WhiteManaAbility) {
addAbility = false;
break;
}
}
if (addAbility) {
land.addAbility(new WhiteManaAbility(), source.getSourceId(), game); land.addAbility(new WhiteManaAbility(), source.getSourceId(), game);
} }
} if (land.getSubtype(game).contains(SubType.MOUNTAIN)) {
if (secondChoice.equals(SubType.MOUNTAIN)) {
for (Ability existingAbility : land.getAbilities()) {
if (existingAbility instanceof RedManaAbility) {
addAbility = false;
break;
}
}
if (addAbility) {
land.addAbility(new RedManaAbility(), source.getSourceId(), game); land.addAbility(new RedManaAbility(), source.getSourceId(), game);
} }
} if (land.getSubtype(game).contains(SubType.ISLAND)) {
if (secondChoice.equals(SubType.ISLAND)) {
for (Ability existingAbility : land.getAbilities()) {
if (existingAbility instanceof BlueManaAbility) {
addAbility = false;
break;
}
}
if (addAbility) {
land.addAbility(new BlueManaAbility(), source.getSourceId(), game); land.addAbility(new BlueManaAbility(), source.getSourceId(), game);
} }
} if (land.getSubtype(game).contains(SubType.SWAMP)) {
if (secondChoice.equals(SubType.SWAMP)) {
for (Ability existingAbility : land.getAbilities()) {
if (existingAbility instanceof BlackManaAbility) {
addAbility = false;
break;
}
}
if (addAbility) {
land.addAbility(new BlackManaAbility(), source.getSourceId(), game); land.addAbility(new BlackManaAbility(), source.getSourceId(), game);
} }
}
}
break; break;
} }
} }
} }
}
return true; return true;
} }
return false; return false;
@ -174,8 +144,9 @@ class IllusionaryTerrainEffect extends ContinuousEffectImpl {
@Override @Override
public boolean hasLayer(Layer layer) { public boolean hasLayer(Layer layer) {
return layer == Layer.AbilityAddingRemovingEffects_6 return layer == Layer.TypeChangingEffects_4
|| layer == Layer.TypeChangingEffects_4; || layer == Layer.AbilityAddingRemovingEffects_6;
} }
} }

View file

@ -125,7 +125,8 @@ class PhantasmalTerrainContinuousEffect extends ContinuousEffectImpl {
@Override @Override
public boolean hasLayer(Layer layer) { public boolean hasLayer(Layer layer) {
return layer == Layer.AbilityAddingRemovingEffects_6 || layer == Layer.TypeChangingEffects_4; return layer == Layer.AbilityAddingRemovingEffects_6
|| layer == Layer.TypeChangingEffects_4;
} }
} }

View file

@ -1,4 +1,3 @@
package org.mage.test.cards.continuous; package org.mage.test.cards.continuous;
import mage.abilities.keyword.IndestructibleAbility; import mage.abilities.keyword.IndestructibleAbility;
@ -11,7 +10,6 @@ import mage.counters.CounterType;
import mage.filter.StaticFilters; import mage.filter.StaticFilters;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase; import org.mage.test.serverside.base.CardTestPlayerBase;
@ -114,10 +112,6 @@ public class LandTypeChangingEffectsTest extends CardTestPlayerBase {
String bloodmoon = "Blood Moon"; String bloodmoon = "Blood Moon";
String canopyvista = "Canopy Vista"; String canopyvista = "Canopy Vista";
/*
TODO: NOTE: this test is currently failing due to bug in code. See issue #3072
*/
//@Ignore
@Test @Test
public void testBloodMoonBeforeUrborg() { public void testBloodMoonBeforeUrborg() {
// Blood Moon 2R // Blood Moon 2R
@ -147,10 +141,6 @@ public class LandTypeChangingEffectsTest extends CardTestPlayerBase {
Assert.assertTrue("The mana the land can produce should be [{R}] but it's " + playerB.getManaAvailable(currentGame).toString(), playerB.getManaAvailable(currentGame).toString().equals("[{R}]")); Assert.assertTrue("The mana the land can produce should be [{R}] but it's " + playerB.getManaAvailable(currentGame).toString(), playerB.getManaAvailable(currentGame).toString().equals("[{R}]"));
} }
/*
TODO: NOTE: this test is currently failing due to bug in code. See issue #3072
*/
//@Ignore
@Test @Test
public void testBloodMoonAfterUrborg() { public void testBloodMoonAfterUrborg() {
// Blood Moon 2R // Blood Moon 2R
@ -186,6 +176,7 @@ public class LandTypeChangingEffectsTest extends CardTestPlayerBase {
In terms of time-stamp order, Urborg was down first, then Kormus Bell, then Quicksilver. In terms of time-stamp order, Urborg was down first, then Kormus Bell, then Quicksilver.
When I put a flood counter on a basic swamp, it would become a 0/0 instead of a 1/1 and die. When I put a flood counter on a basic swamp, it would become a 0/0 instead of a 1/1 and die.
*/ */
@Test @Test
public void testCormusBellAfterUrborg() { public void testCormusBellAfterUrborg() {
// Land - Legendary // Land - Legendary