From 0a88531333796b1d9dfc84dd2ea6617c9c507c2c Mon Sep 17 00:00:00 2001 From: Styxo Date: Wed, 7 Dec 2016 11:47:01 +0100 Subject: [PATCH] [LRW] Added Colfenors Plan and Colfenors Urn --- .../src/mage/cards/c/ColfenorsPlans.java | 192 ++++++++++++++++++ Mage.Sets/src/mage/cards/c/ColfenorsUrn.java | 138 +++++++++++++ Mage.Sets/src/mage/sets/Lorwyn.java | 2 + 3 files changed, 332 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/c/ColfenorsPlans.java create mode 100644 Mage.Sets/src/mage/cards/c/ColfenorsUrn.java diff --git a/Mage.Sets/src/mage/cards/c/ColfenorsPlans.java b/Mage.Sets/src/mage/cards/c/ColfenorsPlans.java new file mode 100644 index 00000000000..d1fd6e37a19 --- /dev/null +++ b/Mage.Sets/src/mage/cards/c/ColfenorsPlans.java @@ -0,0 +1,192 @@ +/* + * 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.c; + +import java.util.UUID; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.AsThoughEffectImpl; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.SkipDrawStepEffect; +import mage.abilities.effects.common.continuous.CantCastMoreThanOneSpellEffect; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.AsThoughEffectType; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.TargetController; +import mage.constants.Zone; +import mage.game.ExileZone; +import mage.game.Game; +import mage.players.Player; +import mage.util.CardUtil; + +/** + * + * @author Styxo + */ +public class ColfenorsPlans extends CardImpl { + + public ColfenorsPlans(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{B}{B}"); + + // When Colfenor's Plans enters the battlefield, exile the top seven cards of your library face down. + this.addAbility(new EntersBattlefieldTriggeredAbility(new ColfenorsPlansExileEffect(), false)); + + // You may look at and play cards exiled with Colfenor's Plans. + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ColfenorsPlansPlayCardEffect())); + this.addAbility(new SimpleStaticAbility(Zone.ALL, new ColfenorsPlansLookAtCardEffect())); + + // Skip your draw step. + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new SkipDrawStepEffect())); + + // You can't cast more than one spell each turn. + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantCastMoreThanOneSpellEffect(TargetController.YOU))); + + } + + public ColfenorsPlans(final ColfenorsPlans card) { + super(card); + } + + @Override + public ColfenorsPlans copy() { + return new ColfenorsPlans(this); + } +} + +class ColfenorsPlansExileEffect extends OneShotEffect { + + public ColfenorsPlansExileEffect() { + super(Outcome.DrawCard); + staticText = "exile the top seven cards of your library face down"; + } + + public ColfenorsPlansExileEffect(final ColfenorsPlansExileEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + MageObject sourceObject = game.getObject(source.getSourceId()); + if (player != null && sourceObject != null) { + for (int i = 0; i < 7; i++) { + Card card = player.getLibrary().removeFromTop(game); + if (card != null) { + if (player.moveCardToExileWithInfo(card, CardUtil.getCardExileZoneId(game, source), sourceObject.getIdName(), source.getSourceId(), game, Zone.LIBRARY, true)) { + card.setFaceDown(true, game); + } + } + } + return true; + } + return false; + } + + @Override + public ColfenorsPlansExileEffect copy() { + return new ColfenorsPlansExileEffect(this); + } +} + +class ColfenorsPlansPlayCardEffect extends AsThoughEffectImpl { + + public ColfenorsPlansPlayCardEffect() { + super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, Duration.WhileOnBattlefield, Outcome.Benefit); + staticText = "You may play cards exiled with {this}"; + } + + public ColfenorsPlansPlayCardEffect(final ColfenorsPlansPlayCardEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } + + @Override + public ColfenorsPlansPlayCardEffect copy() { + return new ColfenorsPlansPlayCardEffect(this); + } + + @Override + public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { + Card card = game.getCard(objectId); + if (affectedControllerId.equals(source.getControllerId()) && card != null && game.getState().getZone(card.getId()) == Zone.EXILED) { + ExileZone zone = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source)); + return zone != null && zone.contains(card.getId()); + } + return false; + } +} + +class ColfenorsPlansLookAtCardEffect extends AsThoughEffectImpl { + + public ColfenorsPlansLookAtCardEffect() { + super(AsThoughEffectType.LOOK_AT_FACE_DOWN, Duration.EndOfGame, Outcome.Benefit); + staticText = "You may look at cards exiled with {this}"; + } + + public ColfenorsPlansLookAtCardEffect(final ColfenorsPlansLookAtCardEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } + + @Override + public ColfenorsPlansLookAtCardEffect copy() { + return new ColfenorsPlansLookAtCardEffect(this); + } + + @Override + public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { + if (affectedControllerId.equals(source.getControllerId())) { + Card card = game.getCard(objectId); + if (card != null) { + MageObject sourceObject = game.getObject(source.getSourceId()); + if (sourceObject == null) { + return false; + } + UUID exileId = CardUtil.getCardExileZoneId(game, source); + ExileZone exile = game.getExile().getExileZone(exileId); + return exile != null && exile.contains(objectId); + } + } + return false; + } + +} diff --git a/Mage.Sets/src/mage/cards/c/ColfenorsUrn.java b/Mage.Sets/src/mage/cards/c/ColfenorsUrn.java new file mode 100644 index 00000000000..0c477bc253c --- /dev/null +++ b/Mage.Sets/src/mage/cards/c/ColfenorsUrn.java @@ -0,0 +1,138 @@ +/* + * 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.c; + +import java.util.UUID; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.common.BeginningOfEndStepTriggeredAbility; +import mage.abilities.common.DiesCreatureTriggeredAbility; +import mage.abilities.condition.Condition; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.ExileTargetForSourceEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.TargetController; +import mage.constants.Zone; +import mage.filter.Filter; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.mageobject.ToughnessPredicate; +import mage.game.ExileZone; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.util.CardUtil; + +/** + * + * @author Styxo + */ +public class ColfenorsUrn extends CardImpl { + + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("a creature with toughness 4 or greater"); + + static { + filter.add(new ToughnessPredicate(Filter.ComparisonType.GreaterThan, 3)); + } + + public ColfenorsUrn(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{3}"); + + // Whenever a creature with toughness 4 or greater is put into your graveyard from the battlefield, you may exile it. + this.addAbility(new DiesCreatureTriggeredAbility(new ExileTargetForSourceEffect(), true, filter, true)); + + // At the beginning of the end step, if three or more cards have been exiled with Colfenor's Urn, sacrifice it. If you do, return those cards to the battlefield under their owner's control. + this.addAbility(new BeginningOfEndStepTriggeredAbility(Zone.BATTLEFIELD, new ColfenorsUrnEffect(), TargetController.ANY, new ColfenorsUrnCondition(), false)); + } + + public ColfenorsUrn(final ColfenorsUrn card) { + super(card); + } + + @Override + public ColfenorsUrn copy() { + return new ColfenorsUrn(this); + } +} + +class ColfenorsUrnEffect extends OneShotEffect { + + public ColfenorsUrnEffect() { + super(Outcome.PutCreatureInPlay); + this.staticText = "If you do, return those cards to the battlefield under their owner's control"; + } + + public ColfenorsUrnEffect(final ColfenorsUrnEffect effect) { + super(effect); + } + + @Override + public ColfenorsUrnEffect copy() { + return new ColfenorsUrnEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + Permanent permanent = (Permanent) source.getSourceObjectIfItStillExists(game); + if (controller != null && permanent != null) { + UUID exileId = CardUtil.getCardExileZoneId(game, source); + ExileZone exile = game.getExile().getExileZone(exileId); + if (permanent.sacrifice(source.getSourceId(), game)) { + controller.moveCards(exile.getCards(game), Zone.BATTLEFIELD, source, game); + } + return true; + + } + return false; + } +} + +class ColfenorsUrnCondition implements Condition { + + @Override + public final boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + MageObject sourceObject = game.getObject(source.getSourceId()); + if (controller != null && sourceObject != null) { + UUID exileId = CardUtil.getCardExileZoneId(game, source); + ExileZone exile = game.getExile().getExileZone(exileId); + if (exile != null) { + return exile.size() > 2; + } + } + return false; + } + + @Override + public String toString() { + return "if three or more cards have been exiled with Colfenor's Urn, sacrifice it."; + } +} diff --git a/Mage.Sets/src/mage/sets/Lorwyn.java b/Mage.Sets/src/mage/sets/Lorwyn.java index a911d9f488b..89aac18df37 100644 --- a/Mage.Sets/src/mage/sets/Lorwyn.java +++ b/Mage.Sets/src/mage/sets/Lorwyn.java @@ -97,6 +97,8 @@ public class Lorwyn extends ExpansionSet { cards.add(new SetCardInfo("Cloudcrown Oak", 201, Rarity.COMMON, mage.cards.c.CloudcrownOak.class)); cards.add(new SetCardInfo("Cloudgoat Ranger", 10, Rarity.UNCOMMON, mage.cards.c.CloudgoatRanger.class)); cards.add(new SetCardInfo("Cloudthresher", 202, Rarity.RARE, mage.cards.c.Cloudthresher.class)); + cards.add(new SetCardInfo("Colfenor's Plans", 106, Rarity.RARE, mage.cards.c.ColfenorsPlans.class)); + cards.add(new SetCardInfo("Colfenor's Urn", 254, Rarity.RARE, mage.cards.c.ColfenorsUrn.class)); cards.add(new SetCardInfo("Consuming Bonfire", 161, Rarity.COMMON, mage.cards.c.ConsumingBonfire.class)); cards.add(new SetCardInfo("Crib Swap", 11, Rarity.UNCOMMON, mage.cards.c.CribSwap.class)); cards.add(new SetCardInfo("Crush Underfoot", 162, Rarity.UNCOMMON, mage.cards.c.CrushUnderfoot.class));