mirror of
https://github.com/correl/mage.git
synced 2024-12-26 19:16:54 +00:00
Changed to stream, and removed prompt when there is only a single type
This commit is contained in:
parent
d6b8e1240c
commit
53f68197aa
1 changed files with 19 additions and 11 deletions
|
@ -18,7 +18,9 @@ import mage.players.Player;
|
||||||
import mage.target.TargetCard;
|
import mage.target.TargetCard;
|
||||||
import mage.target.targetpointer.FixedTarget;
|
import mage.target.targetpointer.FixedTarget;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -219,18 +221,24 @@ class ConsumeCardTypeCost extends CostImpl{
|
||||||
if (isPaid()){
|
if (isPaid()){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Choice choice = new CardTypeChoice(exileHandler.availableTypes(types));
|
CardType choiceType;
|
||||||
if (!game.getPlayer(controllerId).choose(Outcome.Neutral, choice, game)) {
|
EnumSet<CardType> availableChoices = exileHandler.availableTypes(types);
|
||||||
return false;
|
if (availableChoices.size()==1){
|
||||||
}
|
// if there is only one possibility, don't need to prompt for a choice
|
||||||
CardType choiceType = null;
|
choiceType = availableChoices.iterator().next();
|
||||||
for (CardType type:EnumSet.allOf(CardType.class)){
|
}else {
|
||||||
if (type.toString().equals(choice.getChoice())){
|
Choice choice = new CardTypeChoice(availableChoices);
|
||||||
choiceType = type;
|
if (!game.getPlayer(controllerId).choose(Outcome.Neutral, choice, game)) {
|
||||||
break;
|
return false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
paid = exileHandler.useCardType(choiceType);
|
Optional<CardType> 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;
|
return paid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue