From 322695959ac5fb26a179c5ae2b3841a1e04653b0 Mon Sep 17 00:00:00 2001 From: jmharmon <37360760+jmharmon@users.noreply.github.com> Date: Thu, 10 Jan 2019 14:14:42 -0800 Subject: [PATCH] Implement Glaciers (#5485) * Implement Glaciers * Implement Glaciers * Update Glaciers.java * Update Glaciers.java --- Mage.Sets/src/mage/cards/g/Glaciers.java | 104 +++++++++++++++++++++++ Mage.Sets/src/mage/sets/IceAge.java | 1 + 2 files changed, 105 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/g/Glaciers.java diff --git a/Mage.Sets/src/mage/cards/g/Glaciers.java b/Mage.Sets/src/mage/cards/g/Glaciers.java new file mode 100644 index 0000000000..d0c6fa2be8 --- /dev/null +++ b/Mage.Sets/src/mage/cards/g/Glaciers.java @@ -0,0 +1,104 @@ +package mage.cards.g; + +import mage.abilities.Ability; +import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.ContinuousEffect; +import mage.abilities.effects.ContinuousEffectImpl; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.SacrificeSourceUnlessPaysEffect; +import mage.abilities.mana.WhiteManaAbility; +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 java.util.List; +import java.util.Set; +import java.util.UUID; +import java.util.stream.Collectors; + +/** + * + * @author jmharmon + */ + +public final class Glaciers extends CardImpl { + + private static final FilterLandPermanent filter = new FilterLandPermanent(SubType.MOUNTAIN, "Mountains"); + + public Glaciers(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{W}{U}"); + + // At the beginning of your upkeep, sacrifice Glaciers unless you pay {W}{U}. + this.addAbility(new BeginningOfUpkeepTriggeredAbility(new SacrificeSourceUnlessPaysEffect(new ManaCostsImpl("{W}{U}")), TargetController.YOU, false)); + + // All Mountains are Plains. + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GlaciersEffect())); + } + + public Glaciers(final Glaciers card) { + super(card); + } + + @Override + public Glaciers copy() { + return new Glaciers(this); + } + + static class GlaciersEffect extends ContinuousEffectImpl { + + GlaciersEffect() { + super(Duration.WhileOnBattlefield, Outcome.Detriment); + this.staticText = "All Mountains are Plains"; + } + + GlaciersEffect(final GlaciersEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + return false; + } + + @Override + public GlaciersEffect copy() { + return new GlaciersEffect(this); + } + + @Override + public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { + for (Permanent land : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) { + switch (layer) { + case AbilityAddingRemovingEffects_6: + land.removeAllAbilities(source.getSourceId(), game); + land.addAbility(new WhiteManaAbility(), source.getSourceId(), game); + break; + case TypeChangingEffects_4: + land.getSubtype(game).clear(); + land.getSubtype(game).add(SubType.PLAINS); + break; + } + } + return true; + } + + @Override + public boolean hasLayer(Layer layer) { + return layer == Layer.AbilityAddingRemovingEffects_6 || layer == Layer.TypeChangingEffects_4; + } + + @Override + public Set isDependentTo(List allEffectsInLayer) { + return allEffectsInLayer + .stream() + .filter(effect->effect.getDependencyTypes().contains(DependencyType.BecomeMountain)) + .map(Effect::getId) + .collect(Collectors.toSet()); + } + } +} diff --git a/Mage.Sets/src/mage/sets/IceAge.java b/Mage.Sets/src/mage/sets/IceAge.java index a7582ffa45..0e24e6143c 100644 --- a/Mage.Sets/src/mage/sets/IceAge.java +++ b/Mage.Sets/src/mage/sets/IceAge.java @@ -138,6 +138,7 @@ public final class IceAge extends ExpansionSet { cards.add(new SetCardInfo("Glacial Chasm", 353, Rarity.UNCOMMON, mage.cards.g.GlacialChasm.class)); cards.add(new SetCardInfo("Glacial Crevasses", 187, Rarity.RARE, mage.cards.g.GlacialCrevasses.class)); cards.add(new SetCardInfo("Glacial Wall", 71, Rarity.UNCOMMON, mage.cards.g.GlacialWall.class)); + cards.add(new SetCardInfo("Glaciers", 294, Rarity.RARE, mage.cards.g.Glaciers.class)); cards.add(new SetCardInfo("Goblin Lyre", 319, Rarity.RARE, mage.cards.g.GoblinLyre.class)); cards.add(new SetCardInfo("Goblin Mutant", 188, Rarity.UNCOMMON, mage.cards.g.GoblinMutant.class)); cards.add(new SetCardInfo("Goblin Snowman", 191, Rarity.UNCOMMON, mage.cards.g.GoblinSnowman.class));