diff --git a/Mage.Sets/src/mage/sets/antiquities/CandelabraOfTawnos.java b/Mage.Sets/src/mage/sets/antiquities/CandelabraOfTawnos.java new file mode 100644 index 00000000000..4b9e028c7ad --- /dev/null +++ b/Mage.Sets/src/mage/sets/antiquities/CandelabraOfTawnos.java @@ -0,0 +1,122 @@ +/* + * 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.antiquities; + +import java.util.UUID; +import mage.Constants; +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.abilities.Ability; +import mage.abilities.ActivatedAbilityImpl; +import mage.abilities.SpellAbility; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.AdjustingSourceCosts; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.costs.mana.VariableManaCost; +import mage.abilities.effects.common.TapTargetEffect; +import mage.abilities.effects.common.UntapTargetEffect; +import mage.cards.CardImpl; +import mage.filter.common.FilterLandPermanent; +import mage.game.Game; +import mage.target.common.TargetLandPermanent; +import mage.util.CardUtil; + +/** + * + * @author Plopman + */ +public class CandelabraOfTawnos extends CardImpl { + + public CandelabraOfTawnos(UUID ownerId) { + super(ownerId, 8, "Candelabra of Tawnos", Rarity.RARE, new CardType[]{CardType.ARTIFACT}, "{1}"); + this.expansionSetCode = "ATQ"; + + // {X}, {tap}: Untap X target lands. + this.addAbility(new CandelabraOfTawnosAbility()); + } + + public CandelabraOfTawnos(final CandelabraOfTawnos card) { + super(card); + } + + @Override + public CandelabraOfTawnos copy() { + return new CandelabraOfTawnos(this); + } +} + + + + +class CandelabraOfTawnosAbility extends ActivatedAbilityImpl implements AdjustingSourceCosts{ + public CandelabraOfTawnosAbility(){ + super(Constants.Zone.BATTLEFIELD, new UntapTargetEffect(), new TapSourceCost()); + addTarget(new TargetLandPermanent(0, Integer.MAX_VALUE, new FilterLandPermanent(), false)); + } + + public CandelabraOfTawnosAbility(CandelabraOfTawnosAbility ability) { + super(ability); + } + + @Override + public CandelabraOfTawnosAbility copy() { + return new CandelabraOfTawnosAbility(this); + } + + @Override + public void adjustCosts(Ability ability, Game game) { + if(ability instanceof CandelabraOfTawnosAbility){ + int numTargets = ability.getTargets().get(0).getTargets().size(); + if (numTargets > 0) { + ability.getManaCostsToPay().add(new GenericManaCost(numTargets)); + } + } + } + + @Override + public String getRule() { + return "{X}, {T}: Untap X target lands"; + } + + @Override + public String getRule(boolean all) { + return "{X}, {T}: Untap X target lands"; + } + + @Override + public String getRule(String source) { + return "{X}, {T}: Untap X target lands"; + } + + + + + + +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/fallenempires/HighTide.java b/Mage.Sets/src/mage/sets/fallenempires/HighTide.java new file mode 100644 index 00000000000..eb6f2df57e0 --- /dev/null +++ b/Mage.Sets/src/mage/sets/fallenempires/HighTide.java @@ -0,0 +1,144 @@ +/* + * 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.fallenempires; + +import java.util.UUID; +import mage.Constants; +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.Mana; +import mage.abilities.Ability; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect; +import mage.abilities.effects.common.ManaEffect; +import mage.abilities.mana.DelayedTriggeredManaAbility; +import mage.cards.CardImpl; +import mage.filter.common.FilterLandPermanent; +import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.targetpointer.FixedTarget; + +/** + * + * @author Plopman + */ +public class HighTide extends CardImpl { + + public HighTide(UUID ownerId) { + super(ownerId, 35, "High Tide", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{U}"); + this.expansionSetCode = "FEM"; + + this.color.setBlue(true); + + // Until end of turn, whenever a player taps an Island for mana, that player adds {U} to his or her mana pool. + this.getSpellAbility().addEffect(new CreateDelayedTriggeredAbilityEffect(new HighTideTriggeredAbility())); + + } + + public HighTide(final HighTide card) { + super(card); + } + + @Override + public HighTide copy() { + return new HighTide(this); + } +} + +class HighTideTriggeredAbility extends DelayedTriggeredManaAbility { + + private final static FilterLandPermanent filter = new FilterLandPermanent("Island"); + static { + filter.add(new SubtypePredicate("Island")); + } + + public HighTideTriggeredAbility() { + super(new AddBlueToTargetEffect(), Constants.Duration.EndOfTurn, false); + this.usesStack = false; + } + + public HighTideTriggeredAbility(HighTideTriggeredAbility ability) { + super(ability); + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + Permanent land = game.getPermanent(event.getTargetId()); + if (event.getType() == GameEvent.EventType.TAPPED_FOR_MANA && land != null && filter.match(land, game)) { + for (Effect effect : this.getEffects()) { + effect.setTargetPointer(new FixedTarget(land.getControllerId())); + } + return true; + } + return false; + } + + @Override + public HighTideTriggeredAbility copy() { + return new HighTideTriggeredAbility(this); + } + + @Override + public String getRule() { + return "Until end of turn, whenever a player taps an Island for mana, that player adds {U} to his or her mana pool"; + } +} + +class AddBlueToTargetEffect extends ManaEffect { + + + public AddBlueToTargetEffect() { + super(); + staticText = "that player adds {U} to his or her mana pool"; + } + + + public AddBlueToTargetEffect(final AddBlueToTargetEffect effect) { + super(effect); + } + + @Override + public AddBlueToTargetEffect copy() { + return new AddBlueToTargetEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(this.getTargetPointer().getFirst(game, source)); + if(player != null) + { + player.getManaPool().addMana(Mana.BlueMana(1), game, source); + + } + return true; + } + +} diff --git a/Mage.Sets/src/mage/sets/tempest/Intuition.java b/Mage.Sets/src/mage/sets/tempest/Intuition.java new file mode 100644 index 00000000000..6998cde3fb2 --- /dev/null +++ b/Mage.Sets/src/mage/sets/tempest/Intuition.java @@ -0,0 +1,144 @@ +/* + * 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.tempest; + +import java.util.List; +import java.util.UUID; +import mage.Constants; +import mage.Constants.CardType; +import mage.Constants.Outcome; +import mage.Constants.Rarity; +import mage.abilities.Ability; +import mage.abilities.effects.SearchEffect; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.Cards; +import mage.cards.CardsImpl; +import mage.filter.FilterCard; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.TargetCard; +import mage.target.common.TargetCardInLibrary; +import mage.target.common.TargetOpponent; + +/** + * + * @author Plopman + */ +public class Intuition extends CardImpl { + + public Intuition(UUID ownerId) { + super(ownerId, 23, "Intuition", Rarity.RARE, new CardType[]{CardType.INSTANT}, "{2}{U}"); + this.expansionSetCode = "TMP"; + + this.color.setBlue(true); + + // Search your library for three cards and reveal them. Target opponent chooses one. Put that card into your hand and the rest into your graveyard. Then shuffle your library. + this.getSpellAbility().addEffect(new IntuitionEffect()); + this.getSpellAbility().addTarget(new TargetOpponent()); + } + + public Intuition(final Intuition card) { + super(card); + } + + @Override + public Intuition copy() { + return new Intuition(this); + } +} + +class IntuitionEffect extends SearchEffect { + + + + public IntuitionEffect() { + super(new TargetCardInLibrary(3, new FilterCard()), Outcome.Benefit); + staticText = "Search your library for three cards and reveal them. Target opponent chooses one. Put that card into your hand and the rest into your graveyard. Then shuffle your library"; + } + + + public IntuitionEffect(final IntuitionEffect effect) { + super(effect); + } + + @Override + public IntuitionEffect copy() { + return new IntuitionEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + Player opponent = game.getPlayer(source.getFirstTarget()); + if (player == null || opponent == null) + return false; + + if (player.getLibrary().size() >= 3 && player.searchLibrary(target, game)) { + + target.setRequired(true); + if (target.getTargets().size() == 3) { + Cards cards = new CardsImpl(); + for (UUID cardId: (List)target.getTargets()) { + Card card = player.getLibrary().getCard(cardId, game); + if (card != null) { + cards.add(card); + } + } + player.revealCards("Reveal", cards, game); + + TargetCard targetCard = new TargetCard(Constants.Zone.PICK, new FilterCard()); + targetCard.setRequired(true); + + while(!opponent.choose(Outcome.Neutral, cards, targetCard, game)); + Card card = cards.get(targetCard.getFirstTarget(), game); + if (card != null) { + cards.remove(card); + card.moveToZone(Constants.Zone.HAND, source.getId(), game, false); + } + + for(UUID uuid : cards){ + card = cards.get(uuid, game); + card.moveToZone(Constants.Zone.GRAVEYARD, source.getId(), game, false); + } + + } + player.shuffleLibrary(game); + return true; + } + + player.shuffleLibrary(game); + return false; + } + + public List getTargets() { + return target.getTargets(); + } + +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/timespiral/WipeAway.java b/Mage.Sets/src/mage/sets/timespiral/WipeAway.java new file mode 100644 index 00000000000..75382fafde5 --- /dev/null +++ b/Mage.Sets/src/mage/sets/timespiral/WipeAway.java @@ -0,0 +1,65 @@ +/* + * 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.timespiral; + +import java.util.UUID; +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.abilities.effects.common.ReturnToHandTargetEffect; +import mage.abilities.keyword.SplitSecondAbility; +import mage.cards.CardImpl; +import mage.target.TargetPermanent; + +/** + * + * @author Plopman + */ +public class WipeAway extends CardImpl { + + public WipeAway(UUID ownerId) { + super(ownerId, 94, "Wipe Away", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{1}{U}{U}"); + this.expansionSetCode = "TSP"; + + this.color.setBlue(true); + + // Split second + this.addAbility(SplitSecondAbility.getInstance()); + // Return target permanent to its owner's hand. + this.getSpellAbility().addTarget(new TargetPermanent()); + this.getSpellAbility().addEffect(new ReturnToHandTargetEffect()); + } + + public WipeAway(final WipeAway card) { + super(card); + } + + @Override + public WipeAway copy() { + return new WipeAway(this); + } +} diff --git a/Mage.Sets/src/mage/sets/urzassaga/TimeSpiral.java b/Mage.Sets/src/mage/sets/urzassaga/TimeSpiral.java new file mode 100644 index 00000000000..4e4e376bd50 --- /dev/null +++ b/Mage.Sets/src/mage/sets/urzassaga/TimeSpiral.java @@ -0,0 +1,102 @@ +/* + * 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.urzassaga; + +import java.util.UUID; +import mage.Constants.CardType; +import mage.Constants.Outcome; +import mage.Constants.Rarity; +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.ExileSpellEffect; +import mage.abilities.effects.common.UntapLandsEffect; +import mage.cards.CardImpl; +import mage.game.Game; +import mage.players.Player; + +/** + * + * @author Plopman + */ +public class TimeSpiral extends CardImpl { + + public TimeSpiral(UUID ownerId) { + super(ownerId, 103, "Time Spiral", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{4}{U}{U}"); + this.expansionSetCode = "USG"; + + this.color.setBlue(true); + + // Exile Time Spiral. Each player shuffles his or her graveyard and hand into his or her library, then draws seven cards. You untap up to six lands. + this.getSpellAbility().addEffect(ExileSpellEffect.getInstance()); + this.getSpellAbility().addEffect(new TimeSpiralEffect()); + this.getSpellAbility().addEffect(new UntapLandsEffect(6)); + } + public TimeSpiral(final TimeSpiral card) { + super(card); + } + + @Override + public TimeSpiral copy() { + return new TimeSpiral(this); + } +} + +class TimeSpiralEffect extends OneShotEffect { + + public TimeSpiralEffect() { + super(Outcome.Neutral); + staticText = "Each player shuffles his or her hand and graveyard into his or her library, then draws seven cards"; + } + + public TimeSpiralEffect(final TimeSpiralEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + Player sourcePlayer = game.getPlayer(source.getControllerId()); + for (UUID playerId: sourcePlayer.getInRange()) { + Player player = game.getPlayer(playerId); + if (player != null) { + player.getLibrary().addAll(player.getHand().getCards(game), game); + player.getLibrary().addAll(player.getGraveyard().getCards(game), game); + player.shuffleLibrary(game); + player.getHand().clear(); + player.getGraveyard().clear(); + player.drawCards(7, game); + } + } + return true; + } + + @Override + public TimeSpiralEffect copy() { + return new TimeSpiralEffect(this); + } + +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/urzassaga/Turnabout.java b/Mage.Sets/src/mage/sets/urzassaga/Turnabout.java new file mode 100644 index 00000000000..baf32ac38f3 --- /dev/null +++ b/Mage.Sets/src/mage/sets/urzassaga/Turnabout.java @@ -0,0 +1,157 @@ +/* + * 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.urzassaga; + +import java.util.HashSet; +import java.util.UUID; +import mage.Constants; +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.cards.CardImpl; +import mage.choices.Choice; +import mage.choices.ChoiceImpl; +import mage.filter.FilterPermanent; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.mageobject.CardTypePredicate; +import mage.filter.predicate.permanent.TappedPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.TargetPlayer; + +/** + * + * @author Plopman + */ +public class Turnabout extends CardImpl { + + + public Turnabout(UUID ownerId) { + super(ownerId, 105, "Turnabout", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{2}{U}{U}"); + this.expansionSetCode = "USG"; + + this.color.setBlue(true); + + // Choose artifact, creature, or land. Tap all untapped permanents of the chosen type target player controls, or untap all tapped permanents of that type that player controls. + this.getSpellAbility().addTarget(new TargetPlayer()); + this.getSpellAbility().addEffect(new TurnaboutEffect()); + + } + + public Turnabout(final Turnabout card) { + super(card); + } + + @Override + public Turnabout copy() { + return new Turnabout(this); + } +} + +class TurnaboutEffect extends OneShotEffect { + + private static final HashSet choice = new HashSet(); + static{ + choice.add(CardType.ARTIFACT.toString()); + choice.add(CardType.CREATURE.toString()); + choice.add(CardType.LAND.toString()); + } + + private static final HashSet choice2 = new HashSet(); + static{ + choice2.add("Untap"); + choice2.add("Tap"); + } + + public TurnaboutEffect() { + super(Constants.Outcome.Benefit); + staticText = "Choose artifact, creature, or land. Tap all untapped permanents of the chosen type target player controls, or untap all tapped permanents of that type that player controls"; + } + + public TurnaboutEffect(final TurnaboutEffect effect) { + super(effect); + } + + @Override + public TurnaboutEffect copy() { + return new TurnaboutEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + UUID target = source.getFirstTarget(); + if(player != null && target != null){ + Choice choiceImpl = new ChoiceImpl(); + choiceImpl.setChoices(choice); + while(!player.choose(outcome.Neutral, choiceImpl, game)); + CardType type; + String choosenType = choiceImpl.getChoice(); + + if(choosenType.equals(CardType.ARTIFACT.toString())){ + type = CardType.ARTIFACT; + }else if(choosenType.equals(CardType.LAND.toString())){ + type = CardType.LAND; + }else{ + type = CardType.CREATURE; + } + + choiceImpl = new ChoiceImpl(); + choiceImpl.setChoices(choice2); + while(!player.choose(outcome.Neutral, choiceImpl, game)); + + FilterPermanent filter = new FilterPermanent(); + filter.add(new CardTypePredicate(type)); + + + if(choiceImpl.getChoice().equals("Untap")){ + filter.add(new TappedPredicate()); + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + if(permanent.getControllerId().equals(target)){ + permanent.untap(game); + } + } + } + else{ + filter.add(Predicates.not(new TappedPredicate())); + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + if(permanent.getControllerId().equals(target)){ + permanent.tap(game); + } + } + } + + + } + + + return true; + } +} \ No newline at end of file diff --git a/Mage/src/mage/abilities/mana/DelayedTriggeredManaAbility.java b/Mage/src/mage/abilities/mana/DelayedTriggeredManaAbility.java new file mode 100644 index 00000000000..a2ee3278f5d --- /dev/null +++ b/Mage/src/mage/abilities/mana/DelayedTriggeredManaAbility.java @@ -0,0 +1,53 @@ +/* + * Copyright 2011 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.abilities.mana; + + +import mage.Constants; +import mage.Constants.Zone; +import mage.abilities.DelayedTriggeredAbility; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.ManaEffect; + +/** + * @author Plopman + */ +public abstract class DelayedTriggeredManaAbility> extends DelayedTriggeredAbility { + + public DelayedTriggeredManaAbility(Zone zone, ManaEffect effect) { + super(effect); + } + + public DelayedTriggeredManaAbility(final DelayedTriggeredManaAbility ability) { + super(ability); + } + + public DelayedTriggeredManaAbility(Effect effect, Constants.Duration duration, Boolean triggerOnlyOnce) { + super(effect, duration, triggerOnlyOnce); + } +} diff --git a/Mage/src/mage/game/GameImpl.java b/Mage/src/mage/game/GameImpl.java index f18c422cf9a..f474cc04914 100644 --- a/Mage/src/mage/game/GameImpl.java +++ b/Mage/src/mage/game/GameImpl.java @@ -84,6 +84,7 @@ import org.apache.log4j.Logger; import java.io.IOException; import java.io.Serializable; import java.util.*; +import mage.abilities.mana.DelayedTriggeredManaAbility; public abstract class GameImpl> implements Game, Serializable { @@ -884,7 +885,7 @@ public abstract class GameImpl> implements Game, Serializa @Override public void addTriggeredAbility(TriggeredAbility ability) { - if (ability instanceof TriggeredManaAbility) { + if (ability instanceof TriggeredManaAbility || ability instanceof DelayedTriggeredManaAbility) { // 20110715 - 605.4 ability.resolve(this); }