- Added Advice From the Fae, Puca's Mischief, Illuminated Folio, Furystoke Giant, Burn Trail, and Inescapable Brute.

This commit is contained in:
Jeff 2015-02-24 20:35:17 -06:00
parent 7ac423f1d6
commit 9a1eb51506
6 changed files with 707 additions and 0 deletions

View file

@ -0,0 +1,134 @@
/*
* 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.shadowmoor;
import java.util.List;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
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.FilterControlledCreaturePermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.ControllerIdPredicate;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
/**
*
* @author jeffwadsworth
*/
public class AdviceFromTheFae extends CardImpl {
public AdviceFromTheFae(UUID ownerId) {
super(ownerId, 28, "Advice from the Fae", Rarity.UNCOMMON, new CardType[]{CardType.SORCERY}, "{2/U}{2/U}{2/U}");
this.expansionSetCode = "SHM";
// <i>({2U} can be paid with any two mana or with {U}. This card's converted mana cost is 6.)</i>
// Look at the top five cards of your library. If you control more creatures than each other player, put two of those cards into your hand. Otherwise, put one of them into your hand. Then put the rest on the bottom of your library in any order.
this.getSpellAbility().addEffect(new AdviceFromTheFaeEffect());
}
public AdviceFromTheFae(final AdviceFromTheFae card) {
super(card);
}
@Override
public AdviceFromTheFae copy() {
return new AdviceFromTheFae(this);
}
}
class AdviceFromTheFaeEffect extends OneShotEffect {
public AdviceFromTheFaeEffect() {
super(Outcome.DrawCard);
this.staticText = "Look at the top five cards of your library. If you control more creatures than each other player, put two of those cards into your hand. Otherwise, put one of them into your hand. Then put the rest on the bottom of your library in any order";
}
public AdviceFromTheFaeEffect(final AdviceFromTheFaeEffect effect) {
super(effect);
}
@Override
public AdviceFromTheFaeEffect copy() {
return new AdviceFromTheFaeEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject mageObject = game.getObject(source.getSourceId());
if (controller != null) {
List<Card> cardsFromTopLibrary = controller.getLibrary().getTopCards(game, 5);
Cards cards = new CardsImpl(Zone.HAND);
for (Card card : cardsFromTopLibrary) {
cards.add(card);
}
controller.lookAtCards(mageObject.getLogName(), cards, game);
int max = 0;
for (UUID playerId : controller.getInRange()) {
FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(new ControllerIdPredicate(playerId));
if (playerId != controller.getId()) {
if (max < game.getBattlefield().countAll(filter, playerId, game)) {
max = game.getBattlefield().countAll(filter, playerId, game);
}
}
}
if (game.getBattlefield().countAll(new FilterControlledCreaturePermanent(), controller.getId(), game) > max) {
TargetCard target = new TargetCard(2, Zone.HAND, new FilterCard());
if (controller.choose(Outcome.DrawCard, cards, target, game)) {
controller.moveCardToHandWithInfo(game.getCard(target.getFirstTarget()), source.getId(), game, Zone.LIBRARY);
cards.remove(game.getCard(target.getFirstTarget()));
controller.moveCardToHandWithInfo(game.getCard(target.getTargets().get(1)), source.getId(), game, Zone.LIBRARY);
cards.remove(game.getCard(target.getTargets().get(1)));
}
} else {
TargetCard target = new TargetCard(1, Zone.HAND, new FilterCard());
if (controller.choose(Outcome.DrawCard, cards, target, game)) {
controller.moveCardToHandWithInfo(game.getCard(target.getFirstTarget()), source.getId(), game, Zone.LIBRARY);
cards.remove(game.getCard(target.getFirstTarget()));
}
}
controller.putCardsOnBottomOfLibrary(cards, game, source, true);
return true;
}
return false;
}
}

View file

