From e6250c5969c12df54cd4afe7c7e94faf836c707e Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Fri, 27 Jul 2018 12:09:10 -0400 Subject: [PATCH] Implemented Endless Atlas --- Mage.Sets/src/mage/cards/e/EndlessAtlas.java | 74 ++++++++++++++++++++ Mage.Sets/src/mage/sets/Commander2018.java | 1 + 2 files changed, 75 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/e/EndlessAtlas.java diff --git a/Mage.Sets/src/mage/cards/e/EndlessAtlas.java b/Mage.Sets/src/mage/cards/e/EndlessAtlas.java new file mode 100644 index 0000000000..022cb4b44e --- /dev/null +++ b/Mage.Sets/src/mage/cards/e/EndlessAtlas.java @@ -0,0 +1,74 @@ +package mage.cards.e; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.common.ActivateIfConditionActivatedAbility; +import mage.abilities.condition.Condition; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.effects.common.DrawCardSourceControllerEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Zone; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.permanent.Permanent; + +/** + * + * @author TheElk801 + */ +public final class EndlessAtlas extends CardImpl { + + public EndlessAtlas(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{2}"); + + // {2}, {T}: Draw a card. Activate this ability only if you control three or more lands with the same name. + Ability ability = new ActivateIfConditionActivatedAbility( + Zone.BATTLEFIELD, + new DrawCardSourceControllerEffect(1), + new GenericManaCost(2), + new EndlessAtlasCondition() + ); + ability.addCost(new TapSourceCost()); + this.addAbility(ability); + } + + public EndlessAtlas(final EndlessAtlas card) { + super(card); + } + + @Override + public EndlessAtlas copy() { + return new EndlessAtlas(this); + } +} + +class EndlessAtlasCondition implements Condition { + + @Override + public boolean apply(Game game, Ability source) { + Map landMap = new HashMap(); + for (Permanent land : game.getBattlefield().getActivePermanents( + StaticFilters.FILTER_CONTROLLED_PERMANENT_LAND, + source.getControllerId(), game + )) { + if (land != null) { + int landCount = landMap.getOrDefault(land.getName(), 0); + if (landCount > 1) { + return true; + } + landMap.put(land.getName(), landCount + 1); + } + } + return false; + } + + @Override + public String toString() { + return "you control three or more lands with the same name"; + } +} diff --git a/Mage.Sets/src/mage/sets/Commander2018.java b/Mage.Sets/src/mage/sets/Commander2018.java index 5751546ccf..55c291bf2a 100644 --- a/Mage.Sets/src/mage/sets/Commander2018.java +++ b/Mage.Sets/src/mage/sets/Commander2018.java @@ -46,6 +46,7 @@ public final class Commander2018 extends ExpansionSet { cards.add(new SetCardInfo("Empyrial Storm", 2, Rarity.RARE, mage.cards.e.EmpyrialStorm.class)); cards.add(new SetCardInfo("Enchanter's Bane", 21, Rarity.RARE, mage.cards.e.EnchantersBane.class)); cards.add(new SetCardInfo("Enchantress's Presence", 141, Rarity.RARE, mage.cards.e.EnchantresssPresence.class)); + cards.add(new SetCardInfo("Endless Atlas", 55, Rarity.RARE, mage.cards.e.EndlessAtlas.class)); cards.add(new SetCardInfo("Entreat the Dead", 15, Rarity.RARE, mage.cards.e.EntreatTheDead.class)); cards.add(new SetCardInfo("Estrid's Invocation", 8, Rarity.RARE, mage.cards.e.EstridsInvocation.class)); cards.add(new SetCardInfo("Explosive Vegetation", 144, Rarity.UNCOMMON, mage.cards.e.ExplosiveVegetation.class));