diff --git a/Mage.Sets/src/mage/cards/a/AvatarOfGrowth.java b/Mage.Sets/src/mage/cards/a/AvatarOfGrowth.java index 0bee9d45c82..d6c7672ea7b 100644 --- a/Mage.Sets/src/mage/cards/a/AvatarOfGrowth.java +++ b/Mage.Sets/src/mage/cards/a/AvatarOfGrowth.java @@ -1,5 +1,7 @@ package mage.cards.a; +import java.util.HashSet; +import java.util.Set; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldTriggeredAbility; @@ -21,6 +23,7 @@ import mage.players.Player; import mage.target.common.TargetCardInLibrary; import java.util.UUID; +import mage.cards.Card; /** * @author JayDi85 @@ -75,6 +78,7 @@ class AvatarOfGrowthSearchEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); + Set toBattlefield = new HashSet<>(); if (controller != null) { for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); @@ -82,9 +86,17 @@ class AvatarOfGrowthSearchEffect extends OneShotEffect { TargetCardInLibrary target = new TargetCardInLibrary(0, 2, StaticFilters.FILTER_CARD_BASIC_LAND); if (player.searchLibrary(target, source, game)) { if (!target.getTargets().isEmpty()) { - player.moveCards(new CardsImpl(target.getTargets()), Zone.BATTLEFIELD, source, game); + toBattlefield.addAll(new CardsImpl(target.getTargets()).getCards(game)); } } + } + } + // must happen simultaneously Rule 101.4 + controller.moveCards(toBattlefield, Zone.BATTLEFIELD, source, game, false, false, true, null); + + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { + Player player = game.getPlayer(playerId); + if (player != null) { player.shuffleLibrary(source, game); } } diff --git a/Mage.Sets/src/mage/cards/c/CollectiveVoyage.java b/Mage.Sets/src/mage/cards/c/CollectiveVoyage.java index 23fa5b20c97..e7712f6ac7a 100644 --- a/Mage.Sets/src/mage/cards/c/CollectiveVoyage.java +++ b/Mage.Sets/src/mage/cards/c/CollectiveVoyage.java @@ -1,5 +1,6 @@ package mage.cards.c; +import java.util.HashSet; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl; @@ -15,7 +16,9 @@ import mage.target.common.TargetCardInLibrary; import mage.util.ManaUtil; import java.util.Objects; +import java.util.Set; import java.util.UUID; +import mage.cards.Card; /** * @author LevelX2 @@ -58,6 +61,7 @@ class CollectiveVoyageEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); + Set toBattlefield = new HashSet<>(); if (controller != null) { int xSum = 0; xSum += ManaUtil.playerPaysXGenericMana(false, "Collective Voyage", controller, source, game); @@ -74,10 +78,17 @@ class CollectiveVoyageEffect extends OneShotEffect { if (player != null) { TargetCardInLibrary target = new TargetCardInLibrary(0, xSum, StaticFilters.FILTER_CARD_BASIC_LAND); if (player.searchLibrary(target, source, game)) { - player.moveCards(new CardsImpl(target.getTargets()).getCards(game), Zone.BATTLEFIELD, source, game, true, false, true, null); - player.shuffleLibrary(source, game); + toBattlefield.addAll(new CardsImpl(target.getTargets()).getCards(game)); } + } + } + // must happen simultaneously Rule 101.4 + controller.moveCards(toBattlefield, Zone.BATTLEFIELD, source, game, true, false, true, null); + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { + Player player = game.getPlayer(playerId); + if (player != null) { + player.shuffleLibrary(source, game); } } // prevent undo diff --git a/Mage.Sets/src/mage/cards/c/CryptChampion.java b/Mage.Sets/src/mage/cards/c/CryptChampion.java index 444315cb7a7..abd95a53c4d 100644 --- a/Mage.Sets/src/mage/cards/c/CryptChampion.java +++ b/Mage.Sets/src/mage/cards/c/CryptChampion.java @@ -1,6 +1,7 @@ - package mage.cards.c; +import java.util.HashSet; +import java.util.Set; import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; @@ -35,7 +36,7 @@ import mage.watchers.common.ManaSpentToCastWatcher; public final class CryptChampion extends CardImpl { public CryptChampion(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{B}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{B}"); this.subtype.add(SubType.ZOMBIE); this.power = new MageInt(2); @@ -80,6 +81,7 @@ class CryptChampionEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); + Set toBattlefield = new HashSet<>(); if (controller != null) { for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); @@ -88,15 +90,20 @@ class CryptChampionEffect extends OneShotEffect { filter.add(new OwnerIdPredicate(playerId)); filter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, 4)); Target target = new TargetCardInGraveyard(filter); - if (target.canChoose(playerId, game) && player.chooseTarget(outcome, target, source, game)) { + if (target.canChoose(playerId, game) + && player.chooseTarget(outcome, target, source, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { - player.moveCards(card, Zone.BATTLEFIELD, source, game); + toBattlefield.add(card); } } } } + + // must happen simultaneously Rule 101.4 + controller.moveCards(toBattlefield, Zone.BATTLEFIELD, source, game, false, false, true, null); return true; + } return false; } diff --git a/Mage.Sets/src/mage/cards/v/VeteranExplorer.java b/Mage.Sets/src/mage/cards/v/VeteranExplorer.java index a77af3879e4..ff766b3722b 100644 --- a/Mage.Sets/src/mage/cards/v/VeteranExplorer.java +++ b/Mage.Sets/src/mage/cards/v/VeteranExplorer.java @@ -1,13 +1,15 @@ - package mage.cards.v; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.DiesSourceTriggeredAbility; import mage.abilities.effects.OneShotEffect; +import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.cards.CardsImpl; @@ -68,35 +70,44 @@ class VeteranExplorerEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); + Set toBattlefield = new HashSet<>(); + List usingPlayers = new ArrayList<>(); if (controller != null) { - List usingPlayers = new ArrayList<>(); - this.chooseAndSearchLibrary(usingPlayers, controller, source, game); + toBattlefield.addAll(this.chooseAndSearchLibrary(usingPlayers, controller, source, game)); for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { - if (!playerId.equals(controller.getId())) { - Player player = game.getPlayer(playerId); - if (player != null) { - this.chooseAndSearchLibrary(usingPlayers, player, source, game); - } + Player player = game.getPlayer(playerId); + if (player != null + && !player.equals(controller)) { + toBattlefield.addAll(this.chooseAndSearchLibrary(usingPlayers, player, source, game)); } } + + // must happen simultaneously Rule 101.4 + controller.moveCards(toBattlefield, Zone.BATTLEFIELD, source, game, false, false, true, null); + + // only those players that searched can shuffle for (Player player : usingPlayers) { - player.shuffleLibrary(source, game); + if (player != null) { + player.shuffleLibrary(source, game); + } } return true; } return false; } - private void chooseAndSearchLibrary(List usingPlayers, Player player, Ability source, Game game) { + private Set chooseAndSearchLibrary(List usingPlayers, Player player, Ability source, Game game) { + Set toBattlefield = new HashSet<>(); if (player.chooseUse(Outcome.PutCardInPlay, "Search your library for up to two basic land cards and put them onto the battlefield?", source, game)) { usingPlayers.add(player); TargetCardInLibrary target = new TargetCardInLibrary(0, 2, StaticFilters.FILTER_CARD_BASIC_LAND); if (player.searchLibrary(target, source, game)) { if (!target.getTargets().isEmpty()) { - player.moveCards(new CardsImpl(target.getTargets()), Zone.BATTLEFIELD, source, game); + toBattlefield.addAll(new CardsImpl(target.getTargets()).getCards(game)); } } } + return toBattlefield; } }