@ -0,0 +1,64 @@
/*
* 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.shadowmoor;
import java.util.UUID;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.keyword.ConspireAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.target.common.TargetCreatureOrPlayer;
/**
*
* @author jeffwadsworth
*/
public class BurnTrail extends CardImpl {
public BurnTrail(UUID ownerId) {
super(ownerId, 86, "Burn Trail", Rarity.COMMON, new CardType[]{CardType.SORCERY}, "{3}{R}");
this.expansionSetCode = "SHM";
// Burn Trail deals 3 damage to target creature or player.
this.getSpellAbility().addEffect(new DamageTargetEffect(3));
this.getSpellAbility().addTarget(new TargetCreatureOrPlayer());
// Conspire
this.addAbility(new ConspireAbility(this));
}
public BurnTrail(final BurnTrail card) {
super(card);
}
@Override
public BurnTrail copy() {
return new BurnTrail(this);
}
}

View file

@ -0,0 +1,81 @@
/*
* 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.shadowmoor;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.effects.common.continious.GainAbilityAllEffect;
import mage.abilities.keyword.PersistAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.target.common.TargetCreatureOrPlayer;
/**
*
* @author jeffwadsworth
*/
public class FurystokeGiant extends CardImpl {
public FurystokeGiant(UUID ownerId) {
super(ownerId, 93, "Furystoke Giant", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{3}{R}{R}");
this.expansionSetCode = "SHM";
this.subtype.add("Giant");
this.subtype.add("Warrior");
this.power = new MageInt(3);
this.toughness = new MageInt(3);
// When Furystoke Giant enters the battlefield, other creatures you control gain "{tap}: This creature deals 2 damage to target creature or player" until end of turn.
SimpleActivatedAbility FurystokeGiantAbility = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(2), new TapSourceCost());
FurystokeGiantAbility.addTarget(new TargetCreatureOrPlayer());
Effect effect = new GainAbilityAllEffect(FurystokeGiantAbility, Duration.EndOfTurn, new FilterControlledCreaturePermanent("other creatures"), true);
effect.setText("other creatures you control gain \"{T}: This creature deals 2 damage to target creature or player.\" until end of turn.");
this.addAbility(new EntersBattlefieldTriggeredAbility(effect));
// Persist
this.addAbility(new PersistAbility());
}
public FurystokeGiant(final FurystokeGiant card) {
super(card);
}
@Override
public FurystokeGiant copy() {
return new FurystokeGiant(this);
}
}

View file

