diff --git a/Mage.Sets/src/mage/cards/q/QuicksilverFountain.java b/Mage.Sets/src/mage/cards/q/QuicksilverFountain.java new file mode 100644 index 00000000000..e4ea73af408 --- /dev/null +++ b/Mage.Sets/src/mage/cards/q/QuicksilverFountain.java @@ -0,0 +1,187 @@ +/* + * 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.cards.q; + +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.common.BeginningOfEndStepTriggeredAbility; +import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; +import mage.abilities.condition.Condition; +import mage.abilities.decorator.ConditionalContinuousEffect; +import mage.abilities.effects.Effect; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.continuous.BecomesBasicLandTargetEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.TargetController; +import mage.constants.Zone; +import mage.counters.CounterType; +import mage.filter.common.FilterLandPermanent; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.Target; +import mage.target.common.TargetLandPermanent; +import mage.target.targetpointer.FixedTarget; + +/** + * + * @author jeffwadsworth + */ +public class QuicksilverFountain extends CardImpl { + + public QuicksilverFountain(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{3}"); + + // At the beginning of each player's upkeep, that player puts a flood counter on target non-Island land he or she controls of his or her choice. That land is an Island for as long as it has a flood counter on it. + this.addAbility(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new QuicksilverFountainEffect(), TargetController.ANY, false, true)); + + // At the beginning of each end step, if all lands on the battlefield are Islands, remove all flood counters from them. + Condition condition = new AllLandsAreSubtypeCondition("Island"); + this.addAbility(new BeginningOfEndStepTriggeredAbility(Zone.BATTLEFIELD, new QuicksilverFountainEffect2(), TargetController.ANY, condition, false)); + + } + + public QuicksilverFountain(final QuicksilverFountain card) { + super(card); + } + + @Override + public QuicksilverFountain copy() { + return new QuicksilverFountain(this); + } +} + +class QuicksilverFountainEffect extends OneShotEffect { + + static final private FilterLandPermanent filterNonIslandLand = new FilterLandPermanent("non-Island land"); + + static { + filterNonIslandLand.add(Predicates.not(new SubtypePredicate("Island"))); + } + + public QuicksilverFountainEffect() { + super(Outcome.Neutral); + staticText = "that player puts a flood counter on target non-Island land he or she controls of his or her choice. That land is an Island for as long as it has a flood counter on it"; + } + + public QuicksilverFountainEffect(final QuicksilverFountainEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(targetPointer.getFirst(game, source)); + Target targetNonIslandLand = new TargetLandPermanent(filterNonIslandLand); + if (player != null) { + if (player.choose(Outcome.Neutral, targetNonIslandLand, source.getId(), game)) { + Permanent landChosen = game.getPermanent(targetNonIslandLand.getFirstTarget()); + landChosen.addCounters(CounterType.FLOOD.createInstance(), source, game); + ConditionalContinuousEffect effect = new ConditionalContinuousEffect(new BecomesBasicLandTargetEffect(Duration.OneUse, "Island"), new LandHasFloodCounterCondition(this), staticText); + this.setTargetPointer(new FixedTarget(landChosen, game)); + effect.setTargetPointer(new FixedTarget(landChosen, game)); + game.addEffect(effect, source); + return true; + } + } + return false; + } + + @Override + public QuicksilverFountainEffect copy() { + return new QuicksilverFountainEffect(this); + } +} + +class QuicksilverFountainEffect2 extends OneShotEffect { + + public QuicksilverFountainEffect2() { + super(Outcome.Neutral); + staticText = "remove all flood counters from them"; + } + + public QuicksilverFountainEffect2(final QuicksilverFountainEffect2 effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + for (Permanent land : game.getBattlefield().getAllActivePermanents(CardType.LAND)) { + land.removeCounters(CounterType.FLOOD.createInstance(land.getCounters(game).getCount(CounterType.FLOOD)), game); + } + return true; + } + + @Override + public QuicksilverFountainEffect2 copy() { + return new QuicksilverFountainEffect2(this); + } +} + +class AllLandsAreSubtypeCondition implements Condition { + + private final String subtype; + + public AllLandsAreSubtypeCondition(String subtype) { + this.subtype = subtype; + } + + @Override + public boolean apply(Game game, Ability source) { + FilterLandPermanent filterLand = new FilterLandPermanent(); + filterLand.add(new SubtypePredicate(subtype)); + int landCount = game.getBattlefield().getAllActivePermanents(CardType.LAND).size(); + return game.getBattlefield().getAllActivePermanents(filterLand, game).size() == landCount; + } + + @Override + public String toString() { + return "if all lands on the battlefield are " + subtype + "s"; + } +} + +class LandHasFloodCounterCondition implements Condition { + + private final Effect effect; + + public LandHasFloodCounterCondition(Effect effect) { + this.effect = effect; + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent permanent = game.getPermanent(effect.getTargetPointer().getFirst(game, source)); + return permanent != null + && permanent.getCounters(game).getCount(CounterType.FLOOD) > 0; + } +} diff --git a/Mage.Sets/src/mage/sets/Mirrodin.java b/Mage.Sets/src/mage/sets/Mirrodin.java index d35973de0a5..b839f531d86 100644 --- a/Mage.Sets/src/mage/sets/Mirrodin.java +++ b/Mage.Sets/src/mage/sets/Mirrodin.java @@ -208,6 +208,7 @@ public class Mirrodin extends ExpansionSet { cards.add(new SetCardInfo("Psychogenic Probe", 231, Rarity.RARE, mage.cards.p.PsychogenicProbe.class)); cards.add(new SetCardInfo("Pyrite Spellbomb", 232, Rarity.COMMON, mage.cards.p.PyriteSpellbomb.class)); cards.add(new SetCardInfo("Quicksilver Elemental", 47, Rarity.RARE, mage.cards.q.QuicksilverElemental.class)); + cards.add(new SetCardInfo("Quicksilver Fountain", 233, Rarity.RARE, mage.cards.q.QuicksilverFountain.class)); cards.add(new SetCardInfo("Raise the Alarm", 16, Rarity.COMMON, mage.cards.r.RaiseTheAlarm.class)); cards.add(new SetCardInfo("Razor Barrier", 17, Rarity.COMMON, mage.cards.r.RazorBarrier.class)); cards.add(new SetCardInfo("Regress", 48, Rarity.COMMON, mage.cards.r.Regress.class));