diff --git a/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java b/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java index 24cf4203a6..8f5f5d36f4 100644 --- a/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java +++ b/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java @@ -576,6 +576,20 @@ public class ComputerPlayer> extends PlayerImpl i return target.isChosen(); } + if (target instanceof TargetCardInASingleGraveyard) { + List cards = new ArrayList(); + for (Player player: game.getPlayers().values()) { + cards.addAll(player.getGraveyard().getCards(game)); + } + while(!target.isChosen() && !cards.isEmpty()) { + Card pick = pickTarget(cards, outcome, target, source, game); + if (pick != null) { + target.addTarget(pick.getId(), source, game); + } + } + return target.isChosen(); + } + throw new IllegalStateException("Target wasn't handled. class:" + target.getClass().toString()); } diff --git a/Mage.Sets/src/mage/sets/championsofkamigawa/RagDealer.java b/Mage.Sets/src/mage/sets/championsofkamigawa/RagDealer.java index 59a34e7a9d..6a59a22492 100644 --- a/Mage.Sets/src/mage/sets/championsofkamigawa/RagDealer.java +++ b/Mage.Sets/src/mage/sets/championsofkamigawa/RagDealer.java @@ -45,6 +45,7 @@ import mage.cards.CardImpl; import mage.filter.FilterCard; import mage.game.Game; import mage.target.TargetCard; +import mage.target.common.TargetCardInASingleGraveyard; /** * @@ -65,7 +66,7 @@ public class RagDealer extends CardImpl { // {2}{B}, {T}: Exile up to three target cards from a single graveyard. Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new RagDealerExileEffect(), new ManaCostsImpl("{2}{B}")); ability.addCost(new TapSourceCost()); - ability.addTarget(new RagDealerTargetCardsInGraveyard(0, 3, new FilterCard())); + ability.addTarget(new TargetCardInASingleGraveyard(0, 3, new FilterCard("up to three target cards from a single graveyard"))); this.addAbility(ability); } @@ -80,38 +81,6 @@ public class RagDealer extends CardImpl { } -class RagDealerTargetCardsInGraveyard extends TargetCard { - - public RagDealerTargetCardsInGraveyard(int minNumTargets, int maxNumTargets, FilterCard filter) { - super(minNumTargets, maxNumTargets, Zone.GRAVEYARD, filter); - this.targetName = "up to three target cards from a single graveyard"; - } - - public RagDealerTargetCardsInGraveyard(final RagDealerTargetCardsInGraveyard target) { - super(target); - } - - @Override - public boolean canTarget(UUID id, Ability source, Game game) { - UUID firstTarget = this.getFirstTarget(); - if (firstTarget != null) { - Card card = game.getCard(firstTarget); - Card targetCard = game.getCard(id); - if (card == null || targetCard == null - || !card.getOwnerId().equals(targetCard.getOwnerId())) { - return false; - } - } - return super.canTarget(id, source, game); - } - - - @Override - public RagDealerTargetCardsInGraveyard copy() { - return new RagDealerTargetCardsInGraveyard(this); - } -} - class RagDealerExileEffect extends OneShotEffect { public RagDealerExileEffect() { diff --git a/Mage.Sets/src/mage/sets/gatecrash/SereneRemembrance.java b/Mage.Sets/src/mage/sets/gatecrash/SereneRemembrance.java index 3f20b2231f..4cea75820c 100644 --- a/Mage.Sets/src/mage/sets/gatecrash/SereneRemembrance.java +++ b/Mage.Sets/src/mage/sets/gatecrash/SereneRemembrance.java @@ -41,6 +41,7 @@ import mage.filter.FilterCard; import mage.game.Game; import mage.players.Player; import mage.target.TargetCard; +import mage.target.common.TargetCardInASingleGraveyard; /** * @@ -56,7 +57,7 @@ public class SereneRemembrance extends CardImpl { // Shuffle Serene Remembrance and up to three target cards from a single graveyard into their owners' libraries. this.getSpellAbility().addEffect(new SereneRemembranceEffect()); - this.getSpellAbility().addTarget(new SereneRemembranceTargetCardsInGraveyard(0,3,new FilterCard())); + this.getSpellAbility().addTarget(new TargetCardInASingleGraveyard(0,3,new FilterCard("up to three target cards from a single graveyard"))); } @@ -114,35 +115,3 @@ class SereneRemembranceEffect extends OneShotEffect { return result; } } - -class SereneRemembranceTargetCardsInGraveyard extends TargetCard { - - public SereneRemembranceTargetCardsInGraveyard(int minNumTargets, int maxNumTargets, FilterCard filter) { - super(minNumTargets, maxNumTargets, Zone.GRAVEYARD, filter); - this.targetName = "up to three target cards from a single graveyard"; - } - - public SereneRemembranceTargetCardsInGraveyard(final SereneRemembranceTargetCardsInGraveyard target) { - super(target); - } - - @Override - public boolean canTarget(UUID id, Ability source, Game game) { - UUID firstTarget = this.getFirstTarget(); - if (firstTarget != null) { - Card card = game.getCard(firstTarget); - Card targetCard = game.getCard(id); - if (card == null || targetCard == null - || !card.getOwnerId().equals(targetCard.getOwnerId())) { - return false; - } - } - return super.canTarget(id, source, game); - } - - - @Override - public SereneRemembranceTargetCardsInGraveyard copy() { - return new SereneRemembranceTargetCardsInGraveyard(this); - } -} diff --git a/Mage.Sets/src/mage/sets/riseoftheeldrazi/SarkhanTheMad.java b/Mage.Sets/src/mage/sets/riseoftheeldrazi/SarkhanTheMad.java index 7d8380bb7c..aae7a71a5e 100644 --- a/Mage.Sets/src/mage/sets/riseoftheeldrazi/SarkhanTheMad.java +++ b/Mage.Sets/src/mage/sets/riseoftheeldrazi/SarkhanTheMad.java @@ -71,10 +71,12 @@ public class SarkhanTheMad extends CardImpl { this.color.setRed(true); this.addAbility(new LoyaltyAbility(new SarkhanTheMadRevealAndDrawEffect(), 0)); + Target targetCreature = new TargetCreaturePermanent(); Ability sacAbility = new LoyaltyAbility(new SarkhanTheMadSacEffect(), -2); sacAbility.addTarget(targetCreature); this.addAbility(sacAbility); + Ability damageAbility = new LoyaltyAbility(new SarkhanTheMadDragonDamageEffect(), -4); damageAbility.addTarget(new TargetPlayer()); this.addAbility(damageAbility); diff --git a/Mage/src/mage/target/common/TargetCardInASingleGraveyard.java b/Mage/src/mage/target/common/TargetCardInASingleGraveyard.java new file mode 100644 index 0000000000..8bdd96ad01 --- /dev/null +++ b/Mage/src/mage/target/common/TargetCardInASingleGraveyard.java @@ -0,0 +1,76 @@ +/* +* 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.target.common; + +import java.util.UUID; +import mage.abilities.Ability; +import mage.cards.Card; +import mage.constants.Zone; +import mage.filter.FilterCard; +import mage.game.Game; +import mage.target.TargetCard; + + +/** + * + * @author LevelX2 + */ + + +public class TargetCardInASingleGraveyard extends TargetCard { + + public TargetCardInASingleGraveyard(int minNumTargets, int maxNumTargets, FilterCard filter) { + super(minNumTargets, maxNumTargets, Zone.GRAVEYARD, filter); + this.targetName = filter.getMessage(); + } + + public TargetCardInASingleGraveyard(final TargetCardInASingleGraveyard target) { + super(target); + } + + @Override + public boolean canTarget(UUID id, Ability source, Game game) { + UUID firstTarget = this.getFirstTarget(); + if (firstTarget != null) { + Card card = game.getCard(firstTarget); + Card targetCard = game.getCard(id); + if (card == null || targetCard == null + || !card.getOwnerId().equals(targetCard.getOwnerId())) { + return false; + } + } + return super.canTarget(id, source, game); + } + + + @Override + public TargetCardInASingleGraveyard copy() { + return new TargetCardInASingleGraveyard(this); + } +} diff --git a/Mage/src/mage/target/common/TargetCardInGraveyard.java b/Mage/src/mage/target/common/TargetCardInGraveyard.java index 471d44b111..f7db3177d7 100644 --- a/Mage/src/mage/target/common/TargetCardInGraveyard.java +++ b/Mage/src/mage/target/common/TargetCardInGraveyard.java @@ -67,8 +67,9 @@ public class TargetCardInGraveyard extends TargetCard { @Override public boolean canTarget(UUID id, Ability source, Game game) { Card card = game.getCard(id); - if (card != null && game.getState().getZone(card.getId()) == Zone.GRAVEYARD) + if (card != null && game.getState().getZone(card.getId()) == Zone.GRAVEYARD) { return filter.match(card, game); + } return false; }