diff --git a/forge-game/src/main/java/forge/game/ability/effects/ChooseCardNameEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ChooseCardNameEffect.java index b99b686a4ed..51229e72f9e 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ChooseCardNameEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ChooseCardNameEffect.java @@ -1,5 +1,6 @@ package forge.game.ability.effects; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -62,6 +63,7 @@ public class ChooseCardNameEffect extends SpellAbilityEffect { boolean randomChoice = sa.hasParam("AtRandom"); boolean chooseFromDefined = sa.hasParam("ChooseFromDefinedCards"); + boolean chooseFromOneTimeList = sa.hasParam("ChooseFromOneTimeList"); if (!randomChoice) { if (sa.hasParam("SelectPrompt")) { @@ -100,7 +102,7 @@ public class ChooseCardNameEffect extends SpellAbilityEffect { } else if (chooseFromDefined) { CardCollection choices = AbilityUtils.getDefinedCards(host, sa.getParam("ChooseFromDefinedCards"), sa); choices = CardLists.getValidCards(choices, valid, host.getController(), host, sa); - List faces = Lists.newArrayList(); + List faces = new ArrayList<>(); // get Card for (final Card c : choices) { final CardRules rules = c.getRules(); @@ -114,6 +116,22 @@ public class ChooseCardNameEffect extends SpellAbilityEffect { } Collections.sort(faces); chosen = p.getController().chooseCardName(sa, faces, message); + } else if (chooseFromOneTimeList) { + String [] names = sa.getParam("ChooseFromOneTimeList").split(","); + List faces = new ArrayList<>(); + for (String name : names) { + faces.add(StaticData.instance().getCommonCards().getFaceByName(name)); + } + chosen = p.getController().chooseCardName(sa, faces, message); + + // Remove chosen Name from List + StringBuilder sb = new StringBuilder(); + for (String name : names) { + if (chosen.equals(name)) continue; + if (sb.length() > 0) sb.append(','); + sb.append(name); + } + sa.putParam("ChooseFromOneTimeList", sb.toString()); } else { // use CardFace because you might name a alternate names Predicate cpp = Predicates.alwaysTrue(); diff --git a/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java b/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java index 72043aa6839..090a83b34df 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java @@ -35,6 +35,7 @@ import forge.game.zone.Zone; import forge.game.zone.ZoneType; import forge.item.PaperCard; import forge.util.Aggregates; +import forge.util.CardTranslation; import forge.util.Lang; import forge.util.Localizer; @@ -93,8 +94,7 @@ public class PlayEffect extends SpellAbilityEffect { if (sa.hasParam("ShowCards")) { showCards = new CardCollection(AbilityUtils.filterListByType(game.getCardsIn(zones), sa.getParam("ShowCards"), sa)); } - } - else if (sa.hasParam("AnySupportedCard")) { + } else if (sa.hasParam("AnySupportedCard")) { final String valid = sa.getParam("AnySupportedCard"); List cards = null; if (valid.startsWith("Names:")){ @@ -139,8 +139,14 @@ public class PlayEffect extends SpellAbilityEffect { else { return; } - } - else { + } else if (sa.hasParam("CopyFromChosenName")) { + String name = source.getChosenName(); + if (name.isBlank()) return; + Card card = Card.fromPaperCard(StaticData.instance().getCommonCards().getUniqueByName(name), controller); + card.setToken(true); + tgtCards = new CardCollection(); + tgtCards.add(card); + } else { tgtCards = new CardCollection(); // filter only cards that didn't changed zones for (Card c : getTargetCards(sa)) { @@ -179,7 +185,16 @@ public class PlayEffect extends SpellAbilityEffect { while (!tgtCards.isEmpty() && amount > 0) { activator.getController().tempShowCards(showCards); - Card tgtCard = controller.getController().chooseSingleEntityForEffect(tgtCards, sa, Localizer.getInstance().getMessage("lblSelectCardToPlay"), optional, null); + Card tgtCard = null; + if (tgtCards.size() == 1 && amount == 1 && optional) { + tgtCard = tgtCards.get(0); + if (!controller.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblDoYouWantPlayCard", CardTranslation.getTranslatedName(tgtCard.getName())))) { + break; + } + } else { + tgtCard = controller.getController().chooseSingleEntityForEffect(tgtCards, sa, Localizer.getInstance().getMessage("lblSelectCardToPlay"), optional, null); + } + activator.getController().endTempShowCards(); if (tgtCard == null) { break; diff --git a/forge-gui/res/cardsfolder/upcoming/garth_one_eye.txt b/forge-gui/res/cardsfolder/upcoming/garth_one_eye.txt new file mode 100644 index 00000000000..2a615ad7e41 --- /dev/null +++ b/forge-gui/res/cardsfolder/upcoming/garth_one_eye.txt @@ -0,0 +1,8 @@ +Name:Garth One-Eye +ManaCost:W U B R G +Types:Legendary Creature Human Wizard +PT:5/5 +A:AB$ NameCard | Cost$ T | Defined$ You | ChooseFromOneTimeList$ Disenchant,Braingeyser,Terror,Shivan Dragon,Regrowth,Black Lotus | SubAbility$ DBCast | StackDescription$ SpellDescription | SpellDescription$ Choose a card name that hasn't been chosen from among Disenchant, Braingeyser, Terror, Shivan Dragon, Regrowth, and Black Lotus. Create a copy of the card with the chosen name. You may cast the copy. (You still pay its costs.) +SVar:DBCast:DB$ Play | CopyFromChosenName$ True | Optional$ True | StackDescription$ None +AI:RemoveDeck:All +Oracle:{T}: Choose a card name that hasn't been chosen from among Disenchant, Braingeyser, Terror, Shivan Dragon, Regrowth, and Black Lotus. Create a copy of the card with the chosen name. You may cast the copy. (You still pay its costs.)