@ -0,0 +1,188 @@
/*
* 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.shadowmoor;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.RevealTargetFromHandCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.ColorPredicate;
import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetCardInHand;
/**
*
* @author jeffwadsworth
*/
public class IlluminatedFolio extends CardImpl {
public IlluminatedFolio(UUID ownerId) {
super(ownerId, 254, "Illuminated Folio", Rarity.UNCOMMON, new CardType[]{CardType.ARTIFACT}, "{5}");
this.expansionSetCode = "SHM";
// {1}, {tap}, Reveal two cards from your hand that share a color: Draw a card.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DrawCardSourceControllerEffect(1), new ManaCostsImpl("{1}"));
ability.addCost(new TapSourceCost());
ability.addCost(new RevealTwoCardsSharedColorFromHandCost());
this.addAbility(ability);
}
public IlluminatedFolio(final IlluminatedFolio card) {
super(card);
}
@Override
public IlluminatedFolio copy() {
return new IlluminatedFolio(this);
}
}
class RevealTwoCardsSharedColorFromHandCost extends RevealTargetFromHandCost {
public RevealTwoCardsSharedColorFromHandCost() {
super(new TargetTwoCardsWithTheSameColorInHand());
}
public RevealTwoCardsSharedColorFromHandCost(RevealTwoCardsSharedColorFromHandCost cost) {
super(cost);
}
@Override
public RevealTwoCardsSharedColorFromHandCost copy() {
return new RevealTwoCardsSharedColorFromHandCost(this);
}
}
class TargetTwoCardsWithTheSameColorInHand extends TargetCardInHand {
public TargetTwoCardsWithTheSameColorInHand() {
super(2, 2, new FilterCard("two cards from your hand that share a color"));
}
public TargetTwoCardsWithTheSameColorInHand(final TargetTwoCardsWithTheSameColorInHand target) {
super(target);
}
@Override
public Set<UUID> possibleTargets(UUID sourceControllerId, Game game) {
Set<UUID> newPossibleTargets = new HashSet<>();
Set<UUID> possibleTargets = new HashSet<>();
Player player = game.getPlayer(sourceControllerId);
for (Card card : player.getHand().getCards(filter, game)) {
possibleTargets.add(card.getId());
}
Cards cardsToCheck = new CardsImpl();
cardsToCheck.addAll(possibleTargets);
if (targets.size() == 1) {
// first target is laready choosen, now only targets with the same name are selectable
for (Map.Entry<UUID, Integer> entry : targets.entrySet()) {
Card chosenCard = cardsToCheck.get(entry.getKey(), game);
if (chosenCard != null) {
for (UUID cardToCheck : cardsToCheck) {
if (!cardToCheck.equals(chosenCard.getId()) && chosenCard.getColor().equals(game.getCard(cardToCheck).getColor())) {
newPossibleTargets.add(cardToCheck);
}
}
}
}
} else {
for (UUID cardToCheck : cardsToCheck) {
FilterCard colorFilter = new FilterCard();
colorFilter.add(new ColorPredicate(game.getCard(cardToCheck).getColor()));
if (cardsToCheck.count(colorFilter, game) > 1) {
newPossibleTargets.add(cardToCheck);
}
}
}
return newPossibleTargets;
}
@Override
public boolean canChoose(UUID sourceControllerId, Game game) {
Cards cardsToCheck = new CardsImpl();
Player player = game.getPlayer(sourceControllerId);
for (Card card : player.getHand().getCards(filter, game)) {
cardsToCheck.add(card.getId());
}
int possibleCards = 0;
for (UUID cardToCheck : cardsToCheck) {
FilterCard colorFilter = new FilterCard();
colorFilter.add(new ColorPredicate(game.getCard(cardToCheck).getColor()));
if (cardsToCheck.count(colorFilter, game) > 1) {
++possibleCards;
}
}
return possibleCards > 0;
}
@Override
public boolean canTarget(UUID id, Game game) {
if (super.canTarget(id, game)) {
Card card = game.getCard(id);
if (card != null) {
if (targets.size() == 1) {
Card card2 = game.getCard(targets.entrySet().iterator().next().getKey());
if (card2 != null && card2.getColor().equals(card.getColor())) {
return true;
}
} else {
FilterCard colorFilter = new FilterCard();
colorFilter.add(new ColorPredicate(card.getColor()));
Player player = game.getPlayer(card.getOwnerId());
if (player.getHand().getCards(colorFilter, game).size() > 1) {
return true;
}
}
}
}
return false;
}
@Override
public TargetTwoCardsWithTheSameColorInHand copy() {
return new TargetTwoCardsWithTheSameColorInHand(this);
}
}

View file

