diff --git a/Mage.Sets/src/mage/sets/futuresight/ScoutsWarning.java b/Mage.Sets/src/mage/sets/futuresight/ScoutsWarning.java index 624abe4f6e..892d040cf7 100644 --- a/Mage.Sets/src/mage/sets/futuresight/ScoutsWarning.java +++ b/Mage.Sets/src/mage/sets/futuresight/ScoutsWarning.java @@ -75,6 +75,7 @@ public class ScoutsWarning extends CardImpl { } class ScoutsWarningAsThoughEffect extends AsThoughEffectImpl { + private ScoutsWarningWatcher watcher; private int zoneChangeCounter; @@ -91,12 +92,12 @@ class ScoutsWarningAsThoughEffect extends AsThoughEffectImpl { @Override public void init(Ability source, Game game) { - watcher = (ScoutsWarningWatcher) game.getState().getWatchers().get("consumeScoutsWarningWatcher", source.getControllerId()); - Card card = game.getCard(source.getSourceId()); - if (watcher != null && card != null) { - zoneChangeCounter = card.getZoneChangeCounter(game); - watcher.addScoutsWarningSpell(source.getSourceId(), zoneChangeCounter); - } + watcher = (ScoutsWarningWatcher) game.getState().getWatchers().get("consumeScoutsWarningWatcher", source.getControllerId()); + Card card = game.getCard(source.getSourceId()); + if (watcher != null && card != null) { + zoneChangeCounter = card.getZoneChangeCounter(game); + watcher.addScoutsWarningSpell(source.getSourceId(), zoneChangeCounter); + } } @Override @@ -109,13 +110,12 @@ class ScoutsWarningAsThoughEffect extends AsThoughEffectImpl { return new ScoutsWarningAsThoughEffect(this); } - @Override public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) { if (watcher.isScoutsWarningSpellActive(source.getSourceId(), zoneChangeCounter)) { Card card = game.getCard(sourceId); if (card != null && card.getCardType().contains(CardType.CREATURE) && source.getControllerId().equals(affectedControllerId)) { - return card.getSpellAbility().isInUseableZone(game, card, null); + return true; } } return false; diff --git a/Mage.Sets/src/mage/sets/guildpact/Quicken.java b/Mage.Sets/src/mage/sets/guildpact/Quicken.java index 3b75f314c5..35a3f0e25b 100644 --- a/Mage.Sets/src/mage/sets/guildpact/Quicken.java +++ b/Mage.Sets/src/mage/sets/guildpact/Quicken.java @@ -30,17 +30,17 @@ package mage.sets.guildpact; import java.util.ArrayList; import java.util.List; import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.effects.AsThoughEffectImpl; +import mage.abilities.effects.common.DrawCardSourceControllerEffect; +import mage.cards.Card; +import mage.cards.CardImpl; import mage.constants.AsThoughEffectType; import mage.constants.CardType; import mage.constants.Duration; import mage.constants.Outcome; import mage.constants.Rarity; import mage.constants.WatcherScope; -import mage.abilities.Ability; -import mage.abilities.effects.AsThoughEffectImpl; -import mage.abilities.effects.common.DrawCardSourceControllerEffect; -import mage.cards.Card; -import mage.cards.CardImpl; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.stack.Spell; @@ -57,7 +57,6 @@ public class Quicken extends CardImpl { super(ownerId, 31, "Quicken", Rarity.RARE, new CardType[]{CardType.INSTANT}, "{U}"); this.expansionSetCode = "GPT"; - // The next sorcery card you cast this turn can be cast as though it had flash. this.getSpellAbility().addEffect(new QuickenAsThoughEffect()); this.getSpellAbility().addWatcher(new QuickenWatcher()); @@ -77,6 +76,7 @@ public class Quicken extends CardImpl { } class QuickenAsThoughEffect extends AsThoughEffectImpl { + private QuickenWatcher quickenWatcher; private int zoneChangeCounter; @@ -93,12 +93,12 @@ class QuickenAsThoughEffect extends AsThoughEffectImpl { @Override public void init(Ability source, Game game) { - quickenWatcher = (QuickenWatcher) game.getState().getWatchers().get("consumeQuickenWatcher", source.getControllerId()); - Card card = game.getCard(source.getSourceId()); - if (quickenWatcher != null && card != null) { - zoneChangeCounter = card.getZoneChangeCounter(game); - quickenWatcher.addQuickenSpell(source.getSourceId(), zoneChangeCounter); - } + quickenWatcher = (QuickenWatcher) game.getState().getWatchers().get("consumeQuickenWatcher", source.getControllerId()); + Card card = game.getCard(source.getSourceId()); + if (quickenWatcher != null && card != null) { + zoneChangeCounter = card.getZoneChangeCounter(game); + quickenWatcher.addQuickenSpell(source.getSourceId(), zoneChangeCounter); + } } @Override @@ -111,13 +111,12 @@ class QuickenAsThoughEffect extends AsThoughEffectImpl { return new QuickenAsThoughEffect(this); } - @Override public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) { if (quickenWatcher.isQuickenSpellActive(source.getSourceId(), zoneChangeCounter)) { Card card = game.getCard(sourceId); if (card != null && card.getCardType().contains(CardType.SORCERY) && source.getControllerId().equals(affectedControllerId)) { - return card.getSpellAbility().isInUseableZone(game, card, null); + return true; } } return false; diff --git a/Mage.Sets/src/mage/sets/magicorigins/JaceTelepathUnbound.java b/Mage.Sets/src/mage/sets/magicorigins/JaceTelepathUnbound.java new file mode 100644 index 0000000000..968cc70af6 --- /dev/null +++ b/Mage.Sets/src/mage/sets/magicorigins/JaceTelepathUnbound.java @@ -0,0 +1,217 @@ +/* + * 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.sets.magicorigins; + +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.LoyaltyAbility; +import mage.abilities.common.EntersBattlefieldAbility; +import mage.abilities.common.SpellCastControllerTriggeredAbility; +import mage.abilities.effects.AsThoughEffectImpl; +import mage.abilities.effects.ContinuousEffect; +import mage.abilities.effects.Effect; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.effects.common.GetEmblemEffect; +import mage.abilities.effects.common.PutTopCardOfLibraryIntoGraveTargetEffect; +import mage.abilities.effects.common.continuous.BoostTargetEffect; +import mage.abilities.effects.common.counter.AddCountersSourceEffect; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.constants.AsThoughEffectType; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.Zone; +import mage.counters.CounterType; +import mage.filter.common.FilterInstantOrSorceryCard; +import mage.game.Game; +import mage.game.command.Emblem; +import mage.game.events.GameEvent; +import mage.game.events.ZoneChangeEvent; +import mage.players.Player; +import mage.target.common.TargetCardInGraveyard; +import mage.target.common.TargetCreaturePermanent; +import mage.target.common.TargetOpponent; +import mage.target.targetpointer.FixedTarget; + +/** + * + * @author LevelX2 + */ +public class JaceTelepathUnbound extends CardImpl { + + public JaceTelepathUnbound(UUID ownerId) { + super(ownerId, 60, "Jace, Telepath Unbound", Rarity.MYTHIC, new CardType[]{CardType.PLANESWALKER}, ""); + this.expansionSetCode = "ORI"; + this.subtype.add("Jace"); + + this.nightCard = true; + this.canTransform = true; + + this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.LOYALTY.createInstance(5)), false)); + + // +1: Up to one target creature gets -2/-0 until your next turn. + Ability ability = new LoyaltyAbility(new BoostTargetEffect(-2, 0, Duration.UntilYourNextTurn), 1); + ability.addTarget(new TargetCreaturePermanent(0, 1)); + this.addAbility(ability); + + // -3: You may cast target instant or sorcery card from your graveyard this turn. If that card would be put into your graveyard this turn, exile it instead. + ability = new LoyaltyAbility(new JaceTelepathUnboundEffect(), -3); + ability.addTarget(new TargetCardInGraveyard(new FilterInstantOrSorceryCard())); + this.addAbility(ability); + + // -9: You get an emblem with "Whenever you cast a spell, target opponent puts the top five cards of his or her library into his or her graveyard". + this.addAbility(new LoyaltyAbility(new GetEmblemEffect(new JaceTelepathUnboundEmblem()), -9)); + } + + public JaceTelepathUnbound(final JaceTelepathUnbound card) { + super(card); + } + + @Override + public JaceTelepathUnbound copy() { + return new JaceTelepathUnbound(this); + } +} + +class JaceTelepathUnboundEffect extends OneShotEffect { + + JaceTelepathUnboundEffect() { + super(Outcome.Benefit); + this.staticText = "You may cast target instant or sorcery card from your graveyard this turn. If that card would be put into your graveyard this turn, exile it instead"; + } + + JaceTelepathUnboundEffect(final JaceTelepathUnboundEffect effect) { + super(effect); + } + + @Override + public JaceTelepathUnboundEffect copy() { + return new JaceTelepathUnboundEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Card card = game.getCard(this.getTargetPointer().getFirst(game, source)); + if (card != null) { + ContinuousEffect effect = new JaceTelepathUnboundCastFromGraveyardEffect(); + effect.setTargetPointer(new FixedTarget(card.getId())); + game.addEffect(effect, source); + effect = new JaceTelepathUnboundReplacementEffect(card.getId()); + game.addEffect(effect, source); + return true; + } + return false; + } +} + +class JaceTelepathUnboundCastFromGraveyardEffect extends AsThoughEffectImpl { + + JaceTelepathUnboundCastFromGraveyardEffect() { + super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, Duration.EndOfTurn, Outcome.Benefit); + } + + JaceTelepathUnboundCastFromGraveyardEffect(final JaceTelepathUnboundCastFromGraveyardEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } + + @Override + public JaceTelepathUnboundCastFromGraveyardEffect copy() { + return new JaceTelepathUnboundCastFromGraveyardEffect(this); + } + + @Override + public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { + return objectId.equals(this.getTargetPointer().getFirst(game, source)) && affectedControllerId.equals(source.getControllerId()); + } +} + +class JaceTelepathUnboundReplacementEffect extends ReplacementEffectImpl { + + private final UUID cardId; + + JaceTelepathUnboundReplacementEffect(UUID cardId) { + super(Duration.EndOfTurn, Outcome.Exile); + this.cardId = cardId; + staticText = "If that card would be put into your graveyard this turn, exile it instead"; + } + + JaceTelepathUnboundReplacementEffect(final JaceTelepathUnboundReplacementEffect effect) { + super(effect); + this.cardId = effect.cardId; + } + + @Override + public JaceTelepathUnboundReplacementEffect copy() { + return new JaceTelepathUnboundReplacementEffect(this); + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + Player controller = game.getPlayer(source.getControllerId()); + Card card = game.getCard(this.cardId); + if (controller != null && card != null) { + controller.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.STACK, true); + return true; + } + return false; + } + + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.ZONE_CHANGE; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + ZoneChangeEvent zEvent = (ZoneChangeEvent) event; + return zEvent.getToZone() == Zone.GRAVEYARD + && zEvent.getTargetId().equals(this.cardId); + } +} + +class JaceTelepathUnboundEmblem extends Emblem { + + // You get an emblem with "Whenever you cast a spell, target opponent puts the top five cards of his or her library into his or her graveyard". + + public JaceTelepathUnboundEmblem() { + this.setName("Emblem - Jace"); + Effect effect = new PutTopCardOfLibraryIntoGraveTargetEffect(5); + effect.setText("target opponent puts the top five cards of his or her library into his or her graveyard"); + Ability ability = new SpellCastControllerTriggeredAbility(effect, false); + ability.addTarget(new TargetOpponent()); + getAbilities().add(ability); + } +} diff --git a/Mage.Sets/src/mage/sets/magicorigins/JaceVrynsProdigy.java b/Mage.Sets/src/mage/sets/magicorigins/JaceVrynsProdigy.java new file mode 100644 index 0000000000..53768f4e30 --- /dev/null +++ b/Mage.Sets/src/mage/sets/magicorigins/JaceVrynsProdigy.java @@ -0,0 +1,82 @@ +/* + * 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.sets.magicorigins; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.condition.common.CardsInControllerGraveCondition; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.decorator.ConditionalOneShotEffect; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.DrawDiscardControllerEffect; +import mage.abilities.effects.common.ExileAndReturnTransformedSourceEffect; +import mage.abilities.effects.common.ExileAndReturnTransformedSourceEffect.Gender; +import mage.abilities.keyword.TransformAbility; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Rarity; +import mage.constants.Zone; + +/** + * + * @author LevelX2 + */ +public class JaceVrynsProdigy extends CardImpl { + + public JaceVrynsProdigy(UUID ownerId) { + super(ownerId, 60, "Jace, Vryn's Prodigy", Rarity.MYTHIC, new CardType[]{CardType.CREATURE}, "{1}{U}"); + this.expansionSetCode = "ORI"; + this.supertype.add("Legendary"); + this.subtype.add("Human"); + this.subtype.add("Wizard"); + this.power = new MageInt(0); + this.toughness = new MageInt(2); + + this.canTransform = true; + this.secondSideCard = new JaceTelepathUnbound(ownerId); + + // {T}: Draw a card, then discard a card. If there are five or more cards in your graveyard, exile Jace, Vryn's Prodigy, then return him to the battefield transformed under his owner's control. + this.addAbility(new TransformAbility()); + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DrawDiscardControllerEffect(1, 1), new TapSourceCost()); + Effect effect = new ConditionalOneShotEffect(new ExileAndReturnTransformedSourceEffect(Gender.MALE), new CardsInControllerGraveCondition(5)); + ability.addEffect(effect); + this.addAbility(ability); + + } + + public JaceVrynsProdigy(final JaceVrynsProdigy card) { + super(card); + } + + @Override + public JaceVrynsProdigy copy() { + return new JaceVrynsProdigy(this); + } +} diff --git a/Mage.Sets/src/mage/sets/magicorigins/SphinxsTutelage.java b/Mage.Sets/src/mage/sets/magicorigins/SphinxsTutelage.java new file mode 100644 index 0000000000..7e75184c2d --- /dev/null +++ b/Mage.Sets/src/mage/sets/magicorigins/SphinxsTutelage.java @@ -0,0 +1,129 @@ +/* + * 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.sets.magicorigins; + +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.common.DrawCardControllerTriggeredAbility; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.DrawDiscardControllerEffect; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.Cards; +import mage.cards.CardsImpl; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.Zone; +import mage.game.Game; +import mage.players.Player; +import mage.target.common.TargetOpponent; + +/** + * + * @author LevelX2 + */ +public class SphinxsTutelage extends CardImpl { + + public SphinxsTutelage(UUID ownerId) { + super(ownerId, 76, "Sphinx's Tutelage", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{2}{U}"); + this.expansionSetCode = "ORI"; + + // Whenever you draw a card, target opponent puts the top two cards of his or her library into his or her graveyard. If they're both nonland cards that share a color, repeat this process. + Ability ability = new DrawCardControllerTriggeredAbility(new SphinxsTutelageEffect(), false); + ability.addTarget(new TargetOpponent()); + this.addAbility(ability); + + // {5}{U}: Draw a card, then discard a card. + this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new DrawDiscardControllerEffect(1, 1), new ManaCostsImpl<>("{5}{U}"))); + } + + public SphinxsTutelage(final SphinxsTutelage card) { + super(card); + } + + @Override + public SphinxsTutelage copy() { + return new SphinxsTutelage(this); + } +} + +class SphinxsTutelageEffect extends OneShotEffect { + + public SphinxsTutelageEffect() { + super(Outcome.Benefit); + this.staticText = "target opponent puts the top two cards of his or her library into his or her graveyard. If they're both nonland cards that share a color, repeat this process"; + } + + public SphinxsTutelageEffect(final SphinxsTutelageEffect effect) { + super(effect); + } + + @Override + public SphinxsTutelageEffect copy() { + return new SphinxsTutelageEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player targetPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source)); + boolean colorShared; + if (targetPlayer != null) { + int possibleIterations = targetPlayer.getLibrary().size() / 2; + int iteration = 0; + do { + iteration++; + if (iteration > possibleIterations + 20) { + // 801.16. If the game somehow enters a "loop" of mandatory actions, repeating a sequence of events + // with no way to stop, the game is a draw for each player who controls an object that's involved in + // that loop, as well as for each player within the range of influence of any of those players. They + // leave the game. All remaining players continue to play the game. + game.setDraw(source.getControllerId()); + return true; + } + colorShared = false; + Cards cards = new CardsImpl(); + cards.addAll(targetPlayer.getLibrary().getTopCards(game, 2)); + if (!cards.isEmpty()) { + Card card1 = targetPlayer.getLibrary().removeFromTop(game); + if (!card1.getCardType().contains(CardType.LAND) && targetPlayer.getLibrary().size() > 0) { + Card card2 = targetPlayer.getLibrary().removeFromTop(game); + if (!card2.getCardType().contains(CardType.LAND)) { + colorShared = card1.getColor(game).shares(card2.getColor(game)); + } + } + } + targetPlayer.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game); + } while (colorShared && targetPlayer.isInGame()); + return true; + } + return false; + } +} diff --git a/Mage.Sets/src/mage/sets/magicorigins/TalentOfTheTelepath.java b/Mage.Sets/src/mage/sets/magicorigins/TalentOfTheTelepath.java new file mode 100644 index 0000000000..ba137cd423 --- /dev/null +++ b/Mage.Sets/src/mage/sets/magicorigins/TalentOfTheTelepath.java @@ -0,0 +1,146 @@ +/* + * 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.sets.magicorigins; + +import java.util.List; +import java.util.UUID; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.condition.common.SpellMasteryCondition; +import mage.abilities.effects.OneShotEffect; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.Cards; +import mage.cards.CardsImpl; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.Zone; +import mage.filter.FilterCard; +import mage.filter.common.FilterInstantOrSorceryCard; +import mage.game.Game; +import mage.players.Player; +import mage.target.TargetCard; +import mage.target.common.TargetOpponent; + +/** + * + * @author LevelX2 + */ +public class TalentOfTheTelepath extends CardImpl { + + public TalentOfTheTelepath(UUID ownerId) { + super(ownerId, 78, "Talent of the Telepath", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{2}{U}{U}"); + this.expansionSetCode = "ORI"; + + // Target opponent reveals the top seven cards of his or her library. You may cast an instant or sorcery card from among them without paying its mana cost. Then that player puts the rest into his or her graveyard. + // Spell mastery - If there are two or more instant and/or sorcery cards in your graveyard, you may cast up to two revealed instant and/or sorcery cards instead of one. + getSpellAbility().addEffect(new TalentOfTheTelepathEffect()); + getSpellAbility().addTarget(new TargetOpponent()); + + } + + public TalentOfTheTelepath(final TalentOfTheTelepath card) { + super(card); + } + + @Override + public TalentOfTheTelepath copy() { + return new TalentOfTheTelepath(this); + } +} + +class TalentOfTheTelepathEffect extends OneShotEffect { + + private static final FilterCard filter = new FilterInstantOrSorceryCard(); + + public TalentOfTheTelepathEffect() { + super(Outcome.PlayForFree); + this.staticText = "Target opponent reveals the top seven cards of his or her library. You may cast an instant or sorcery card from among them without paying its mana cost. Then that player puts the rest into his or her graveyard. " + + "
Spell mastery - If there are two or more instant and/or sorcery cards in your graveyard, you may cast up to two revealed instant and/or sorcery cards instead of one."; + } + + public TalentOfTheTelepathEffect(final TalentOfTheTelepathEffect effect) { + super(effect); + } + + @Override + public TalentOfTheTelepathEffect copy() { + return new TalentOfTheTelepathEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Cards cardsToCast = new CardsImpl(); + Player targetOpponent = game.getPlayer(targetPointer.getFirst(game, source)); + MageObject sourceObject = source.getSourceObject(game); + if (targetOpponent != null && sourceObject != null) { + List allCards = targetOpponent.getLibrary().getTopCards(game, 7); + Cards cards = new CardsImpl(Zone.LIBRARY, allCards); + targetOpponent.revealCards(sourceObject.getIdName() + " - " + targetOpponent.getName() + "'s top library cards", cards, game); + for (Card card : allCards) { + if (filter.match(card, game)) { + cardsToCast.add(card); + } + } + // cast an instant or sorcery for free + if (cardsToCast.size() > 0) { + int numberOfSpells = 1; + if (SpellMasteryCondition.getInstance().apply(game, source)) { + numberOfSpells++; + } + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + + TargetCard target = new TargetCard(Zone.LIBRARY, filter); // zone should be ignored here + target.setNotTarget(true); + while (numberOfSpells > 0 + && cardsToCast.size() > 0 + && controller.chooseUse(outcome, "Cast an instant or sorcery card from among them for free?", source, game) + && controller.choose(outcome, cardsToCast, target, game)) { + Card card = cardsToCast.get(target.getFirstTarget(), game); + if (card != null) { + controller.cast(card.getSpellAbility(), game, true); + numberOfSpells--; + cardsToCast.remove(card); + allCards.remove(card); + } + if (!controller.isInGame()) { + return false; + } + target.clearChosen(); + } + } + + targetOpponent.moveCards(allCards, Zone.LIBRARY, Zone.GRAVEYARD, source, game); + } + return true; + } + return false; + } +} diff --git a/Mage.Sets/src/mage/sets/magicorigins/Willbreaker.java b/Mage.Sets/src/mage/sets/magicorigins/Willbreaker.java new file mode 100644 index 0000000000..c6dcbe34c6 --- /dev/null +++ b/Mage.Sets/src/mage/sets/magicorigins/Willbreaker.java @@ -0,0 +1,120 @@ +/* + * 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.sets.magicorigins; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.condition.common.SourceOnBattlefieldControlUnchangedCondition; +import mage.abilities.decorator.ConditionalContinuousEffect; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.continuous.GainControlTargetEffect; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Rarity; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.GameEvent.EventType; +import mage.game.permanent.Permanent; +import mage.game.stack.StackObject; +import mage.players.Player; +import mage.target.targetpointer.FixedTarget; + +/** + * + * @author LevelX2 + */ +public class Willbreaker extends CardImpl { + + public Willbreaker(UUID ownerId) { + super(ownerId, 84, "Willbreaker", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{3}{U}{U}"); + this.expansionSetCode = "ORI"; + this.subtype.add("Human"); + this.subtype.add("Wizard"); + this.power = new MageInt(2); + this.toughness = new MageInt(3); + + // Whenever a creature an opponent controls becomes the target of a spell or ability you control, gain control of that creature for as long as you control Willbreaker. + ConditionalContinuousEffect effect = new ConditionalContinuousEffect(new GainControlTargetEffect(Duration.Custom), new SourceOnBattlefieldControlUnchangedCondition(), null); + effect.setText("gain control of that creature for as long as you control {this}"); + this.addAbility(new WillbreakerTriggeredAbility(effect)); + } + + public Willbreaker(final Willbreaker card) { + super(card); + } + + @Override + public Willbreaker copy() { + return new Willbreaker(this); + } +} + +class WillbreakerTriggeredAbility extends TriggeredAbilityImpl { + + public WillbreakerTriggeredAbility(Effect effect) { + super(Zone.BATTLEFIELD, effect); + } + + public WillbreakerTriggeredAbility(WillbreakerTriggeredAbility ability) { + super(ability); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == EventType.TARGETED; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (getControllerId().equals(event.getPlayerId())) { + Permanent permanent = game.getPermanent(event.getTargetId()); + if (permanent != null && permanent.getCardType().contains(CardType.CREATURE) + && StackObject.class.isInstance(game.getObject(event.getSourceId()))) { + Player controller = game.getPlayer(getControllerId()); + if (controller != null && controller.hasOpponent(permanent.getControllerId(), game)) { + getEffects().get(0).setTargetPointer(new FixedTarget(event.getTargetId())); + return true; + } + } + } + return false; + } + + @Override + public String getRule() { + return "Whenever a creature an opponent controls becomes the target of a spell or ability you control, " + super.getRule(); + } + + @Override + public WillbreakerTriggeredAbility copy() { + return new WillbreakerTriggeredAbility(this); + } +} diff --git a/Mage.Sets/src/mage/sets/ravnica/SinsOfThePast.java b/Mage.Sets/src/mage/sets/ravnica/SinsOfThePast.java index 01743f1db5..a199e0cfe0 100644 --- a/Mage.Sets/src/mage/sets/ravnica/SinsOfThePast.java +++ b/Mage.Sets/src/mage/sets/ravnica/SinsOfThePast.java @@ -77,21 +77,21 @@ public class SinsOfThePast extends CardImpl { } class SinsOfThePastEffect extends OneShotEffect { - + SinsOfThePastEffect() { super(Outcome.PlayForFree); this.staticText = "Until end of turn, you may cast target instant or sorcery card from your graveyard without paying its mana cost. If that card would be put into your graveyard this turn, exile it instead"; } - + SinsOfThePastEffect(final SinsOfThePastEffect effect) { super(effect); } - + @Override public SinsOfThePastEffect copy() { return new SinsOfThePastEffect(this); } - + @Override public boolean apply(Game game, Ability source) { Card card = game.getCard(this.getTargetPointer().getFirst(game, source)); @@ -139,7 +139,7 @@ class SinsOfThePastCastFromGraveyardEffect extends AsThoughEffectImpl { } class SinsOfThePastReplacementEffect extends ReplacementEffectImpl { - + private final UUID cardId; SinsOfThePastReplacementEffect(UUID cardId) { @@ -157,11 +157,6 @@ class SinsOfThePastReplacementEffect extends ReplacementEffectImpl { return new SinsOfThePastReplacementEffect(this); } - @Override - public boolean apply(Game game, Ability source) { - return true; - } - @Override public boolean replaceEvent(GameEvent event, Ability source, Game game) { Player controller = game.getPlayer(source.getControllerId()); @@ -175,7 +170,6 @@ class SinsOfThePastReplacementEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { - game.informPlayers(event.getType().name()); return event.getType() == GameEvent.EventType.ZONE_CHANGE; } diff --git a/Mage.Sets/src/mage/sets/returntoravnica/GuildFeud.java b/Mage.Sets/src/mage/sets/returntoravnica/GuildFeud.java index 756e5538fd..742386fbd7 100644 --- a/Mage.Sets/src/mage/sets/returntoravnica/GuildFeud.java +++ b/Mage.Sets/src/mage/sets/returntoravnica/GuildFeud.java @@ -28,11 +28,7 @@ package mage.sets.returntoravnica; import java.util.UUID; - -import mage.constants.CardType; -import mage.constants.Outcome; -import mage.constants.Rarity; -import mage.constants.Zone; +import mage.MageObject; import mage.abilities.Ability; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; import mage.abilities.effects.OneShotEffect; @@ -40,7 +36,11 @@ import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.Cards; import mage.cards.CardsImpl; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Rarity; import mage.constants.TargetController; +import mage.constants.Zone; import mage.filter.common.FilterCreatureCard; import mage.game.Game; import mage.game.permanent.Permanent; @@ -48,7 +48,6 @@ import mage.players.Player; import mage.target.TargetCard; import mage.target.common.TargetOpponent; - /** * * @author LevelX2 @@ -79,7 +78,6 @@ public class GuildFeud extends CardImpl { } } - class GuildFeudEffect extends OneShotEffect { public GuildFeudEffect() { @@ -97,18 +95,19 @@ class GuildFeudEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); Permanent opponentCreature = null; Permanent controllerCreature = null; - if (opponent != null && controller != null) { + MageObject sourceObject = source.getSourceObject(game); + if (opponent != null && controller != null && sourceObject != null) { for (int activePlayer = 0; activePlayer < 2; activePlayer++) { - Player player = (activePlayer == 0? opponent : controller); + Player player = (activePlayer == 0 ? opponent : controller); Cards topThreeCards = new CardsImpl(); topThreeCards.addAll(player.getLibrary().getTopCards(game, 3)); - player.revealCards(player.getName() + " top three library cards", topThreeCards, game); + player.revealCards(sourceObject.getIdName() + " - " + player.getName() + " top library cards", topThreeCards, game); Card creatureToBattlefield; if (!topThreeCards.isEmpty()) { if (player.chooseUse(Outcome.PutCreatureInPlay, "Put a creature card among them to the battlefield?", source, game)) { TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCreatureCard( - "creature card to put on the battlefield")); + "creature card to put on the battlefield")); if (player.choose(Outcome.PutCreatureInPlay, topThreeCards, target, game)) { creatureToBattlefield = topThreeCards.get(target.getFirstTarget(), game); if (creatureToBattlefield != null) { diff --git a/Mage.Sets/src/mage/sets/tempest/Grindstone.java b/Mage.Sets/src/mage/sets/tempest/Grindstone.java index f2b73cbca1..785046a82b 100644 --- a/Mage.Sets/src/mage/sets/tempest/Grindstone.java +++ b/Mage.Sets/src/mage/sets/tempest/Grindstone.java @@ -60,8 +60,7 @@ public class Grindstone extends CardImpl { ability.addCost(new TapSourceCost()); ability.addTarget(new TargetPlayer()); this.addAbility(ability); - - + } public Grindstone(final Grindstone card) { @@ -75,21 +74,21 @@ public class Grindstone extends CardImpl { } class GrindstoneEffect extends OneShotEffect { - + public GrindstoneEffect() { super(Outcome.Benefit); this.staticText = "Target player puts the top two cards of his or her library into his or her graveyard. If both cards share a color, repeat this process"; } - + public GrindstoneEffect(final GrindstoneEffect effect) { super(effect); } - + @Override public GrindstoneEffect copy() { return new GrindstoneEffect(this); } - + @Override public boolean apply(Game game, Ability source) { Player targetPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source)); @@ -111,12 +110,9 @@ class GrindstoneEffect extends OneShotEffect { Cards cards = new CardsImpl(); cards.addAll(targetPlayer.getLibrary().getTopCards(game, 2)); if (!cards.isEmpty()) { - Card card1 = targetPlayer.getLibrary().removeFromTop(game); + Card card1 = targetPlayer.getLibrary().removeFromTop(game); if (targetPlayer.getLibrary().size() > 0) { - Card card2 = targetPlayer.getLibrary().removeFromTop(game); - if (card1.getColor(game).hasColor() && card2.getColor(game).hasColor()) { - colorShared = card1.getColor(game).shares(card2.getColor(game)); - } + colorShared = card1.getColor(game).shares(targetPlayer.getLibrary().removeFromTop(game).getColor(game)); } } targetPlayer.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game); diff --git a/Mage/src/mage/abilities/condition/common/CardsInControllerGraveCondition.java b/Mage/src/mage/abilities/condition/common/CardsInControllerGraveCondition.java index 355d7b9e06..d36c9c9687 100644 --- a/Mage/src/mage/abilities/condition/common/CardsInControllerGraveCondition.java +++ b/Mage/src/mage/abilities/condition/common/CardsInControllerGraveCondition.java @@ -4,6 +4,7 @@ import mage.abilities.Ability; import mage.abilities.condition.Condition; import mage.game.Game; import mage.players.Player; +import mage.util.CardUtil; /** * Condition for - Controller has X or more cards in his or her graveyard @@ -23,4 +24,10 @@ public class CardsInControllerGraveCondition implements Condition { Player player = game.getPlayer(source.getControllerId()); return player != null && player.getGraveyard().size() >= value; } + + @Override + public String toString() { + return "there are " + CardUtil.numberToText(value, "one") + " or more cards in your graveyard"; + } + } diff --git a/Mage/src/mage/abilities/effects/common/PutTopCardOfLibraryIntoGraveTargetEffect.java b/Mage/src/mage/abilities/effects/common/PutTopCardOfLibraryIntoGraveTargetEffect.java index b40abbbff0..a59f86122f 100644 --- a/Mage/src/mage/abilities/effects/common/PutTopCardOfLibraryIntoGraveTargetEffect.java +++ b/Mage/src/mage/abilities/effects/common/PutTopCardOfLibraryIntoGraveTargetEffect.java @@ -25,15 +25,12 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. */ - package mage.abilities.effects.common; import mage.abilities.Ability; import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.common.StaticValue; import mage.abilities.effects.OneShotEffect; -import mage.cards.Card; -import mage.cards.Cards; import mage.constants.Outcome; import mage.constants.Zone; import mage.game.Game; @@ -43,7 +40,6 @@ import mage.util.CardUtil; /** * @author LevelX2 */ - public class PutTopCardOfLibraryIntoGraveTargetEffect extends OneShotEffect { private DynamicValue numberCards; @@ -51,6 +47,7 @@ public class PutTopCardOfLibraryIntoGraveTargetEffect extends OneShotEffect { public PutTopCardOfLibraryIntoGraveTargetEffect(int numberCards) { this(new StaticValue(numberCards)); } + public PutTopCardOfLibraryIntoGraveTargetEffect(DynamicValue numberCards) { super(Outcome.Discard); this.numberCards = numberCards;