diff --git a/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java index 13a3c0697f7..2896cb0ada7 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java @@ -4,7 +4,6 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; - import forge.card.CardStateName; import forge.card.CardType; import forge.game.*; @@ -27,7 +26,9 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.Pair; -import java.util.*; +import java.util.Arrays; +import java.util.List; +import java.util.Map; public class ChangeZoneEffect extends SpellAbilityEffect { @@ -1085,8 +1086,10 @@ else if (origin.contains(ZoneType.Hand) && player.isOpponentOf(decider)) { String selectPrompt = sa.hasParam("SelectPrompt") ? sa.getParam("SelectPrompt") : MessageUtil.formatMessage(Localizer.getInstance().getMessage("lblSelectCardFromPlayerZone", "{player's}", Lang.joinHomogenous(origin, ZoneType::getTranslatedName).toLowerCase()), decider, player); final String totalcmc = sa.getParam("WithTotalCMC"); final String totalpower = sa.getParam("WithTotalPower"); + final String totalCardTypes = sa.getParam("WithTotalCardTypes"); int totcmc = AbilityUtils.calculateAmount(source, totalcmc, sa); int totpower = AbilityUtils.calculateAmount(source, totalpower, sa); + int totCardTypes = AbilityUtils.calculateAmount(source, totalCardTypes, sa); CardCollection chosenCards = new CardCollection(); if (changeType.startsWith("EACH")) { @@ -1160,6 +1163,7 @@ else if (origin.contains(ZoneType.Hand) && player.isOpponentOf(decider)) { } } + // If we're choosing multiple cards, only need to show the reveal dialog the first time through. boolean shouldReveal = (i == 0); Card c = null; @@ -1170,6 +1174,10 @@ else if (origin.contains(ZoneType.Hand) && player.isOpponentOf(decider)) { c = Aggregates.random(fetchList); } else if (defined && !chooseFromDef) { c = Iterables.getFirst(fetchList, null); + } else if (totalCardTypes != null) { + String title = selectPrompt; + title += "\nCard types left: " + Math.max(totCardTypes, 0); + c = decider.getController().chooseSingleCardForZoneChange(destination, origin, sa, fetchList, shouldReveal ? delayedReveal : null, title, !mandatory, decider); } else { String title = selectPrompt; if (changeNum > 1) { //indicate progress if multiple cards being chosen @@ -1202,6 +1210,13 @@ else if (origin.contains(ZoneType.Hand) && player.isOpponentOf(decider)) { if (totalpower != null) { totpower -= c.getCurrentPower(); } + if (totalCardTypes != null) { + totCardTypes -= Iterables.size(c.getType().getCoreTypes()); + } + } + + if (totalCardTypes != null && totCardTypes > 0) { + chosenCards.clear(); } } @@ -1537,7 +1552,8 @@ private static boolean allowMultiSelect(Player decider, SpellAbility sa) { && !sa.hasParam("AtRandom") && (!sa.hasParam("Defined") || sa.hasParam("ChooseFromDefined")) && !sa.hasParam("WithTotalCMC") - && !sa.hasParam("WithTotalPower"); + && !sa.hasParam("WithTotalPower") + && !sa.hasParam("WithTotalCardTypes"); } /** diff --git a/forge-gui/res/cardsfolder/w/winter_cynical_opportunist.txt b/forge-gui/res/cardsfolder/w/winter_cynical_opportunist.txt new file mode 100644 index 00000000000..99abeaf440f --- /dev/null +++ b/forge-gui/res/cardsfolder/w/winter_cynical_opportunist.txt @@ -0,0 +1,14 @@ +Name:Winter, Cynical Opportunist +ManaCost:2 B G +Types:Legendary Creature Human Warlock +PT:2/5 +K:Deathtouch +T:Mode$ Attacks | ValidCard$ Card.Self | Execute$ TrigMill | TriggerDescription$ Whenever NICKNAME attacks, mill three cards. +SVar:TrigMill:DB$ Mill | NumCards$ 3 +T:Mode$ Phase | Phase$ End of Turn | ValidPlayer$ You | Delirium$ True | TriggerZones$ Battlefield | Execute$ TrigExileDelirium | TriggerDescription$ Delirium — At the beginning of your end step, you may exile any number of cards from your graveyard with four or more card types among them. If you do, put a permanent card from among them onto the battlefield with a finality counter on it. +SVar:TrigExileDelirium:DB$ ChangeZone | Origin$ Graveyard | Destination$ Exile | ChangeType$ Card.YouOwn | ChangeNum$ X | RememberChanged$ True | Hidden$ True | WithTotalCardTypes$ 4 | SubAbility$ DBReturn +SVar:DBReturn:DB$ ChangeZone | Origin$ Exile | Destination$ Battlefield | WithCountersType$ FINALITY | Hidden$ True | ChangeType$ Permanent.YouOwn+IsRemembered | ChangeNum$ 1 | SubAbility$ DBCleanup | Mandatory$ True +SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True +SVar:X:Count$ValidGraveyard Card.YouOwn +AI:RemoveDeck:All +Oracle:Deathtouch\nWhenever Winter attacks, mill three cards.\nDelirium — At the beginning of your end step, you may exile any number of cards from your graveyard with four or more card types among them. If you do, put a permanent card from among them onto the battlefield with a finality counter on it.