From 53f68197aaade5d788de5163a3fe72cc08417c85 Mon Sep 17 00:00:00 2001 From: Colin Redman Date: Sat, 4 Aug 2018 16:34:30 -0600 Subject: [PATCH] Changed to stream, and removed prompt when there is only a single type --- .../src/mage/cards/a/AminatousAugury.java | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/Mage.Sets/src/mage/cards/a/AminatousAugury.java b/Mage.Sets/src/mage/cards/a/AminatousAugury.java index fa946ad612..b4297c4940 100644 --- a/Mage.Sets/src/mage/cards/a/AminatousAugury.java +++ b/Mage.Sets/src/mage/cards/a/AminatousAugury.java @@ -18,7 +18,9 @@ import mage.players.Player; import mage.target.TargetCard; import mage.target.targetpointer.FixedTarget; +import java.util.Arrays; import java.util.EnumSet; +import java.util.Optional; import java.util.UUID; /** @@ -219,18 +221,24 @@ class ConsumeCardTypeCost extends CostImpl{ if (isPaid()){ return true; } - Choice choice = new CardTypeChoice(exileHandler.availableTypes(types)); - if (!game.getPlayer(controllerId).choose(Outcome.Neutral, choice, game)) { - return false; - } - CardType choiceType = null; - for (CardType type:EnumSet.allOf(CardType.class)){ - if (type.toString().equals(choice.getChoice())){ - choiceType = type; - break; - } + CardType choiceType; + EnumSet availableChoices = exileHandler.availableTypes(types); + if (availableChoices.size()==1){ + // if there is only one possibility, don't need to prompt for a choice + choiceType = availableChoices.iterator().next(); + }else { + Choice choice = new CardTypeChoice(availableChoices); + if (!game.getPlayer(controllerId).choose(Outcome.Neutral, choice, game)) { + return false; } - paid = exileHandler.useCardType(choiceType); + Optional optionalChoice = Arrays.stream(CardType.values()).filter(type -> type.toString().equals(choice.getChoice())).findAny(); + if (optionalChoice.isPresent()){ + choiceType = optionalChoice.get(); + }else{ + return false; + } + } + paid = exileHandler.useCardType(choiceType); return paid; }