@ -0,0 +1,70 @@
/*
* 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.shadowmoor;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.combat.MustBeBlockedByAtLeastOneSourceEffect;
import mage.abilities.keyword.WitherAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.constants.Zone;
/**
*
* @author jeffwadsworth
*/
public class InescapableBrute extends CardImpl {
public InescapableBrute(UUID ownerId) {
super(ownerId, 95, "Inescapable Brute", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{5}{R}");
this.expansionSetCode = "SHM";
this.subtype.add("Giant");
this.subtype.add("Warrior");
this.power = new MageInt(3);
this.toughness = new MageInt(3);
// Wither
this.addAbility(WitherAbility.getInstance());
// Inescapable Brute must be blocked if able.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new MustBeBlockedByAtLeastOneSourceEffect()));
}
public InescapableBrute(final InescapableBrute card) {
super(card);
}
@Override
public InescapableBrute copy() {
return new InescapableBrute(this);
}
}

View file

@ -0,0 +1,170 @@
/*
* 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.shadowmoor;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.effects.common.continious.ExchangeControlTargetEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.TargetController;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.TargetPermanent;
import mage.target.common.TargetControlledPermanent;
/**
*
* @author jeffwadsworth
*/
public class PucasMischief extends CardImpl {
private static final String rule = "you may exchange control of target nonland permanent you control and target nonland permanent an opponent controls with an equal or lesser converted mana cost";
public PucasMischief(UUID ownerId) {
super(ownerId, 47, "Puca's Mischief", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{3}{U}");
this.expansionSetCode = "SHM";
// At the beginning of your upkeep, you may exchange control of target nonland permanent you control and target nonland permanent an opponent controls with an equal or lesser converted mana cost.
Ability ability = new BeginningOfUpkeepTriggeredAbility(new ExchangeControlTargetEffect(Duration.EndOfGame, rule, false, true), TargetController.YOU, true);
ability.addTarget(new TargetControlledPermanentWithCMCGreaterOrLessThanOpponentPermanent());
ability.addTarget(new PucasMischiefSecondTarget());
this.addAbility(ability);
}
public PucasMischief(final PucasMischief card) {
super(card);
}
@Override
public PucasMischief copy() {
return new PucasMischief(this);
}
}
class TargetControlledPermanentWithCMCGreaterOrLessThanOpponentPermanent extends TargetControlledPermanent {
public TargetControlledPermanentWithCMCGreaterOrLessThanOpponentPermanent() {
super();
filter.add(Predicates.not(new CardTypePredicate(CardType.LAND)));
setTargetName("nonland permanent you control");
}
public TargetControlledPermanentWithCMCGreaterOrLessThanOpponentPermanent(final TargetControlledPermanentWithCMCGreaterOrLessThanOpponentPermanent target) {
super(target);
}
@Override
public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) {
return super.canTarget(controllerId, id, source, game);
}
@Override
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
Set<UUID> possibleTargets = new HashSet<>();
MageObject targetSource = game.getObject(sourceId);
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
possibleTargets.add(permanent.getId());
}
}
return possibleTargets;
}
@Override
public TargetControlledPermanentWithCMCGreaterOrLessThanOpponentPermanent copy() {
return new TargetControlledPermanentWithCMCGreaterOrLessThanOpponentPermanent(this);
}
}
class PucasMischiefSecondTarget extends TargetPermanent {
private Permanent firstTarget = null;
public PucasMischiefSecondTarget() {
super();
filter.add(new ControllerPredicate(TargetController.OPPONENT));
filter.add(Predicates.not(new CardTypePredicate(CardType.LAND)));
setTargetName("permanent an opponent controls with an equal or lesser converted mana cost");
}
public PucasMischiefSecondTarget(final PucasMischiefSecondTarget target) {
super(target);
this.firstTarget = target.firstTarget;
}
@Override
public boolean canTarget(UUID id, Ability source, Game game) {
if (super.canTarget(id, source, game)) {
Permanent target1 = game.getPermanent(source.getFirstTarget());
Permanent opponentPermanent = game.getPermanent(id);
if (target1 != null && opponentPermanent != null) {
return target1.getManaCost().convertedManaCost() >= opponentPermanent.getManaCost().convertedManaCost();
}
}
return false;
}
@Override
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
Set<UUID> possibleTargets = new HashSet<>();
if (firstTarget != null) {
MageObject targetSource = game.getObject(sourceId);
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
if (firstTarget.getManaCost().convertedManaCost() >= permanent.getManaCost().convertedManaCost()) {
possibleTargets.add(permanent.getId());
}
}
}
}
return possibleTargets;
}
@Override
public boolean chooseTarget(Outcome outcome, UUID playerId, Ability source, Game game) {
firstTarget = game.getPermanent(source.getFirstTarget());
return super.chooseTarget(Outcome.GainControl, playerId, source, game);
}
@Override
public PucasMischiefSecondTarget copy() {
return new PucasMischiefSecondTarget(this);
}
}