mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 21:12:04 -08:00
Merge pull request #3774 from ingmargoudt/master
fixing choosing creature types
This commit is contained in:
commit
2192a517ce
15 changed files with 55 additions and 81 deletions
|
|
@ -39,6 +39,7 @@ import mage.game.permanent.Permanent;
|
|||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
|
@ -65,7 +66,7 @@ public class ChooseCreatureTypeEffect extends OneShotEffect {
|
|||
if (controller != null && mageObject != null) {
|
||||
Choice typeChoice = new ChoiceImpl(true);
|
||||
typeChoice.setMessage("Choose creature type");
|
||||
typeChoice.setChoices(SubType.getCreatureTypes(false).stream().map(SubType::toString).collect(Collectors.toSet()));
|
||||
typeChoice.setChoices(SubType.getCreatureTypes(false).stream().map(SubType::toString).collect(Collectors.toCollection(LinkedHashSet::new)));
|
||||
while (!controller.choose(outcome, typeChoice, game)) {
|
||||
if (!controller.canRespond()) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -6,16 +6,13 @@ import mage.abilities.effects.Effect;
|
|||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.choices.Choice;
|
||||
import mage.choices.ChoiceImpl;
|
||||
import mage.choices.ChoiceCreatureType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
import mage.util.SubTypeList;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class BecomesChosenCreatureTypeTargetEffect extends OneShotEffect {
|
||||
|
||||
|
|
@ -48,17 +45,15 @@ public class BecomesChosenCreatureTypeTargetEffect extends OneShotEffect {
|
|||
Card card = game.getCard(source.getSourceId());
|
||||
String chosenType = "";
|
||||
if (player != null && card != null) {
|
||||
Choice typeChoice = new ChoiceImpl(true);
|
||||
Choice typeChoice = new ChoiceCreatureType();
|
||||
String msg = "Choose a creature type";
|
||||
if(nonWall) {
|
||||
msg += " other than Wall";
|
||||
}
|
||||
typeChoice.setMessage(msg);
|
||||
SubTypeList types = SubType.getCreatureTypes(false);
|
||||
if(nonWall) {
|
||||
types.remove(SubType.WALL);
|
||||
typeChoice.getChoices().remove(SubType.WALL.getDescription());
|
||||
}
|
||||
typeChoice.setChoices(types.stream().map(SubType::toString).collect(Collectors.toSet()));
|
||||
while (!player.choose(Outcome.BoostCreature, typeChoice, game)) {
|
||||
if (!player.canRespond()) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -2,13 +2,14 @@ package mage.choices;
|
|||
|
||||
import mage.constants.SubType;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ChoiceCreatureType extends ChoiceImpl {
|
||||
|
||||
public ChoiceCreatureType() {
|
||||
super(true);
|
||||
this.setChoices(SubType.getCreatureTypes(false).stream().map(SubType::toString).collect(Collectors.toSet()));
|
||||
this.setChoices(SubType.getCreatureTypes(false).stream().map(SubType::toString).collect(Collectors.toCollection(LinkedHashSet::new)));
|
||||
this.message = "Choose a creature type:";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package mage.constants;
|
|||
import mage.util.SubTypeList;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
|
@ -418,10 +419,10 @@ public enum SubType {
|
|||
return subTypeSet;
|
||||
}
|
||||
|
||||
public static SubTypeList getCreatureTypes(boolean customSet) {
|
||||
SubTypeList subTypes = new SubTypeList();
|
||||
public static Set<SubType> getCreatureTypes(boolean customSet) {
|
||||
Set<SubType> subTypes = EnumSet.noneOf(SubType.class);
|
||||
for (SubType s : values()) {
|
||||
if (!s.customSet) {
|
||||
if (s.customSet == customSet && s.getSubTypeSet() == SubTypeSet.CreatureType) {
|
||||
subTypes.add(s);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue