diff --git a/Mage.Sets/src/mage/sets/antiquities/TransmuteArtifact.java b/Mage.Sets/src/mage/sets/antiquities/TransmuteArtifact.java index fc16f642206..d0b6d85fde4 100644 --- a/Mage.Sets/src/mage/sets/antiquities/TransmuteArtifact.java +++ b/Mage.Sets/src/mage/sets/antiquities/TransmuteArtifact.java @@ -129,7 +129,7 @@ class TransmuteArtifactEffect extends SearchEffect { } else{ //If you don't, put it into its owner's graveyard. Then shuffle your library - controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); + controller.moveCards(card, Zone.LIBRARY, Zone.GRAVEYARD, source, game); } } } diff --git a/Mage.Sets/src/mage/sets/betrayersofkamigawa/HeedTheMists.java b/Mage.Sets/src/mage/sets/betrayersofkamigawa/HeedTheMists.java index 8bcdd7ec796..0e044f80fa0 100644 --- a/Mage.Sets/src/mage/sets/betrayersofkamigawa/HeedTheMists.java +++ b/Mage.Sets/src/mage/sets/betrayersofkamigawa/HeedTheMists.java @@ -84,7 +84,7 @@ public class HeedTheMists extends CardImpl { Card card = controller.getLibrary().removeFromTop(game); if (card != null) { int cmc = card.getManaCost().convertedManaCost(); - controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); + controller.moveCards(card, Zone.LIBRARY, Zone.GRAVEYARD, source, game); controller.drawCards(cmc, game); } } diff --git a/Mage.Sets/src/mage/sets/championsofkamigawa/GiftsUngiven.java b/Mage.Sets/src/mage/sets/championsofkamigawa/GiftsUngiven.java index e11bc191c4b..c40bae528da 100644 --- a/Mage.Sets/src/mage/sets/championsofkamigawa/GiftsUngiven.java +++ b/Mage.Sets/src/mage/sets/championsofkamigawa/GiftsUngiven.java @@ -119,19 +119,14 @@ class GiftsUngivenEffect extends OneShotEffect { } else { opponent = game.getPlayer(game.getOpponents(player.getId()).iterator().next()); } - TargetCard targetDiscard = new TargetCard(2, Zone.PICK, new FilterCard("cards to put in graveyard")); + TargetCard targetDiscard = new TargetCard(2, Zone.LIBRARY, new FilterCard("cards to put in graveyard")); if (opponent != null && opponent.choose(Outcome.Discard, cards, targetDiscard, game)) { cardsToKeep.removeAll(targetDiscard.getTargets()); cards.removeAll(cardsToKeep); } } - for (UUID cardId : cards) { - Card card = game.getCard(cardId); - if (card != null) { - player.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); - } - } + player.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game); for (UUID cardId : cardsToKeep) { Card card = game.getCard(cardId); if (card != null) { diff --git a/Mage.Sets/src/mage/sets/commander2014/StitcherGeralf.java b/Mage.Sets/src/mage/sets/commander2014/StitcherGeralf.java index 8ad954bec05..d625fa7b221 100644 --- a/Mage.Sets/src/mage/sets/commander2014/StitcherGeralf.java +++ b/Mage.Sets/src/mage/sets/commander2014/StitcherGeralf.java @@ -105,15 +105,10 @@ class StitcherGeralfEffect extends OneShotEffect { for (UUID playerId: controller.getInRange()) { Player player = game.getPlayer(playerId); if (player != null) { - for (int i = 0; i < Math.min(3, player.getLibrary().size()); i++) { - Card card = player.getLibrary().getFromTop(game); - if (player.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY)) { - // add card only if it goes to graveyard - cards.add(card); - } - } + cards.addAll(player.getLibrary().getTopCards(game, 3)); } } + controller.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game); TargetCard target = new TargetCard(0,2,Zone.GRAVEYARD, new FilterCreatureCard("creature cards to exile")); controller.chooseTarget(outcome, cards, target, source, game); int power = 0; diff --git a/Mage.Sets/src/mage/sets/conspiracy/GrenzoDungeonWarden.java b/Mage.Sets/src/mage/sets/conspiracy/GrenzoDungeonWarden.java index 36dbd11400e..4b253a06661 100644 --- a/Mage.Sets/src/mage/sets/conspiracy/GrenzoDungeonWarden.java +++ b/Mage.Sets/src/mage/sets/conspiracy/GrenzoDungeonWarden.java @@ -117,7 +117,7 @@ class GrenzoDungeonWardenEffect extends OneShotEffect { GrenzoDungeonWardenEffect() { super(Outcome.Benefit); - this.staticText = "Put the bottom card of your library into your graveyard. If it's a creature card with power less than or equal to Grenzo's power, put it onto the battlefield"; + this.staticText = "Put the bottom card of your library into your graveyard. If it's a creature card with power less than or equal to {this}'s power, put it onto the battlefield"; } GrenzoDungeonWardenEffect(final GrenzoDungeonWardenEffect effect) { @@ -131,16 +131,16 @@ class GrenzoDungeonWardenEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - if (player != null) { - if (player.getLibrary().size() > 0) { - Card card = player.getLibrary().removeFromBottom(game); + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + if (controller.getLibrary().size() > 0) { + Card card = controller.getLibrary().removeFromBottom(game); if (card != null) { - player.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); + controller.moveCards(card, Zone.LIBRARY, Zone.GRAVEYARD, source, game); if (card.getCardType().contains(CardType.CREATURE)) { Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); if (sourcePermanent != null && card.getPower().getValue() <= sourcePermanent.getPower().getValue()) { - player.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId()); + controller.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId()); } } } diff --git a/Mage.Sets/src/mage/sets/dragonsoftarkir/GurmagDrowner.java b/Mage.Sets/src/mage/sets/dragonsoftarkir/GurmagDrowner.java index 438f2002828..fecfe20865f 100644 --- a/Mage.Sets/src/mage/sets/dragonsoftarkir/GurmagDrowner.java +++ b/Mage.Sets/src/mage/sets/dragonsoftarkir/GurmagDrowner.java @@ -101,22 +101,17 @@ class GurmagDrownerEffect extends OneShotEffect { if (controller != null && sourceObject != null) { Cards cards = new CardsImpl(); cards.addAll(controller.getLibrary().getTopCards(game, 4)); - if (cards.size() > 0) { controller.lookAtCards(sourceObject.getName(), cards, game); - TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to put in your hand")); if (controller.choose(Outcome.Benefit, cards, target, game)) { Card card = cards.get(target.getFirstTarget(), game); if (card != null) { - card.moveToZone(Zone.HAND, source.getSourceId(), game, false); + controller.moveCards(card, Zone.LIBRARY, Zone.HAND, source, game); cards.remove(card); } } - - for (Card card : cards.getCards(game)) { - controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); - } + controller.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game); } return true; } diff --git a/Mage.Sets/src/mage/sets/elvesvsgoblins/SkirkDrillSergeant.java b/Mage.Sets/src/mage/sets/elvesvsgoblins/SkirkDrillSergeant.java index 0963ac0f95e..fc751e65248 100644 --- a/Mage.Sets/src/mage/sets/elvesvsgoblins/SkirkDrillSergeant.java +++ b/Mage.Sets/src/mage/sets/elvesvsgoblins/SkirkDrillSergeant.java @@ -124,7 +124,7 @@ class SkirkDrillSergeantEffect extends OneShotEffect { if (filter.match(card, game)) { player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId()); } else { - player.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); + player.moveCards(card, Zone.LIBRARY, Zone.GRAVEYARD, source, game); } } } diff --git a/Mage.Sets/src/mage/sets/exodus/OathOfDruids.java b/Mage.Sets/src/mage/sets/exodus/OathOfDruids.java index 194dfe03e6d..e08f682393c 100644 --- a/Mage.Sets/src/mage/sets/exodus/OathOfDruids.java +++ b/Mage.Sets/src/mage/sets/exodus/OathOfDruids.java @@ -161,12 +161,7 @@ class OathOfDruidsEffect extends OneShotEffect { player.putOntoBattlefieldWithInfo(creatureCard, game, Zone.LIBRARY, source.getSourceId()); } // and all other cards revealed this way into his or her graveyard - for (UUID uuid : nonCreatureCards) { - Card card = game.getCard(uuid); - if (card != null) { - player.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); - } - } + player.moveCards(nonCreatureCards, Zone.LIBRARY, Zone.GRAVEYARD, source, game); return true; } diff --git a/Mage.Sets/src/mage/sets/gatecrash/PsychicStrike.java b/Mage.Sets/src/mage/sets/gatecrash/PsychicStrike.java index f7546f28458..4ecc8fc520a 100644 --- a/Mage.Sets/src/mage/sets/gatecrash/PsychicStrike.java +++ b/Mage.Sets/src/mage/sets/gatecrash/PsychicStrike.java @@ -94,13 +94,7 @@ class PsychicStrikeEffect extends OneShotEffect { if (stackObject != null) { Player controller = game.getPlayer(stackObject.getControllerId()); if (controller != null) { - int cardsCount = Math.min(2, controller.getLibrary().size()); - for (int i = 0; i < cardsCount; i++) { - Card card = controller.getLibrary().removeFromTop(game); - if (card != null) { - controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); - } - } + controller.moveCards(controller.getLibrary().getTopCards(game, 2), Zone.LIBRARY, Zone.GRAVEYARD, source, game); } } return countered; diff --git a/Mage.Sets/src/mage/sets/iceage/EnduringRenewal.java b/Mage.Sets/src/mage/sets/iceage/EnduringRenewal.java index 5c99ba221ad..725e5e71c57 100644 --- a/Mage.Sets/src/mage/sets/iceage/EnduringRenewal.java +++ b/Mage.Sets/src/mage/sets/iceage/EnduringRenewal.java @@ -112,26 +112,19 @@ class EnduringRenewalReplacementEffect extends ReplacementEffectImpl { @Override public boolean replaceEvent(GameEvent event, Ability source, Game game) { - Player you = game.getPlayer(source.getControllerId()); - if (you == null) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller == null) { return false; - } else if (you.getLibrary().size() > 0){ - - Card top = you.getLibrary().getFromTop(game); - + } + Card card = controller.getLibrary().getFromTop(game); + if (card != null) { Cards cards = new CardsImpl(); - - cards.add(top); - - you.revealCards("Top card of " + you.getName() + "'s library", cards, game); - - if (top.getCardType().contains(CardType.CREATURE)) { - you.moveCardToGraveyardWithInfo(top, source.getSourceId(), game, Zone.LIBRARY); - } else { - you.moveCardToHandWithInfo(top, source.getSourceId(), game, Zone.LIBRARY); + cards.add(card); + controller.revealCards("Top card of " + controller.getName() + "'s library", cards, game); + if (card.getCardType().contains(CardType.CREATURE)) { + controller.moveCards(card, Zone.LIBRARY, Zone.GRAVEYARD, source, game); + return true; } - - return true; } return false; } diff --git a/Mage.Sets/src/mage/sets/iceage/ZursWeirding.java b/Mage.Sets/src/mage/sets/iceage/ZursWeirding.java index 6ac69f1248a..96b514713ed 100644 --- a/Mage.Sets/src/mage/sets/iceage/ZursWeirding.java +++ b/Mage.Sets/src/mage/sets/iceage/ZursWeirding.java @@ -114,10 +114,8 @@ class ZursWeirdingReplacementEffect extends ReplacementEffectImpl { currentPlayer.getLife() >= 2 && currentPlayer.chooseUse(Outcome.Benefit, message, game)) { currentPlayer.loseLife(2, game); - player.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); - + player.moveCards(card, Zone.LIBRARY, Zone.GRAVEYARD, source, game); game.getState().getRevealed().reset(); - return true; } diff --git a/Mage.Sets/src/mage/sets/innistrad/Mulch.java b/Mage.Sets/src/mage/sets/innistrad/Mulch.java index a18ac113e7a..83ab6cfde9b 100644 --- a/Mage.Sets/src/mage/sets/innistrad/Mulch.java +++ b/Mage.Sets/src/mage/sets/innistrad/Mulch.java @@ -89,18 +89,21 @@ class MulchEffect extends OneShotEffect { MageObject sourceObject = game.getObject(source.getSourceId()); if (controller != null && sourceObject != null) { Cards cards = new CardsImpl(); - int count = Math.min(controller.getLibrary().size(), 4); - cards.addAll(controller.getLibrary().getTopCards(game, count)); + cards.addAll(controller.getLibrary().getTopCards(game, 4)); if (!cards.isEmpty()) { + controller.revealCards(sourceObject.getName(), cards, game); + Cards landCards = new CardsImpl(); + Cards otherCards = new CardsImpl(); for (Card card: cards.getCards(game)) { - cards.add(card); if (card.getCardType().contains(CardType.LAND)) { - controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); + landCards.add(card); } else { - controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); + otherCards.add(card); } } - controller.revealCards(sourceObject.getName(), cards, game); + controller.moveCards(landCards, Zone.LIBRARY, Zone.HAND, source, game); + controller.moveCards(otherCards, Zone.LIBRARY, Zone.GRAVEYARD, source, game); + } return true; } diff --git a/Mage.Sets/src/mage/sets/innistrad/TrepanationBlade.java b/Mage.Sets/src/mage/sets/innistrad/TrepanationBlade.java index bddcc031f64..1fe6f9554c9 100644 --- a/Mage.Sets/src/mage/sets/innistrad/TrepanationBlade.java +++ b/Mage.Sets/src/mage/sets/innistrad/TrepanationBlade.java @@ -115,15 +115,14 @@ class TrepanationBladeDiscardEffect extends OneShotEffect { Card card = player.getLibrary().removeFromTop(game); if (card != null) { cards.add(card); - player.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); if (card.getCardType().contains(CardType.LAND)) { landFound = true; } } } - + player.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game); if (!cards.isEmpty()) { - player.revealCards("Trepanation Blade", cards, game); + player.revealCards(equipment.getName(), cards, game); game.getState().setValue(source.getSourceId().toString() + "_TrepanationBlade", cards.size()); return true; } diff --git a/Mage.Sets/src/mage/sets/innistrad/UndeadAlchemist.java b/Mage.Sets/src/mage/sets/innistrad/UndeadAlchemist.java index f01b7dfe38e..884fc9e016a 100644 --- a/Mage.Sets/src/mage/sets/innistrad/UndeadAlchemist.java +++ b/Mage.Sets/src/mage/sets/innistrad/UndeadAlchemist.java @@ -98,16 +98,19 @@ class UndeadAlchemistTriggeredAbility extends TriggeredAbilityImpl { return new UndeadAlchemistTriggeredAbility(this); } + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.ZONE_CHANGE; + } + @Override public boolean checkTrigger(GameEvent event, Game game) { - if (event.getType() == GameEvent.EventType.ZONE_CHANGE) { - ZoneChangeEvent zEvent = (ZoneChangeEvent)event; - if (zEvent.getFromZone() == Zone.LIBRARY && zEvent.getToZone() == Zone.GRAVEYARD && game.getOpponents(this.getControllerId()).contains(zEvent.getPlayerId())) { - Card card = game.getCard(event.getTargetId()); - if (card != null && card.getCardType().contains(CardType.CREATURE)) { - this.getEffects().get(0).setTargetPointer(new FixedTarget(card.getId())); - return true; - } + ZoneChangeEvent zEvent = (ZoneChangeEvent)event; + if (zEvent.getFromZone() == Zone.LIBRARY && zEvent.getToZone() == Zone.GRAVEYARD && game.getOpponents(this.getControllerId()).contains(zEvent.getPlayerId())) { + Card card = game.getCard(event.getTargetId()); + if (card != null && card.getCardType().contains(CardType.CREATURE)) { + this.getEffects().get(0).setTargetPointer(new FixedTarget(card.getId())); + return true; } } return false; @@ -134,30 +137,23 @@ class UndeadAlchemistEffect extends ReplacementEffectImpl { public boolean replaceEvent(GameEvent event, Ability source, Game game) { Player player = game.getPlayer(event.getTargetId()); if (player != null) { - int cardsCount = Math.min(event.getAmount(), player.getLibrary().size()); - for (int i = 0; i < cardsCount; i++) { - Card card = player.getLibrary().removeFromTop(game); - if (card != null) { - player.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); - } else { - break; - } - } - - return true; + return player.moveCards(player.getLibrary().getTopCards(game, event.getAmount()), Zone.LIBRARY, Zone.GRAVEYARD, source, game); } return true; } + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.DAMAGE_PLAYER; + } + @Override public boolean applies(GameEvent event, Ability source, Game game) { - if (event.getType() == GameEvent.EventType.DAMAGE_PLAYER && event instanceof DamagePlayerEvent) { - DamagePlayerEvent damageEvent = (DamagePlayerEvent) event; - if (damageEvent.isCombatDamage()) { - Permanent permanent = game.getPermanent(event.getSourceId()); - if (permanent != null && permanent.hasSubtype("Zombie")) { - return true; - } + DamagePlayerEvent damageEvent = (DamagePlayerEvent) event; + if (damageEvent.isCombatDamage()) { + Permanent permanent = game.getPermanent(event.getSourceId()); + if (permanent != null && permanent.hasSubtype("Zombie")) { + return true; } } return false; diff --git a/Mage.Sets/src/mage/sets/invasion/RevivingVapors.java b/Mage.Sets/src/mage/sets/invasion/RevivingVapors.java index aff5c131df5..d867fbc732b 100644 --- a/Mage.Sets/src/mage/sets/invasion/RevivingVapors.java +++ b/Mage.Sets/src/mage/sets/invasion/RevivingVapors.java @@ -112,12 +112,9 @@ class RevivingVaporsEffect extends OneShotEffect { } if (card != null) { cards.remove(card); - controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); - } - - for (Card moveCard: cards.getCards(game)) { - controller.moveCardToGraveyardWithInfo(moveCard, source.getSourceId(), game, Zone.LIBRARY); + controller.moveCards(card, Zone.LIBRARY, Zone.GRAVEYARD, source, game); } + controller.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game); } return true; } diff --git a/Mage.Sets/src/mage/sets/journeyintonyx/Countermand.java b/Mage.Sets/src/mage/sets/journeyintonyx/Countermand.java index 005a6cefb8f..6f4269f9735 100644 --- a/Mage.Sets/src/mage/sets/journeyintonyx/Countermand.java +++ b/Mage.Sets/src/mage/sets/journeyintonyx/Countermand.java @@ -93,13 +93,7 @@ class CountermandEffect extends OneShotEffect { if (stackObject != null) { Player controller = game.getPlayer(stackObject.getControllerId()); if (controller != null) { - int cardsCount = Math.min(4, controller.getLibrary().size()); - for (int i = 0; i < cardsCount; i++) { - Card card = controller.getLibrary().removeFromTop(game); - if (card != null) { - controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); - } - } + controller.moveCards(controller.getLibrary().getTopCards(game, 4), Zone.LIBRARY, Zone.GRAVEYARD, source, game); } } return countered; diff --git a/Mage.Sets/src/mage/sets/journeyintonyx/DakraMystic.java b/Mage.Sets/src/mage/sets/journeyintonyx/DakraMystic.java index 862ae462b97..6c9afba1eb6 100644 --- a/Mage.Sets/src/mage/sets/journeyintonyx/DakraMystic.java +++ b/Mage.Sets/src/mage/sets/journeyintonyx/DakraMystic.java @@ -105,9 +105,9 @@ class DakraMysticEffect extends OneShotEffect { } if (controller.chooseUse(outcome, "Put revealed cards into graveyard?", game)) { for(UUID playerId: controller.getInRange()) { - Player player = game.getPlayer(playerId); + Player player = game.getPlayer(playerId); if (player != null && player.getLibrary().size() > 0) { - controller.moveCardToGraveyardWithInfo(player.getLibrary().getFromTop(game), source.getSourceId(), game, Zone.LIBRARY); + player.moveCards(player.getLibrary().getFromTop(game), Zone.LIBRARY, Zone.GRAVEYARD, source, game); } } } else { diff --git a/Mage.Sets/src/mage/sets/khansoftarkir/BitterRevelation.java b/Mage.Sets/src/mage/sets/khansoftarkir/BitterRevelation.java index 0c858075ea0..f7d5f2c831c 100644 --- a/Mage.Sets/src/mage/sets/khansoftarkir/BitterRevelation.java +++ b/Mage.Sets/src/mage/sets/khansoftarkir/BitterRevelation.java @@ -99,20 +99,20 @@ class BitterRevelationEffect extends OneShotEffect { } } if (cards.size() > 0) { + Cards cardsToHand = new CardsImpl(); player.lookAtCards("Bitter Revelation", cards, game); TargetCard target = new TargetCard(Math.min(2, cards.size()), Zone.PICK, new FilterCard("two cards to put in your hand")); if (player.choose(Outcome.DrawCard, cards, target, game)) { for (UUID targetId : target.getTargets()) { Card card = cards.get(targetId, game); if (card != null) { - player.putInHand(card, game); + cardsToHand.add(card); cards.remove(card); } } } - for (Card card : cards.getCards(game)) { - player.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); - } + player.moveCards(cardsToHand, Zone.LIBRARY, Zone.HAND, source, game); + player.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game); } return true; } diff --git a/Mage.Sets/src/mage/sets/khansoftarkir/ScoutTheBorders.java b/Mage.Sets/src/mage/sets/khansoftarkir/ScoutTheBorders.java index 3b9f71b4c2e..968ec4167f0 100644 --- a/Mage.Sets/src/mage/sets/khansoftarkir/ScoutTheBorders.java +++ b/Mage.Sets/src/mage/sets/khansoftarkir/ScoutTheBorders.java @@ -117,18 +117,12 @@ class ScoutTheBordersEffect extends OneShotEffect { if (properCardFound && controller.choose(Outcome.DrawCard, cards, target, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { - controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); + controller.moveCards(card, Zone.LIBRARY, Zone.HAND, source, game); cards.remove(card); } } - - for (UUID cardId : cards) { - Card card = game.getCard(cardId); - if (card != null) { - controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); - } - } + controller.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game); } return true; } diff --git a/Mage.Sets/src/mage/sets/khansoftarkir/SeeTheUnwritten.java b/Mage.Sets/src/mage/sets/khansoftarkir/SeeTheUnwritten.java index ad26154debc..248f02ab30f 100644 --- a/Mage.Sets/src/mage/sets/khansoftarkir/SeeTheUnwritten.java +++ b/Mage.Sets/src/mage/sets/khansoftarkir/SeeTheUnwritten.java @@ -106,15 +106,15 @@ class SeeTheUnwrittenEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); + Player controller = game.getPlayer(source.getControllerId()); MageObject sourceObject = game.getObject(source.getSourceId()); - if (player != null && sourceObject != null) { + if (controller != null && sourceObject != null) { Cards cards = new CardsImpl(Zone.LIBRARY); int creatureCardsFound = 0; - int count = Math.min(player.getLibrary().size(), 8); + int count = Math.min(controller.getLibrary().size(), 8); for (int i = 0; i < count; i++) { - Card card = player.getLibrary().removeFromTop(game); + Card card = controller.getLibrary().removeFromTop(game); if (card != null) { cards.add(card); if (filter.match(card, source.getSourceId(), source.getControllerId(), game)) { @@ -124,27 +124,22 @@ class SeeTheUnwrittenEffect extends OneShotEffect { } if (!cards.isEmpty()) { - player.revealCards(sourceObject.getName(), cards, game); - if (creatureCardsFound > 0 && player.chooseUse(outcome, "Put creature(s) into play?", game)) { + controller.revealCards(sourceObject.getName(), cards, game); + if (creatureCardsFound > 0 && controller.chooseUse(outcome, "Put creature(s) into play?", game)) { int cardsToChoose = Math.min(numberOfCardsToPutIntoPlay, creatureCardsFound); TargetCard target = new TargetCard(cardsToChoose, cardsToChoose, Zone.LIBRARY, filter); - if (player.choose(Outcome.PutCreatureInPlay, cards, target, game)) { + if (controller.choose(Outcome.PutCreatureInPlay, cards, target, game)) { for(UUID creatureId: target.getTargets()) { Card card = game.getCard(creatureId); if (card != null) { cards.remove(card); - player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId()); + controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId()); } } } } - for (UUID cardId : cards) { - Card card = game.getCard(cardId); - if (card != null) { - player.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); - } - } + controller.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game); } return true; } diff --git a/Mage.Sets/src/mage/sets/khansoftarkir/SultaiSoothsayer.java b/Mage.Sets/src/mage/sets/khansoftarkir/SultaiSoothsayer.java index 383bd3faddb..2409babeeba 100644 --- a/Mage.Sets/src/mage/sets/khansoftarkir/SultaiSoothsayer.java +++ b/Mage.Sets/src/mage/sets/khansoftarkir/SultaiSoothsayer.java @@ -98,22 +98,17 @@ class SultaiSoothsayerEffect extends OneShotEffect { if (controller != null && sourceObject != null) { Cards cards = new CardsImpl(); cards.addAll(controller.getLibrary().getTopCards(game, 4)); - if (cards.size() > 0) { controller.lookAtCards(sourceObject.getName(), cards, game); - TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to put in your hand")); if (controller.choose(Outcome.Benefit, cards, target, game)) { Card card = cards.get(target.getFirstTarget(), game); if (card != null) { - card.moveToZone(Zone.HAND, source.getSourceId(), game, false); + controller.moveCards(card, Zone.LIBRARY, Zone.GRAVEYARD, source, game); cards.remove(card); } } - - for (Card card : cards.getCards(game)) { - controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); - } + controller.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game); } return true; } diff --git a/Mage.Sets/src/mage/sets/khansoftarkir/TaigamsScheming.java b/Mage.Sets/src/mage/sets/khansoftarkir/TaigamsScheming.java index a566c32b053..74afa58c4e1 100644 --- a/Mage.Sets/src/mage/sets/khansoftarkir/TaigamsScheming.java +++ b/Mage.Sets/src/mage/sets/khansoftarkir/TaigamsScheming.java @@ -95,38 +95,20 @@ class TaigamsSchemingEffect extends OneShotEffect { controller.setTopCardRevealed(false); // get cards from top Cards cards = new CardsImpl(); - int count = Math.min(controller.getLibrary().size(), 5); - if (count > 0) { - cards.addAll(controller.getLibrary().getTopCards(game, count)); + cards.addAll(controller.getLibrary().getTopCards(game, 5)); + if (!cards.isEmpty()) { controller.lookAtCards(sourceObject.getName(), cards, game); // pick cards going to graveyard - TargetCard target = new TargetCard(0,5, Zone.LIBRARY, new FilterCard("cards to put into your graveyard")); + TargetCard target = new TargetCard(0,cards.size(), Zone.LIBRARY, new FilterCard("cards to put into your graveyard")); if (controller.choose(Outcome.Detriment, cards, target, game)) { - for (UUID cardId : (List)target.getTargets()) { - Card card = cards.get(cardId, game); - if (card != null) { - cards.remove(card); - controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); - } - } + Cards cardsToGraveyard = new CardsImpl(); + cards.removeAll(target.getTargets()); + cardsToGraveyard.addAll(target.getTargets()); + controller.moveCards(cardsToGraveyard, Zone.LIBRARY, Zone.GRAVEYARD, source, game); } // The rest goes back to library in any order if (cards.size() > 0) { - game.informPlayers(controller.getLogName() + " puts " + cards.size() + " card" + (cards.size() ==1 ? "":"s") + " back to his or her library"); - target = new TargetCard(Zone.LIBRARY, new FilterCard("card to put on your library (last chosen will be on top)")); - while (controller.isInGame() && cards.size() > 1) { - controller.choose(Outcome.Neutral, cards, target, game); - Card card = cards.get(target.getFirstTarget(), game); - if (card != null) { - cards.remove(card); - card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true); - } - target.clearChosen(); - } - if (cards.size() == 1) { - Card card = cards.get(cards.iterator().next(), game); - card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true); - } + controller.putCardsOnTopOfLibrary(cards, game, source, true); } } controller.setTopCardRevealed(topCardRevealed); diff --git a/Mage.Sets/src/mage/sets/newphyrexia/LifesFinale.java b/Mage.Sets/src/mage/sets/newphyrexia/LifesFinale.java index c5a13f6cc66..cb6f9dcb8cb 100644 --- a/Mage.Sets/src/mage/sets/newphyrexia/LifesFinale.java +++ b/Mage.Sets/src/mage/sets/newphyrexia/LifesFinale.java @@ -33,6 +33,8 @@ 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; @@ -98,13 +100,7 @@ class LifesFinaleEffect extends OneShotEffect { if (player != null && opponent != null) { TargetCardInLibrary target = new TargetCardInLibrary(0, 3, new FilterCreatureCard("creature cards from his library to put in his graveyard")); if (player.searchLibrary(target, game, opponent.getId())) { - List targets = target.getTargets(); - for (UUID targetId : targets) { - Card card = opponent.getLibrary().remove(targetId, game); - if (card != null) { - player.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); - } - } + player.moveCards(new CardsImpl(target.getTargets()), Zone.LIBRARY, Zone.GRAVEYARD, source, game); } opponent.shuffleLibrary(game); return true; diff --git a/Mage.Sets/src/mage/sets/odyssey/Entomb.java b/Mage.Sets/src/mage/sets/odyssey/Entomb.java index 66ce41fa05d..887ef80e5d3 100644 --- a/Mage.Sets/src/mage/sets/odyssey/Entomb.java +++ b/Mage.Sets/src/mage/sets/odyssey/Entomb.java @@ -54,7 +54,6 @@ public class Entomb extends CardImpl { super(ownerId, 132, "Entomb", Rarity.RARE, new CardType[]{CardType.INSTANT}, "{B}"); this.expansionSetCode = "ODY"; - // Search your library for a card and put that card into your graveyard. Then shuffle your library. this.getSpellAbility().addEffect(new SearchLibraryPutInGraveyard()); } @@ -92,20 +91,11 @@ class SearchLibraryPutInGraveyard extends SearchEffect { if (controller == null) { return false; } - boolean result = false; if (controller.searchLibrary(target, game)) { - if (target.getTargets().size() > 0) { - for (UUID cardId: (List)target.getTargets()) { - Card card = controller.getLibrary().remove(cardId, game); - if (card != null) { - controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); - } - } - } - result = true; + controller.moveCards(game.getCard(target.getFirstTarget()), Zone.LIBRARY, Zone.GRAVEYARD, source, game); } controller.shuffleLibrary(game); - return result; + return true; } } diff --git a/Mage.Sets/src/mage/sets/odyssey/Predict.java b/Mage.Sets/src/mage/sets/odyssey/Predict.java index cee6aa18bcb..cf7607f4555 100644 --- a/Mage.Sets/src/mage/sets/odyssey/Predict.java +++ b/Mage.Sets/src/mage/sets/odyssey/Predict.java @@ -97,15 +97,12 @@ class PredictEffect extends OneShotEffect { int amount = 1; Card card = targetPlayer.getLibrary().getFromTop(game); if (card != null) { - if (targetPlayer.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY)) { - if (card.getName().equals(cardName)) { - amount = 2; - } + controller.moveCards(card, Zone.LIBRARY, Zone.GRAVEYARD, source, game); + if (card.getName().equals(cardName)) { + amount = 2; } - } - - controller.drawCards(amount, game); - + } + controller.drawCards(amount, game); return true; } return false; diff --git a/Mage.Sets/src/mage/sets/odyssey/Zoologist.java b/Mage.Sets/src/mage/sets/odyssey/Zoologist.java index f540e179d31..5780599cfe9 100644 --- a/Mage.Sets/src/mage/sets/odyssey/Zoologist.java +++ b/Mage.Sets/src/mage/sets/odyssey/Zoologist.java @@ -109,7 +109,7 @@ class ZoologistEffect extends OneShotEffect { if (card.getCardType().contains(CardType.CREATURE)) { player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId()); } else { - player.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); + player.moveCards(card, Zone.LIBRARY, Zone.GRAVEYARD, source, game); } } } diff --git a/Mage.Sets/src/mage/sets/returntoravnica/GrislySalvage.java b/Mage.Sets/src/mage/sets/returntoravnica/GrislySalvage.java index 85bc21d4a6f..0b1ee4f9c85 100644 --- a/Mage.Sets/src/mage/sets/returntoravnica/GrislySalvage.java +++ b/Mage.Sets/src/mage/sets/returntoravnica/GrislySalvage.java @@ -112,13 +112,11 @@ class GrislySalvageEffect extends OneShotEffect { if (properCardFound && controller.choose(Outcome.DrawCard, cards, target, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { - controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); + controller.moveCards(card, Zone.LIBRARY, Zone.HAND, source, game); cards.remove(card); } } - for (Card card : cards.getCards(game)) { - controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); - } + controller.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game); } return true; } diff --git a/Mage.Sets/src/mage/sets/riseoftheeldrazi/RealmsUncharted.java b/Mage.Sets/src/mage/sets/riseoftheeldrazi/RealmsUncharted.java index 628f32db775..e597ad94748 100644 --- a/Mage.Sets/src/mage/sets/riseoftheeldrazi/RealmsUncharted.java +++ b/Mage.Sets/src/mage/sets/riseoftheeldrazi/RealmsUncharted.java @@ -102,7 +102,7 @@ class RealmsUnchartedEffect extends OneShotEffect { if (controller.searchLibrary(target, game)) { if (target.getTargets().size() > 0) { Cards cards = new CardsImpl(); - for (UUID cardId : (List) target.getTargets()) { + for (UUID cardId : target.getTargets()) { Card card = controller.getLibrary().getCard(cardId, game); if (card != null) { cards.add(card); @@ -129,19 +129,8 @@ class RealmsUnchartedEffect extends OneShotEffect { cards.removeAll(cardsToKeep); } } - - for (UUID cardId : cards) { - Card card = game.getCard(cardId); - if (card != null) { - controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); - } - } - for (UUID cardId : cardsToKeep) { - Card card = game.getCard(cardId); - if (card != null) { - controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); - } - } + controller.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game); + controller.moveCards(cardsToKeep, Zone.LIBRARY, Zone.HAND, source, game); } controller.shuffleLibrary(game); return true; diff --git a/Mage.Sets/src/mage/sets/saviorsofkamigawa/MurmursFromBeyond.java b/Mage.Sets/src/mage/sets/saviorsofkamigawa/MurmursFromBeyond.java index c5fe30687b3..76ece7c2df5 100644 --- a/Mage.Sets/src/mage/sets/saviorsofkamigawa/MurmursFromBeyond.java +++ b/Mage.Sets/src/mage/sets/saviorsofkamigawa/MurmursFromBeyond.java @@ -97,8 +97,9 @@ class MurmursFromBeyondEffect extends OneShotEffect { cards.addAll(controller.getLibrary().getTopCards(game, 3)); if (!cards.isEmpty()) { controller.revealCards(staticText, cards, game); + Card cardToGraveyard; if (cards.size() == 1) { - controller.moveCardToGraveyardWithInfo(cards.getRandom(game), source.getSourceId(), game, Zone.LIBRARY); + cardToGraveyard = cards.getRandom(game); } else { Player opponent; Set opponents = game.getOpponents(controller.getId()); @@ -111,15 +112,13 @@ class MurmursFromBeyondEffect extends OneShotEffect { } TargetCard target = new TargetCard(1, Zone.LIBRARY, new FilterCard()); opponent.chooseTarget(outcome, cards, target, source, game); - Card card = game.getCard(target.getFirstTarget()); - if (card != null) { - controller.moveCardToGraveyardWithInfo(cards.getRandom(game), source.getSourceId(), game, Zone.LIBRARY); - cards.remove(card); - } - for (Card cardToHand: cards.getCards(game)) { - controller.moveCardToHandWithInfo(cardToHand, source.getSourceId(), game, Zone.LIBRARY); - } + cardToGraveyard = game.getCard(target.getFirstTarget()); + } + if (cardToGraveyard != null) { + controller.moveCards(cardToGraveyard,Zone.LIBRARY, Zone.GRAVEYARD, source, game); + cards.remove(cardToGraveyard); } + controller.moveCards(cards, Zone.LIBRARY, Zone.HAND, source, game); } return true; } diff --git a/Mage.Sets/src/mage/sets/scarsofmirrodin/GenesisWave.java b/Mage.Sets/src/mage/sets/scarsofmirrodin/GenesisWave.java index 54846b2cddd..1d54c0cce94 100644 --- a/Mage.Sets/src/mage/sets/scarsofmirrodin/GenesisWave.java +++ b/Mage.Sets/src/mage/sets/scarsofmirrodin/GenesisWave.java @@ -123,11 +123,7 @@ class GenesisWaveEffect extends OneShotEffect { controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId()); } } - while (cards.size() > 0) { - Card card = cards.get(cards.iterator().next(), game); - cards.remove(card); - controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); - } + controller.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game); } return true; } diff --git a/Mage.Sets/src/mage/sets/shadowmoor/ImpromptuRaid.java b/Mage.Sets/src/mage/sets/shadowmoor/ImpromptuRaid.java index fa448a0c0e0..95e71547286 100644 --- a/Mage.Sets/src/mage/sets/shadowmoor/ImpromptuRaid.java +++ b/Mage.Sets/src/mage/sets/shadowmoor/ImpromptuRaid.java @@ -113,7 +113,7 @@ class ImpromptuRaidEffect extends OneShotEffect { cards.add(card); controller.revealCards(sourceObject.getName(), cards, game); if (filterPutInGraveyard.match(card, source.getSourceId(), source.getControllerId(), game)) { - controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); + controller.moveCards(card, Zone.LIBRARY, Zone.GRAVEYARD, source, game); return true; } if (controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId())) { diff --git a/Mage.Sets/src/mage/sets/stronghold/HermitDruid.java b/Mage.Sets/src/mage/sets/stronghold/HermitDruid.java index 89a48a3c88f..efc70d9ce33 100644 --- a/Mage.Sets/src/mage/sets/stronghold/HermitDruid.java +++ b/Mage.Sets/src/mage/sets/stronghold/HermitDruid.java @@ -42,7 +42,6 @@ import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Rarity; import mage.constants.Zone; -import mage.filter.Filter; import mage.filter.common.FilterBasicLandCard; import mage.game.Game; import mage.players.Library; @@ -67,8 +66,6 @@ public class HermitDruid extends CardImpl { Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new HermitDruidEffect(), new ManaCostsImpl("{G}")); ability.addCost(new TapSourceCost()); this.addAbility(ability); - - } public HermitDruid(final HermitDruid card) { @@ -109,13 +106,13 @@ class HermitDruidEffect extends OneShotEffect { } CardsImpl cards = new CardsImpl(); Card card; - Filter filter = new FilterBasicLandCard(); + FilterBasicLandCard filter = new FilterBasicLandCard(); do { card = library.removeFromTop(game); if (card != null) { if (filter.match(card, game)) { - player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); + player.moveCards(card, Zone.LIBRARY, Zone.HAND, source, game); } else { cards.add(card); } @@ -123,9 +120,7 @@ class HermitDruidEffect extends OneShotEffect { } while (library.size() > 0 && card != null && !filter.match(card, game)); if (!cards.isEmpty()) { - for (Card cardToGrave: cards.getCards(game)) { - player.moveCardToGraveyardWithInfo(cardToGrave, source.getSourceId(), game, Zone.LIBRARY); - } + player.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game); if (card != null) { cards.add(card); } diff --git a/Mage.Sets/src/mage/sets/stronghold/MoxDiamond.java b/Mage.Sets/src/mage/sets/stronghold/MoxDiamond.java index 7ebc0e8b629..5438cfc2f5f 100644 --- a/Mage.Sets/src/mage/sets/stronghold/MoxDiamond.java +++ b/Mage.Sets/src/mage/sets/stronghold/MoxDiamond.java @@ -110,7 +110,7 @@ class MoxDiamondReplacementEffect extends ReplacementEffectImpl { else{ Card card = game.getCard(event.getTargetId()); if (card != null) { - player.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, null); + player.moveCards(card, Zone.STACK, Zone.GRAVEYARD, source, game); } return true; } diff --git a/Mage.Sets/src/mage/sets/tempest/Grindstone.java b/Mage.Sets/src/mage/sets/tempest/Grindstone.java index c27434aef0f..aac4ee1fec2 100644 --- a/Mage.Sets/src/mage/sets/tempest/Grindstone.java +++ b/Mage.Sets/src/mage/sets/tempest/Grindstone.java @@ -35,6 +35,8 @@ import mage.abilities.costs.mana.ManaCostsImpl; 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; @@ -106,23 +108,18 @@ class GrindstoneEffect extends OneShotEffect { return true; } colorShared = false; - Card card1 = null; - Card card2 = null; - if (targetPlayer.getLibrary().size() > 0) { - card1 = targetPlayer.getLibrary().removeFromTop(game); + Cards cards = new CardsImpl(); + cards.addAll(targetPlayer.getLibrary().getTopCards(game, 2)); + if (!cards.isEmpty()) { + Card card1 = targetPlayer.getLibrary().removeFromTop(game); if (targetPlayer.getLibrary().size() > 0) { - card2 = targetPlayer.getLibrary().removeFromTop(game); + Card card2 = targetPlayer.getLibrary().removeFromTop(game); if (card1.getColor().hasColor() && card2.getColor().hasColor()) { colorShared = card1.getColor().shares(card2.getColor()); } } } - if (card1 != null) { - targetPlayer.moveCardToGraveyardWithInfo(card1, source.getSourceId(), game, Zone.LIBRARY); - } - if (card2 != null) { - targetPlayer.moveCardToGraveyardWithInfo(card2, source.getSourceId(), game, Zone.LIBRARY); - } + targetPlayer.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game); } while (colorShared && targetPlayer.isInGame()); return true; } diff --git a/Mage.Sets/src/mage/sets/theros/CommuneWithTheGods.java b/Mage.Sets/src/mage/sets/theros/CommuneWithTheGods.java index dd65dd81d13..1a16b219244 100644 --- a/Mage.Sets/src/mage/sets/theros/CommuneWithTheGods.java +++ b/Mage.Sets/src/mage/sets/theros/CommuneWithTheGods.java @@ -119,17 +119,11 @@ class CommuneWithTheGodsEffect extends OneShotEffect { Card card = game.getCard(target.getFirstTarget()); if (card != null) { cards.remove(card); - controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); + controller.moveCards(card, Zone.LIBRARY, Zone.GRAVEYARD, source, game); } } - - for (UUID cardId : cards) { - Card card = game.getCard(cardId); - if (card != null) { - controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); - } - } + controller.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game); } return true; } diff --git a/Mage.Sets/src/mage/sets/timeshifted/GrinningTotem.java b/Mage.Sets/src/mage/sets/timeshifted/GrinningTotem.java index a709607a8a2..8cd942ebf69 100644 --- a/Mage.Sets/src/mage/sets/timeshifted/GrinningTotem.java +++ b/Mage.Sets/src/mage/sets/timeshifted/GrinningTotem.java @@ -237,10 +237,7 @@ class GrinningTotemPutIntoGraveyardEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); ExileZone zone = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source)); if (controller != null && zone != null) { - for (Card card : zone.getCards(game)) { - controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.EXILED); - } - return true; + return controller.moveCards(zone, Zone.EXILED, Zone.GRAVEYARD, source, game); } return false; } diff --git a/Mage.Sets/src/mage/sets/timespiral/PullFromEternity.java b/Mage.Sets/src/mage/sets/timespiral/PullFromEternity.java index e69e92e5537..1a0284aeb35 100644 --- a/Mage.Sets/src/mage/sets/timespiral/PullFromEternity.java +++ b/Mage.Sets/src/mage/sets/timespiral/PullFromEternity.java @@ -98,7 +98,7 @@ class PullFromEternityEffect extends OneShotEffect { if (controller != null) { Card card = game.getCard(getTargetPointer().getFirst(game, source)); if (card != null) { - controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.EXILED); + controller.moveCards(card, Zone.EXILED, Zone.GRAVEYARD, source, game); } return true; } diff --git a/Mage.Sets/src/mage/sets/visions/WandOfDenial.java b/Mage.Sets/src/mage/sets/visions/WandOfDenial.java index 01044803616..1ccd7901d5f 100644 --- a/Mage.Sets/src/mage/sets/visions/WandOfDenial.java +++ b/Mage.Sets/src/mage/sets/visions/WandOfDenial.java @@ -98,9 +98,9 @@ class WandOfDenialEffect extends OneShotEffect { if (!card.getCardType().contains(CardType.LAND) && controller.canPayLifeCost() && controller.getLife() >= 2 - && controller.chooseUse(Outcome.Neutral, "Pay 2 life to put " + card.getName() + " into graveyard?", game)) { + && controller.chooseUse(Outcome.Neutral, "Pay 2 life to put " + card.getLogName() + " into graveyard?", game)) { controller.loseLife(2, game); - controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); + controller.moveCards(card, Zone.LIBRARY, Zone.GRAVEYARD, source, game); } return true; } diff --git a/Mage.Sets/src/mage/sets/weatherlight/CallOfTheWild.java b/Mage.Sets/src/mage/sets/weatherlight/CallOfTheWild.java index f4f13334e9e..bc0509a505a 100644 --- a/Mage.Sets/src/mage/sets/weatherlight/CallOfTheWild.java +++ b/Mage.Sets/src/mage/sets/weatherlight/CallOfTheWild.java @@ -54,7 +54,6 @@ public class CallOfTheWild extends CardImpl { super(ownerId, 64, "Call of the Wild", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{2}{G}{G}"); this.expansionSetCode = "WTH"; - // {2}{G}{G}: Reveal the top card of your library. If it's a creature card, put it onto the battlefield. Otherwise, put it into your graveyard. this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new CallOfTheWildEffect(), new ManaCostsImpl("{2}{G}{G}"))); } @@ -103,10 +102,10 @@ class CallOfTheWildEffect extends OneShotEffect { if (card.getCardType().contains(CardType.CREATURE)) { player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId()); } else { - player.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); + player.moveCards(card, Zone.LIBRARY, Zone.GRAVEYARD, source, game); } } } - return false; + return true; } } diff --git a/Mage.Sets/src/mage/sets/zendikar/BeastHunt.java b/Mage.Sets/src/mage/sets/zendikar/BeastHunt.java index 172d49dc4dc..22c9d2a05ee 100644 --- a/Mage.Sets/src/mage/sets/zendikar/BeastHunt.java +++ b/Mage.Sets/src/mage/sets/zendikar/BeastHunt.java @@ -86,25 +86,19 @@ class BeastHuntEffect extends OneShotEffect { } Cards cards = new CardsImpl(); - int count = Math.min(controller.getLibrary().size(), 3); - for (int i = 0; i < count; i++) { - Card card = controller.getLibrary().removeFromTop(game); - if (card != null) { - cards.add(card); - if (card.getCardType().contains(CardType.CREATURE)) { - controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); - } else { - controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); - } - } else { - return false; - } - } - + Cards cardsToHand = new CardsImpl(); + cards.addAll(controller.getLibrary().getTopCards(game, 3)); if (!cards.isEmpty()) { controller.revealCards(sourceObject.getName(), cards, game); + for (Card card: cards.getCards(game)) { + if (card.getCardType().contains(CardType.CREATURE)) { + cardsToHand.add(card); + cards.remove(card); + } + } + controller.moveCards(cardsToHand, Zone.LIBRARY, Zone.HAND, source, game); + controller.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game); } - return true; } diff --git a/Mage/src/mage/abilities/effects/common/EnterBattlefieldPayCostOrPutGraveyardEffect.java b/Mage/src/mage/abilities/effects/common/EnterBattlefieldPayCostOrPutGraveyardEffect.java index 53e7cd764e2..b3f4001b7b2 100644 --- a/Mage/src/mage/abilities/effects/common/EnterBattlefieldPayCostOrPutGraveyardEffect.java +++ b/Mage/src/mage/abilities/effects/common/EnterBattlefieldPayCostOrPutGraveyardEffect.java @@ -86,7 +86,7 @@ public class EnterBattlefieldPayCostOrPutGraveyardEffect extends ReplacementEffe if (replace) { Card card = game.getCard(event.getTargetId()); if (card != null) { - player.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, game.getState().getZone(event.getTargetId())); + player.moveCards(card, game.getState().getZone(event.getTargetId()), Zone.GRAVEYARD, source, game); } return true; } diff --git a/Mage/src/mage/abilities/effects/common/LookLibraryControllerEffect.java b/Mage/src/mage/abilities/effects/common/LookLibraryControllerEffect.java index 658c3da101e..517179592e5 100644 --- a/Mage/src/mage/abilities/effects/common/LookLibraryControllerEffect.java +++ b/Mage/src/mage/abilities/effects/common/LookLibraryControllerEffect.java @@ -38,11 +38,9 @@ import mage.abilities.effects.OneShotEffect; import mage.cards.Card; 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.util.CardUtil; /** @@ -156,7 +154,7 @@ public class LookLibraryControllerEffect extends OneShotEffect { } /** - * Put the rest of the cards back to library + * Put the rest of the cards back to defined zone * * @param source * @param player @@ -166,27 +164,14 @@ public class LookLibraryControllerEffect extends OneShotEffect { protected void putCardsBack(Ability source, Player player, Cards cards, Game game) { switch(targetZoneLookedCards) { case LIBRARY: - TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard(this.getPutBackText())); - while (player.isInGame() && cards.size() > 1) { - player.choose(Outcome.Neutral, cards, target, game); - Card card = cards.get(target.getFirstTarget(), game); - if (card != null) { - cards.remove(card); - player.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.LIBRARY, putOnTop, false); - } - target.clearChosen(); - } - if (cards.size() == 1) { - Card card = cards.get(cards.iterator().next(), game); - player.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.LIBRARY, putOnTop, false); + if (putOnTop) { + player.putCardsOnTopOfLibrary(cards, game, source, true); + } else { + player.putCardsOnBottomOfLibrary(cards, game, source, true); } break; case GRAVEYARD: - for (Card card : cards.getCards(game)) { - player.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); - - card.moveToZone(Zone.GRAVEYARD, source.getSourceId(), game, true); - } + player.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game); break; default: // not supported yet @@ -205,16 +190,6 @@ public class LookLibraryControllerEffect extends OneShotEffect { } } - protected String getPutBackText() { - StringBuilder sb = new StringBuilder("card to put "); - if (putOnTop) { - sb.append("on your library (last chosen will be on top)"); - } else { - sb.append("on bottom of your library (last chosen will be mostbottom)"); - } - return sb.toString(); - } - @Override public String getText(Mode mode) { return setText(mode, ""); diff --git a/Mage/src/mage/abilities/effects/common/PutTopCardOfLibraryIntoGraveTargetEffect.java b/Mage/src/mage/abilities/effects/common/PutTopCardOfLibraryIntoGraveTargetEffect.java index 6467f1baa92..b40abbbff00 100644 --- a/Mage/src/mage/abilities/effects/common/PutTopCardOfLibraryIntoGraveTargetEffect.java +++ b/Mage/src/mage/abilities/effects/common/PutTopCardOfLibraryIntoGraveTargetEffect.java @@ -33,6 +33,7 @@ import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.common.StaticValue; import mage.abilities.effects.OneShotEffect; import mage.cards.Card; +import mage.cards.Cards; import mage.constants.Outcome; import mage.constants.Zone; import mage.game.Game; @@ -70,14 +71,7 @@ public class PutTopCardOfLibraryIntoGraveTargetEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player player = game.getPlayer(targetPointer.getFirst(game, source)); if (player != null) { - int cardsCount = Math.min(numberCards.calculate(game, source, this), player.getLibrary().size()); - for (int i = 0; i < cardsCount; i++) { - Card card = player.getLibrary().removeFromTop(game); - if (card != null) { - player.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); - } - } - return true; + return player.moveCards(player.getLibrary().getTopCards(game, numberCards.calculate(game, source, this)), Zone.LIBRARY, Zone.GRAVEYARD, source, game); } return false; } diff --git a/Mage/src/mage/abilities/effects/common/ReturnFromExileEffect.java b/Mage/src/mage/abilities/effects/common/ReturnFromExileEffect.java index 8ef7f04f938..25bb4868036 100644 --- a/Mage/src/mage/abilities/effects/common/ReturnFromExileEffect.java +++ b/Mage/src/mage/abilities/effects/common/ReturnFromExileEffect.java @@ -84,36 +84,37 @@ public class ReturnFromExileEffect extends OneShotEffect { ExileZone exile = game.getExile().getExileZone(exileId); Player controller = game.getPlayer(source.getControllerId()); if (controller != null && exile != null) { - exile = exile.copy(); - for (UUID cardId : exile) { - Card card = game.getCard(cardId); - Player owner = game.getPlayer(card.getOwnerId()); - if (owner != null) { - switch (zone) { - case BATTLEFIELD: - card.moveToZone(zone, source.getSourceId(), game, tapped); - if (!game.isSimulation()) { - game.informPlayers(controller.getLogName() + " moves " + card.getName() + " to " + zone.toString().toLowerCase()); - } - break; - case HAND: - controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.EXILED); - break; - case GRAVEYARD: - controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.EXILED); - break; - case LIBRARY: - controller.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.EXILED, true, true); - break; - default: - card.moveToZone(zone, source.getSourceId(), game, tapped); - if (!game.isSimulation()) { - game.informPlayers(controller.getLogName() + " moves " + card.getName() + " to " + zone.toString().toLowerCase()); - } + if (zone == Zone.GRAVEYARD) { + controller.moveCards(exile, zone, Zone.EXILED, source, game); + } else { + exile = exile.copy(); + for (UUID cardId : exile) { + Card card = game.getCard(cardId); + Player owner = game.getPlayer(card.getOwnerId()); + if (owner != null) { + switch (zone) { + case BATTLEFIELD: + card.moveToZone(zone, source.getSourceId(), game, tapped); + if (!game.isSimulation()) { + game.informPlayers(controller.getLogName() + " moves " + card.getName() + " to " + zone.toString().toLowerCase()); + } + break; + case HAND: + controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.EXILED); + break; + case LIBRARY: + controller.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.EXILED, true, true); + break; + default: + card.moveToZone(zone, source.getSourceId(), game, tapped); + if (!game.isSimulation()) { + game.informPlayers(controller.getLogName() + " moves " + card.getName() + " to " + zone.toString().toLowerCase()); + } + } } } + game.getExile().getExileZone(exileId).clear(); } - game.getExile().getExileZone(exileId).clear(); return true; } return false; diff --git a/Mage/src/mage/abilities/keyword/MadnessAbility.java b/Mage/src/mage/abilities/keyword/MadnessAbility.java index bb7c1d3b307..f8e1ff0f5cc 100644 --- a/Mage/src/mage/abilities/keyword/MadnessAbility.java +++ b/Mage/src/mage/abilities/keyword/MadnessAbility.java @@ -150,7 +150,7 @@ class MadnessTriggeredAbility extends TriggeredAbilityImpl { Player owner = game.getPlayer(card.getOwnerId()); if (owner != null) { // if cast was not successfull, the card is moved to graveyard - owner.moveCardToGraveyardWithInfo(card, getSourceId(), game, Zone.EXILED); + owner.moveCards(card, Zone.EXILED, Zone.GRAVEYARD, this, game); } } return false; diff --git a/Mage/src/mage/cards/CardsImpl.java b/Mage/src/mage/cards/CardsImpl.java index 8866b6ae079..a5c19f3a9f3 100644 --- a/Mage/src/mage/cards/CardsImpl.java +++ b/Mage/src/mage/cards/CardsImpl.java @@ -64,13 +64,21 @@ public class CardsImpl extends LinkedHashSet implements Cards, Serializabl public CardsImpl() { } public CardsImpl(Card card) { - this.add(card.getId()); + if (card != null) { + this.add(card.getId()); + } + } + + public CardsImpl(Collection cardIds) { + if (cardIds != null) { + this.addAll(cardIds); + } } public CardsImpl(Zone zone) { this.zone = zone; } - + public CardsImpl(Zone zone, Collection cards) { this(zone); for (Card card: cards) { diff --git a/Mage/src/mage/players/Player.java b/Mage/src/mage/players/Player.java index f2ce8e6aef9..d2d4b7d0646 100644 --- a/Mage/src/mage/players/Player.java +++ b/Mage/src/mage/players/Player.java @@ -438,6 +438,20 @@ public interface Player extends MageItem, Copyable { */ UUID getCommanderId(); + /** + * Moves cards from one zone to another + * + * @param cards + * @param fromZone + * @param toZone + * @param source + * @param game + * @return + */ + boolean moveCards(Cards cards, Zone fromZone, Zone toZone, Ability source, Game game); + boolean moveCards(List cards, Zone fromZone, Zone toZone, Ability source, Game game); + boolean moveCards(Card card, Zone fromZone, Zone toZone, Ability source, Game game); + /** * Uses card.moveToZone and posts a inform message about moving the card * into the game log diff --git a/Mage/src/mage/players/PlayerImpl.java b/Mage/src/mage/players/PlayerImpl.java index 2d344cc591d..30bc982f6b1 100644 --- a/Mage/src/mage/players/PlayerImpl.java +++ b/Mage/src/mage/players/PlayerImpl.java @@ -2821,13 +2821,42 @@ public abstract class PlayerImpl implements Player, Serializable { this.commanderId = commanderId; } - ; - @Override public UUID getCommanderId() { return this.commanderId; } + @Override + public boolean moveCards(Cards cards, Zone fromZone, Zone toZone, Ability source, Game game) { + ArrayList cardList = new ArrayList<>(); + cardList.addAll(cards.getCards(game)); + return moveCards(cardList, fromZone, toZone, source, game); + } + + @Override + public boolean moveCards(Card card, Zone fromZone, Zone toZone, Ability source, Game game) { + ArrayList cardList = new ArrayList<>(); + if (card != null) { + cardList.add(card); + } + return moveCards(cardList, fromZone, toZone, source, game); + } + + @Override + public boolean moveCards(List cards, Zone fromZone, Zone toZone, Ability source, Game game) { + switch(toZone) { + case GRAVEYARD: + return moveCardsToGraveyardWithInfo(cards, source, game, fromZone); + case HAND: + for(Card card: cards) { + moveCardToHandWithInfo(card, playerId, game, fromZone); + } + return true; + default: + throw new UnsupportedOperationException("to Zone not supported yet"); + } + } + @Override public boolean moveCardToHandWithInfo(Card card, UUID sourceId, Game game, Zone fromZone) { return this.moveCardToHandWithInfo(card, sourceId, game, fromZone, true);