diff --git a/forge-game/src/main/java/forge/game/ability/effects/DigEffect.java b/forge-game/src/main/java/forge/game/ability/effects/DigEffect.java index ba0633b127e..bb67a7a2c41 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/DigEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/DigEffect.java @@ -62,6 +62,7 @@ public class DigEffect extends SpellAbilityEffect { final Card host = sa.getHostCard(); final Player player = sa.getActivatingPlayer(); final Game game = player.getGame(); + final Player cont = host.getController(); Player chooser = player; int numToDig = AbilityUtils.calculateAmount(host, sa.getParam("DigNum"), sa); @@ -105,6 +106,8 @@ public class DigEffect extends SpellAbilityEffect { boolean changeAll = false; boolean allButOne = false; + boolean totalCMC = (sa.hasParam("WithTotalCMC")); + int totcmc = AbilityUtils.calculateAmount(host, sa.getParam("WithTotalCMC"), sa); if (sa.hasParam("ChangeNum")) { if (sa.getParam("ChangeNum").equalsIgnoreCase("All")) { @@ -156,9 +159,9 @@ public class DigEffect extends SpellAbilityEffect { } else if (sa.hasParam("RevealValid")) { final String revealValid = sa.getParam("RevealValid"); - final CardCollection toReveal = CardLists.getValidCards(top, revealValid, host.getController(), host, sa); + final CardCollection toReveal = CardLists.getValidCards(top, revealValid, cont, host, sa); if (!toReveal.isEmpty()) { - game.getAction().reveal(toReveal, host.getController()); + game.getAction().reveal(toReveal, cont); if (sa.hasParam("RememberRevealed")) { for (final Card one : toReveal) { host.addRemembered(one); @@ -197,14 +200,17 @@ public class DigEffect extends SpellAbilityEffect { CardCollection valid; if (mitosis) { valid = sharesNameWithCardOnBattlefield(game, top); - } - else if (!changeValid.isEmpty()) { + } else if (!changeValid.isEmpty()) { if (changeValid.contains("ChosenType")) { changeValid = changeValid.replace("ChosenType", host.getChosenType()); } - valid = CardLists.getValidCards(top, changeValid.split(","), host.getController(), host, sa); - } - else { + valid = CardLists.getValidCards(top, changeValid.split(","), cont, host, sa); + if (totalCMC) { + valid = CardLists.getValidCards(valid, "Card.cmcLE" + totcmc, cont, host, sa); + } + } else if (totalCMC) { + valid = CardLists.getValidCards(top, "Card.cmcLE" + totcmc, cont, host, sa); + } else { // If all the cards are valid choices, no need for a separate reveal dialog to the chooser. pfps?? if (p == chooser && destZone1ChangeNum > 1) { delayedReveal = null; @@ -228,19 +234,49 @@ public class DigEffect extends SpellAbilityEffect { if (changeAll) { movedCards = new CardCollection(valid); - } - else if (sa.hasParam("RandomChange")) { + } else if (sa.hasParam("RandomChange")) { int numChanging = Math.min(destZone1ChangeNum, valid.size()); movedCards = CardLists.getRandomSubList(valid, numChanging); - } - else if (sa.hasParam("ForEachColorPair")) { + } else if (sa.hasParam("WithTotalCMC")) { + movedCards = new CardCollection(); + if (p == chooser) { + chooser.getController().tempShowCards(top); + } + if (valid.isEmpty()) { + chooser.getController().notifyOfValue(sa, null, + Localizer.getInstance().getMessage("lblNoValidCards")); + } + boolean opt = false; + if (anyNumber) { + opt = true; + } + while (!valid.isEmpty()) { + Card chosen = chooser.getController().chooseSingleEntityForEffect(valid, delayedReveal, sa, + Localizer.getInstance().getMessage("lblChooseOne"), opt, p, null); + if (chosen != null) { + movedCards.add(chosen); + valid.remove(chosen); + totcmc = totcmc - chosen.getCMC(); + valid = CardLists.getValidCards(valid, "Card.cmcLE" + totcmc, cont, host, sa); + } else { //if they can and did choose nothing, we're done here + break; + } + } + chooser.getController().endTempShowCards(); + if (!movedCards.isEmpty()) { + game.getAction().reveal(movedCards, chooser, true, + Localizer.getInstance().getMessage("lblPlayerPickedChosen", + chooser.getName(), "")); + } + } else if (sa.hasParam("ForEachColorPair")) { movedCards = new CardCollection(); if (p == chooser) { chooser.getController().tempShowCards(top); } for (final byte pair : MagicColor.COLORPAIR) { - Card chosen = chooser.getController().chooseSingleEntityForEffect(CardLists.filter(valid, CardPredicates.isExactlyColor(pair)), - delayedReveal, sa, Localizer.getInstance().getMessage("lblChooseOne"), false, p, null); + Card chosen = chooser.getController().chooseSingleEntityForEffect(CardLists.filter(valid, + CardPredicates.isExactlyColor(pair)), delayedReveal, sa, + Localizer.getInstance().getMessage("lblChooseOne"), false, p, null); if (chosen != null) { movedCards.add(chosen); } @@ -249,14 +285,12 @@ public class DigEffect extends SpellAbilityEffect { if (!movedCards.isEmpty()) { game.getAction().reveal(movedCards, chooser, true, Localizer.getInstance().getMessage("lblPlayerPickedChosen", chooser.getName(), "")); } - } - else if (allButOne) { + } else if (allButOne) { movedCards = new CardCollection(valid); String prompt; if (destZone2.equals(ZoneType.Library) && libraryPosition2 == 0) { prompt = Localizer.getInstance().getMessage("lblChooseACardToLeaveTargetLibraryTop", p.getName()); - } - else { + } else { prompt = Localizer.getInstance().getMessage("lblChooseACardLeaveTarget", p.getName(), destZone2.getTranslatedName()); } diff --git a/forge-gui/res/cardsfolder/upcoming/ao_the_dawn_sky.txt b/forge-gui/res/cardsfolder/upcoming/ao_the_dawn_sky.txt new file mode 100644 index 00000000000..e2371524ca3 --- /dev/null +++ b/forge-gui/res/cardsfolder/upcoming/ao_the_dawn_sky.txt @@ -0,0 +1,12 @@ +Name:Ao, the Dawn Sky +ManaCost:3 W W +Types:Legendary Creature Dragon Spirit +PT:5/4 +K:Flying +K:Vigilance +T:Mode$ ChangesZone | Origin$ Battlefield | Destination$ Graveyard | ValidCard$ Card.Self | Execute$ TrigCharm | TriggerDescription$ When CARDNAME dies, ABILITY +SVar:TrigCharm:DB$ Charm | Choices$ TrigDig,TrigPutCounterAll +SVar:TrigDig:DB$ Dig | DigNum$ 7 | WithTotalCMC$ 4 | AnyNumber$ True | ChangeValid$ Card.Permanent+nonLand | DestinationZone$ Battlefield | DestinationZone2$ Library | RestRandomOrder$ True | SpellDescription$ Look at the top seven cards of your library. Put any number of nonland permanent cards with total mana value 4 or less from among them onto the battlefield. Put the rest on the bottom of your library in a a random order. +SVar:TrigPutCounterAll:DB$ PutCounterAll | ValidCards$ Creature.YouCtrl,Vehicle.YouCtrl | CounterType$ P1P1 | CounterNum$ 2 | SpellDescription$ Put two +1/+1 counters on each permanent you control that's a creature or a Vehicle. +DeckHints:Type$Creature|Vehicle +Oracle:Flying, vigilance\nWhen Ao, the Dawn Sky dies, choose one —\n• Look at the top seven cards of your library. Put any number of nonland permanent cards with total mana value 4 or less from among them onto the battlefield. Put the rest on the bottom of your library in a a random order.\n• Put two +1/+1 counters on each permanent you control that's a creature or a Vehicle.