* Aminatous Augury - Fixed a problem that the cards could not be cast from exile. Added logic so the player could select the card types to consume for the cast from exile.

This commit is contained in:
LevelX2 2019-12-29 16:22:52 +01:00
parent 8710bb5ca2
commit 2508de1f82
3 changed files with 64 additions and 29 deletions

View file

@ -1,12 +1,25 @@
package mage.cards.a; package mage.cards.a;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.Iterator;
import java.util.Set;
import java.util.UUID;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.AsThoughEffectImpl; import mage.abilities.effects.AsThoughEffectImpl;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.cards.*; import mage.cards.Card;
import mage.constants.*; import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.choices.Choice;
import mage.choices.ChoiceImpl;
import mage.constants.AsThoughEffectType;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.StaticFilters; import mage.filter.StaticFilters;
import mage.game.ExileZone; import mage.game.ExileZone;
import mage.game.Game; import mage.game.Game;
@ -14,9 +27,6 @@ import mage.players.Player;
import mage.target.TargetCard; import mage.target.TargetCard;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTarget;
import mage.util.CardUtil; import mage.util.CardUtil;
import java.util.UUID;
import mage.choices.Choice;
import mage.choices.ChoiceImpl;
/** /**
* *
@ -81,12 +91,14 @@ class AminatousAuguryEffect extends OneShotEffect {
Zone.EXILED, Zone.EXILED,
StaticFilters.FILTER_CARD_LAND_A StaticFilters.FILTER_CARD_LAND_A
); );
if (controller.chooseUse(Outcome.PutLandInPlay, "Put a land from among the exiled cards into play?", source, game)) { if (cardsToCast.count(StaticFilters.FILTER_CARD_LAND, game) > 0) {
if (controller.choose(Outcome.PutLandInPlay, cardsToCast, target, game)) { if (controller.chooseUse(Outcome.PutLandInPlay, "Put a land from among the exiled cards into play?", source, game)) {
Card card = cardsToCast.get(target.getFirstTarget(), game); if (controller.choose(Outcome.PutLandInPlay, cardsToCast, target, game)) {
if (card != null) { Card card = cardsToCast.get(target.getFirstTarget(), game);
cardsToCast.remove(card); if (card != null) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game, false, false, true, null); cardsToCast.remove(card);
controller.moveCards(card, Zone.BATTLEFIELD, source, game, false, false, true, null);
}
} }
} }
} }
@ -124,12 +136,12 @@ class AminatousAuguryCastFromExileEffect extends AsThoughEffectImpl {
@Override @Override
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) { public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
Player player = game.getPlayer(affectedControllerId); Player player = game.getPlayer(affectedControllerId);
EnumSet<CardType> cardTypes = EnumSet.noneOf(CardType.class); EnumSet<CardType> usedCardTypes = EnumSet.noneOf(CardType.class);
Boolean checkType = false;
if (game.getState().getValue(source.getSourceId().toString() + "cardTypes") != null) { if (game.getState().getValue(source.getSourceId().toString() + "cardTypes") != null) {
cardTypes = (EnumSet<CardType>) game.getState().getValue(source.getSourceId().toString() + "cardTypes"); usedCardTypes = (EnumSet<CardType>) game.getState().getValue(source.getSourceId().toString() + "cardTypes");
} }
//TODO add code for choosing from multiple card types and adding additional costs to the card //TODO add code for adding additional costs to the card
if (player != null if (player != null
&& sourceId != null && sourceId != null
&& sourceId.equals(getTargetPointer().getFirst(game, source)) && sourceId.equals(getTargetPointer().getFirst(game, source))
@ -137,15 +149,38 @@ class AminatousAuguryCastFromExileEffect extends AsThoughEffectImpl {
Card card = game.getCard(sourceId); Card card = game.getCard(sourceId);
if (card != null if (card != null
&& game.getState().getZone(sourceId) == Zone.EXILED) { && game.getState().getZone(sourceId) == Zone.EXILED) {
for (CardType cardT : cardTypes) { EnumSet<CardType> unusedCardTypes = EnumSet.noneOf(CardType.class);
if (card.getCardType().contains(cardT)) { for (CardType cardT : card.getCardType()) {
checkType = true; if (!usedCardTypes.contains(cardT)) {
unusedCardTypes.add(cardT);
} }
} }
if (!checkType) { if (!unusedCardTypes.isEmpty()) {
player.setCastSourceIdWithAlternateMana(sourceId, null, null); if (!game.inCheckPlayableState()) { // some actions may not be done while the game only checks if a card can be cast
cardTypes.addAll(card.getCardType()); if (!player.chooseUse(outcome, "Cast " + card.getIdName() + " without paying its mana cost?", source, game)) {
game.getState().setValue(source.getSourceId().toString() + "cardTypes", cardTypes); return false;
}
// Select the card type to consume and remove all not seleczted card types
if (unusedCardTypes.size() > 1) {
Choice choice = new ChoiceImpl(true);
choice.setMessage("Which card type do you want to consume?");
Set<String> choices = choice.getChoices();
for (CardType cardType : unusedCardTypes) {
choices.add(cardType.toString());
}
player.choose(Outcome.Detriment, choice, game);
for (Iterator<CardType> iterator = unusedCardTypes.iterator(); iterator.hasNext();) {
CardType next = iterator.next();
if (!next.toString().equals(choice.getChoice())) {
iterator.remove();
}
}
usedCardTypes.add(CardType.fromString(choice.getChoice()));
}
usedCardTypes.addAll(unusedCardTypes);
player.setCastSourceIdWithAlternateMana(sourceId, null, null);
game.getState().setValue(source.getSourceId().toString() + "cardTypes", usedCardTypes);
}
return true; return true;
} }
} }

View file

@ -1,5 +1,7 @@
package mage.cards.g; package mage.cards.g;
import java.util.Set;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility;
@ -19,9 +21,6 @@ import mage.players.Player;
import mage.target.common.TargetCardInLibrary; import mage.target.common.TargetCardInLibrary;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTarget;
import java.util.Set;
import java.util.UUID;
/** /**
* @author TheElk801 * @author TheElk801
*/ */
@ -61,8 +60,8 @@ class GolosTirelessPilgrimEffect extends OneShotEffect {
GolosTirelessPilgrimEffect() { GolosTirelessPilgrimEffect() {
super(Outcome.Discard); super(Outcome.Discard);
staticText = "Exile the top three cards of your library. " + staticText = "Exile the top three cards of your library. "
"You may play them this turn without paying their mana costs."; + "You may play them this turn without paying their mana costs.";
} }
private GolosTirelessPilgrimEffect(final GolosTirelessPilgrimEffect effect) { private GolosTirelessPilgrimEffect(final GolosTirelessPilgrimEffect effect) {

View file

@ -1,4 +1,3 @@
package mage.abilities.effects.common.search; package mage.abilities.effects.common.search;
import java.util.List; import java.util.List;
@ -87,7 +86,9 @@ public class SearchLibraryPutInPlayEffect extends SearchEffect {
} }
sb.append(target.getTargetName()).append(" and put them onto the battlefield"); sb.append(target.getTargetName()).append(" and put them onto the battlefield");
} else { } else {
sb.append("a ").append(target.getTargetName()).append(" and put it onto the battlefield"); sb.append(target.getTargetName().startsWith("a ") || target.getTargetName().startsWith("an ") ? "" : sb.append("a "))
.append(target.getTargetName())
.append(" and put it onto the battlefield");
} }
if (tapped) { if (tapped) {
sb.append(" tapped"); sb.append(" tapped");