* Winds of Abandon - fixed not working ability;

This commit is contained in:
Oleg Agafonov 2019-06-07 18:28:05 +04:00
parent 1c41f6418d
commit fa973d9a90

View file

@ -4,7 +4,10 @@ import mage.abilities.Ability;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.OverloadAbility; import mage.abilities.keyword.OverloadAbility;
import mage.cards.*; import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.CardsImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.TargetController; import mage.constants.TargetController;
@ -20,6 +23,7 @@ import mage.target.TargetPermanent;
import mage.target.common.TargetCardInLibrary; import mage.target.common.TargetCardInLibrary;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
@ -78,7 +82,10 @@ class WindsOfAbandonEffect extends OneShotEffect {
} }
Player player = game.getPlayer(permanent.getControllerId()); Player player = game.getPlayer(permanent.getControllerId());
// if the zone change to exile gets replaced does not prevent the target controller to be able to search // if the zone change to exile gets replaced does not prevent the target controller to be able to search
controller.moveCardToExileWithInfo(permanent, null, "", source.getSourceId(), game, Zone.BATTLEFIELD, true); if (!controller.moveCards(permanent, Zone.EXILED, source, game)) {
return true;
}
if (!player.chooseUse(Outcome.PutCardInPlay, "Search your library for a basic land card?", source, game)) { if (!player.chooseUse(Outcome.PutCardInPlay, "Search your library for a basic land card?", source, game)) {
return true; return true;
} }
@ -86,7 +93,7 @@ class WindsOfAbandonEffect extends OneShotEffect {
if (player.searchLibrary(target, source, game)) { if (player.searchLibrary(target, source, game)) {
Card card = player.getLibrary().getCard(target.getFirstTarget(), game); Card card = player.getLibrary().getCard(target.getFirstTarget(), game);
if (card != null) { if (card != null) {
player.moveCards(card, Zone.EXILED, source, game, true, false, false, null); player.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null);
} }
} }
player.shuffleLibrary(source, game); player.shuffleLibrary(source, game);
@ -124,14 +131,17 @@ class WindsOfAbandonOverloadEffect extends OneShotEffect {
if (controller == null) { if (controller == null) {
return false; return false;
} }
Map<UUID, Integer> playerMap = new HashMap(); Map<UUID, Integer> playerMap = new HashMap<>();
Cards cards = new CardsImpl(); CardsImpl cards = new CardsImpl();
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
int count = playerMap.getOrDefault(permanent.getControllerId(), 0); int count = playerMap.getOrDefault(permanent.getControllerId(), 0);
playerMap.put(permanent.getControllerId(), count + 1); playerMap.put(permanent.getControllerId(), count + 1);
cards.add(permanent); cards.add(permanent);
} }
controller.moveCards(cards, Zone.EXILED, source, game); if (!controller.moveCards(cards, Zone.EXILED, source, game)) {
return true;
}
for (UUID playerId : game.getOpponents(source.getControllerId())) { for (UUID playerId : game.getOpponents(source.getControllerId())) {
Player player = game.getPlayer(playerId); Player player = game.getPlayer(playerId);
int count = playerMap.getOrDefault(playerId, 0); int count = playerMap.getOrDefault(playerId, 0);
@ -139,14 +149,22 @@ class WindsOfAbandonOverloadEffect extends OneShotEffect {
continue; continue;
} }
TargetCardInLibrary target = new TargetCardInLibrary(0, count, StaticFilters.FILTER_CARD_BASIC_LAND); TargetCardInLibrary target = new TargetCardInLibrary(0, count, StaticFilters.FILTER_CARD_BASIC_LAND);
boolean moved = false;
if (player.searchLibrary(target, source, game)) { if (player.searchLibrary(target, source, game)) {
Card card = player.getLibrary().getCard(target.getFirstTarget(), game); List<UUID> targets = target.getTargets();
for (UUID targetId : targets) {
Card card = player.getLibrary().getCard(targetId, game);
if (card != null) { if (card != null) {
player.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null); if (player.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null)) {
moved = true;
} }
} }
}
}
if (moved) {
player.shuffleLibrary(source, game); player.shuffleLibrary(source, game);
} }
}
return true; return true;
} }
} }