This commit is contained in:
Jeff 2019-03-22 15:29:47 -05:00
parent 270ec615af
commit f7557d76f4

View file

@ -1,4 +1,3 @@
package mage.cards.n;
import java.util.HashMap;
@ -91,36 +90,33 @@ class NicolBolasGodPharaohPlusOneEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Boolean applied = false;
// Store for each player the cards to exile, that's important because all exile shall happen at the same time
Map<UUID, Cards> cardsToExile = new HashMap<>();
// Each player chooses 2 cards to discard
for (UUID playerId : game.getOpponents(source.getControllerId())) {
Player player = game.getPlayer(playerId);
if (player == null) {
continue;
for (UUID opponentId : game.getOpponents(source.getControllerId())) {
Player opponent = game.getPlayer(opponentId);
if (opponent != null) {
int numberOfCardsToExile = Math.min(2, opponent.getHand().size());
Target target = new TargetCardInHand(numberOfCardsToExile, new FilterCard());
target.setRequired(true);
if (opponent.chooseTarget(Outcome.Exile, target, source, game)) {
Cards cards = new CardsImpl(target.getTargets());
cardsToExile.put(opponentId, cards);
}
}
int numberOfCardsToExile = Math.min(2, player.getHand().size());
Target target = new TargetCardInHand(numberOfCardsToExile, new FilterCard());
Cards cards = new CardsImpl(target.getTargets());
player.chooseTarget(Outcome.Exile, target, source, game);
cardsToExile.put(playerId, cards);
}
// Exile all choosen cards
for (UUID playerId : game.getOpponents(source.getControllerId())) {
Player player = game.getPlayer(playerId);
if (player == null) {
continue;
// Exile all chosen cards at the same time
Cards cardsOpponentsChoseToExile = new CardsImpl();
for (UUID opponentId : game.getOpponents(source.getControllerId())) {
Player opponent = game.getPlayer(opponentId);
if (opponent != null) {
cardsOpponentsChoseToExile.addAll(cardsToExile.get(opponentId));
opponent.moveCards(cardsOpponentsChoseToExile, Zone.EXILED, source, game);
applied = true;
}
Cards cardsPlayerChoseToExile = cardsToExile.get(playerId);
if (cardsPlayerChoseToExile == null) {
continue;
}
player.moveCards(cardsPlayerChoseToExile.getCards(game), Zone.EXILED, source, game);
}
return true;
return applied;
}
}
@ -128,7 +124,9 @@ class NicolBolasGodPharaohPlusTwoEffect extends OneShotEffect {
public NicolBolasGodPharaohPlusTwoEffect() {
super(Outcome.Detriment);
this.staticText = "Target opponent exiles cards from the top of their library until he or she exiles a nonland card. Until end of turn, you may cast that card without paying its mana cost";
this.staticText = "Target opponent exiles cards from the top of their "
+ "library until he or she exiles a nonland card. Until end of turn, "
+ "you may cast that card without paying its mana cost";
}
public NicolBolasGodPharaohPlusTwoEffect(final NicolBolasGodPharaohPlusTwoEffect effect) {
@ -152,12 +150,14 @@ class NicolBolasGodPharaohPlusTwoEffect extends OneShotEffect {
opponent.moveCards(card, Zone.EXILED, source, game);
if (!card.isLand()) {
ContinuousEffect effect = new NicolBolasGodPharaohFromExileEffect();
effect.setTargetPointer(new FixedTarget(card.getId(), game.getState().getZoneChangeCounter(card.getId())));
effect.setTargetPointer(new FixedTarget(card.getId(),
game.getState().getZoneChangeCounter(card.getId())));
game.addEffect(effect, source);
break;
}
}
} while (library.hasCards() && card != null);
} while (library.hasCards()
&& card != null);
return true;
}
return false;
@ -187,13 +187,18 @@ class NicolBolasGodPharaohFromExileEffect extends AsThoughEffectImpl {
@Override
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
if (sourceId != null && sourceId.equals(getTargetPointer().getFirst(game, source))
if (sourceId != null
&& sourceId.equals(getTargetPointer().getFirst(game, source))
&& affectedControllerId.equals(source.getControllerId())) {
Card card = game.getCard(sourceId);
if (card != null && game.getState().getZone(sourceId) == Zone.EXILED) {
Player player = game.getPlayer(affectedControllerId);
if(player != null) {
player.setCastSourceIdWithAlternateMana(sourceId, null, card.getSpellAbility().getCosts());
if (card != null
&& game.getState().getZone(sourceId) == Zone.EXILED) {
Player controller = game.getPlayer(affectedControllerId);
if (controller != null) {
controller.setCastSourceIdWithAlternateMana(
sourceId,
null,
card.getSpellAbility().getCosts());
return true;
}
}