Add Time Spiral, Candelabra Of Tawnos, Turnabout, High Tide, Intuition and Wipe Away,

This commit is contained in:
Plopman 2012-11-28 23:19:04 +01:00
parent 62ff2c0fa3
commit 3b176eedf2
8 changed files with 789 additions and 1 deletions

View file

@ -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<CandelabraOfTawnos> {
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<CandelabraOfTawnosAbility> 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";
}
}

View file

@ -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<HighTide> {
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<HighTideTriggeredAbility> {
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<AddBlueToTargetEffect> {
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;
}
}

View file

@ -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<Intuition> {
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<IntuitionEffect> {
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<UUID>)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<UUID> getTargets() {
return target.getTargets();
}
}

View file

@ -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<WipeAway> {
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);
}
}

View file

@ -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<TimeSpiral> {
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<TimeSpiralEffect> {
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);
}
}

View file

@ -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<Turnabout> {
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<TurnaboutEffect> {
private static final HashSet<String> choice = new HashSet<String>();
static{
choice.add(CardType.ARTIFACT.toString());
choice.add(CardType.CREATURE.toString());
choice.add(CardType.LAND.toString());
}
private static final HashSet<String> choice2 = new HashSet<String>();
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;
}
}