From 23b2bd8b7e5adcaf590805169ef88f9ac9350d3a Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Wed, 8 Jan 2020 12:23:23 -0500 Subject: [PATCH] Implemented Dryad of Ilysian Grove --- .../src/mage/cards/d/DryadOfIlysianGrove.java | 44 +++++++++ Mage.Sets/src/mage/cards/p/PrismaticOmen.java | 91 +------------------ .../src/mage/sets/TherosBeyondDeath.java | 1 + .../BecomesAllBasicsControlledEffect.java | 86 ++++++++++++++++++ 4 files changed, 135 insertions(+), 87 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/d/DryadOfIlysianGrove.java create mode 100644 Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesAllBasicsControlledEffect.java diff --git a/Mage.Sets/src/mage/cards/d/DryadOfIlysianGrove.java b/Mage.Sets/src/mage/cards/d/DryadOfIlysianGrove.java new file mode 100644 index 00000000000..5e37dc5a2dd --- /dev/null +++ b/Mage.Sets/src/mage/cards/d/DryadOfIlysianGrove.java @@ -0,0 +1,44 @@ +package mage.cards.d; + +import mage.MageInt; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.common.continuous.BecomesAllBasicsControlledEffect; +import mage.abilities.effects.common.continuous.PlayAdditionalLandsControllerEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.SubType; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class DryadOfIlysianGrove extends CardImpl { + + public DryadOfIlysianGrove(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT, CardType.CREATURE}, "{2}{G}"); + + this.subtype.add(SubType.NYMPH); + this.power = new MageInt(2); + this.toughness = new MageInt(4); + + // You may play an additional land on each of your turns. + this.addAbility(new SimpleStaticAbility( + new PlayAdditionalLandsControllerEffect(1, Duration.WhileOnBattlefield) + )); + + // Lands you control are every basic land type in addition to their other types. + this.addAbility(new SimpleStaticAbility(new BecomesAllBasicsControlledEffect())); + } + + private DryadOfIlysianGrove(final DryadOfIlysianGrove card) { + super(card); + } + + @Override + public DryadOfIlysianGrove copy() { + return new DryadOfIlysianGrove(this); + } +} diff --git a/Mage.Sets/src/mage/cards/p/PrismaticOmen.java b/Mage.Sets/src/mage/cards/p/PrismaticOmen.java index 9403d698bd3..9a53dca6d17 100644 --- a/Mage.Sets/src/mage/cards/p/PrismaticOmen.java +++ b/Mage.Sets/src/mage/cards/p/PrismaticOmen.java @@ -1,19 +1,11 @@ package mage.cards.p; -import mage.Mana; -import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.effects.ContinuousEffectImpl; -import mage.abilities.mana.*; +import mage.abilities.effects.common.continuous.BecomesAllBasicsControlledEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.*; -import mage.filter.common.FilterLandPermanent; -import mage.game.Game; -import mage.game.permanent.Permanent; +import mage.constants.CardType; -import java.util.ArrayList; -import java.util.List; import java.util.UUID; /** @@ -25,10 +17,10 @@ public final class PrismaticOmen extends CardImpl { super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{G}"); // Lands you control are every basic land type in addition to their other types. - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BecomesBasicLandTypeAllEffect("Swamp", "Mountain", "Forest", "Island", "Plains"))); + this.addAbility(new SimpleStaticAbility(new BecomesAllBasicsControlledEffect())); } - public PrismaticOmen(final PrismaticOmen card) { + private PrismaticOmen(final PrismaticOmen card) { super(card); } @@ -37,78 +29,3 @@ public final class PrismaticOmen extends CardImpl { return new PrismaticOmen(this); } } - -class BecomesBasicLandTypeAllEffect extends ContinuousEffectImpl { - - protected List landTypes = new ArrayList<>(); - - public BecomesBasicLandTypeAllEffect(String... landNames) { - super(Duration.WhileOnBattlefield, Outcome.Detriment); - landTypes.addAll(SubType.getBasicLands()); - this.staticText = "Lands you control are every basic land type in addition to their other types"; - } - - public BecomesBasicLandTypeAllEffect(final BecomesBasicLandTypeAllEffect effect) { - super(effect); - this.landTypes.addAll(effect.landTypes); - } - - @Override - public boolean apply(Game game, Ability source) { - return false; - } - - @Override - public BecomesBasicLandTypeAllEffect copy() { - return new BecomesBasicLandTypeAllEffect(this); - } - - @Override - public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { - for (Permanent land : game.getState().getBattlefield().getAllActivePermanents(new FilterLandPermanent(), source.getControllerId(), game)) { - if (land != null) { - switch (layer) { - case AbilityAddingRemovingEffects_6: - Mana mana = new Mana(); - for (Ability ability : land.getAbilities()) { - if (ability instanceof BasicManaAbility) { - for (Mana netMana : ((BasicManaAbility) ability).getNetMana(game)) { - mana.add(netMana); - } - } - } - if (mana.getGreen() == 0 && landTypes.contains(SubType.FOREST)) { - land.addAbility(new GreenManaAbility(), source.getSourceId(), game); - } - if (mana.getRed() == 0 && landTypes.contains(SubType.MOUNTAIN)) { - land.addAbility(new RedManaAbility(), source.getSourceId(), game); - } - if (mana.getBlue() == 0 && landTypes.contains(SubType.ISLAND)) { - land.addAbility(new BlueManaAbility(), source.getSourceId(), game); - } - if (mana.getWhite() == 0 && landTypes.contains(SubType.PLAINS)) { - land.addAbility(new WhiteManaAbility(), source.getSourceId(), game); - } - if (mana.getBlack() == 0 && landTypes.contains(SubType.SWAMP)) { - land.addAbility(new BlackManaAbility(), source.getSourceId(), game); - } - break; - case TypeChangingEffects_4: - for (SubType subtype : landTypes) { - if (!land.hasSubtype(subtype, game)) { - land.getSubtype(game).add(subtype); - } - } - break; - } - } - - } - return true; - } - - @Override - public boolean hasLayer(Layer layer) { - return layer == Layer.AbilityAddingRemovingEffects_6 || layer == Layer.TypeChangingEffects_4; - } -} diff --git a/Mage.Sets/src/mage/sets/TherosBeyondDeath.java b/Mage.Sets/src/mage/sets/TherosBeyondDeath.java index fe84f4178ef..97d676af567 100644 --- a/Mage.Sets/src/mage/sets/TherosBeyondDeath.java +++ b/Mage.Sets/src/mage/sets/TherosBeyondDeath.java @@ -54,6 +54,7 @@ public final class TherosBeyondDeath extends ExpansionSet { cards.add(new SetCardInfo("Demon of Loathing", 292, Rarity.RARE, mage.cards.d.DemonOfLoathing.class)); cards.add(new SetCardInfo("Devourer of Memory", 213, Rarity.UNCOMMON, mage.cards.d.DevourerOfMemory.class)); cards.add(new SetCardInfo("Drag to the Underworld", 89, Rarity.UNCOMMON, mage.cards.d.DragToTheUnderworld.class)); + cards.add(new SetCardInfo("Dryad of Ilysian Grove", 169, Rarity.RARE, mage.cards.d.DryadOfIlysianGrove.class)); cards.add(new SetCardInfo("Eat to Extinction", 90, Rarity.RARE, mage.cards.e.EatToExtinction.class)); cards.add(new SetCardInfo("Eidolon of Philosophy", 48, Rarity.COMMON, mage.cards.e.EidolonOfPhilosophy.class)); cards.add(new SetCardInfo("Elspeth, Sun's Nemesis", 14, Rarity.MYTHIC, mage.cards.e.ElspethSunsNemesis.class)); diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesAllBasicsControlledEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesAllBasicsControlledEffect.java new file mode 100644 index 00000000000..693c71b5ed1 --- /dev/null +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesAllBasicsControlledEffect.java @@ -0,0 +1,86 @@ +package mage.abilities.effects.common.continuous; + +import mage.Mana; +import mage.abilities.Ability; +import mage.abilities.effects.ContinuousEffectImpl; +import mage.abilities.mana.*; +import mage.constants.*; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.permanent.Permanent; + +import java.util.Collection; + +/** + * @author TheElk801 + */ +public class BecomesAllBasicsControlledEffect extends ContinuousEffectImpl { + + public BecomesAllBasicsControlledEffect() { + super(Duration.WhileOnBattlefield, Outcome.Detriment); + this.staticText = "Lands you control are every basic land type in addition to their other types"; + } + + private BecomesAllBasicsControlledEffect(final BecomesAllBasicsControlledEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + return false; + } + + @Override + public BecomesAllBasicsControlledEffect copy() { + return new BecomesAllBasicsControlledEffect(this); + } + + @Override + public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { + game.getState() + .getBattlefield() + .getAllActivePermanents(StaticFilters.FILTER_LAND, source.getControllerId(), game) + .stream() + .forEach(land -> this.modifyLand(land, layer, source, game)); + return true; + } + + private void modifyLand(Permanent land, Layer layer, Ability source, Game game) { + if (layer == Layer.AbilityAddingRemovingEffects_6) { + Mana mana = new Mana(); + land.getAbilities() + .stream() + .filter(BasicManaAbility.class::isInstance) + .map(BasicManaAbility.class::cast) + .map(basicManaAbility -> basicManaAbility.getNetMana(game)) + .flatMap(Collection::stream) + .forEach(mana::add); + if (mana.getGreen() == 0) { + land.addAbility(new GreenManaAbility(), source.getSourceId(), game); + } + if (mana.getRed() == 0) { + land.addAbility(new RedManaAbility(), source.getSourceId(), game); + } + if (mana.getBlue() == 0) { + land.addAbility(new BlueManaAbility(), source.getSourceId(), game); + } + if (mana.getWhite() == 0) { + land.addAbility(new WhiteManaAbility(), source.getSourceId(), game); + } + if (mana.getBlack() == 0) { + land.addAbility(new BlackManaAbility(), source.getSourceId(), game); + } + } + if (layer == Layer.TypeChangingEffects_4) { + SubType.getBasicLands() + .stream() + .filter(subType -> !land.hasSubtype(subType, game)) + .forEach(land.getSubtype(game)::add); + } + } + + @Override + public boolean hasLayer(Layer layer) { + return layer == Layer.AbilityAddingRemovingEffects_6 || layer == Layer.TypeChangingEffects_4; + } +}