From c79888c2384b1994d9a8b4c0e890b5f95b94a1af Mon Sep 17 00:00:00 2001 From: Northmoc Date: Mon, 31 Oct 2022 13:23:23 -0400 Subject: [PATCH] hurkyl_master_wizard.txt refactor --- .../ability/effects/RepeatEachEffect.java | 36 +++++++++++++++---- .../upcoming/hurkyl_master_wizard.txt | 22 ++++-------- 2 files changed, 36 insertions(+), 22 deletions(-) diff --git a/forge-game/src/main/java/forge/game/ability/effects/RepeatEachEffect.java b/forge-game/src/main/java/forge/game/ability/effects/RepeatEachEffect.java index b6ab85f4aeb..33c16955a25 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/RepeatEachEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/RepeatEachEffect.java @@ -1,22 +1,19 @@ package forge.game.ability.effects; -import java.util.Collections; -import java.util.List; +import java.util.*; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.GameCommand; +import forge.card.CardType; import forge.game.Game; import forge.game.GameEntityCounterTable; import forge.game.GameObject; import forge.game.ability.AbilityUtils; import forge.game.ability.SpellAbilityEffect; +import forge.game.card.*; import forge.game.card.Card; -import forge.game.card.CardCollectionView; -import forge.game.card.CardDamageMap; -import forge.game.card.CardLists; -import forge.game.card.CardZoneTable; import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.game.spellability.SpellAbilityStackInstance; @@ -139,6 +136,33 @@ public class RepeatEachEffect extends SpellAbilityEffect { } } + if (sa.hasParam("RepeatTypesFromDefined")) { + final String def = sa.getParam("RepeatTypesFromDefined"); + final Set validTypes = new HashSet<>(); + final List res; + if (def.startsWith("ThisTurnCast")) { + final String[] workingCopy = def.split("_"); + final String validFilter = workingCopy[1]; + res = CardUtil.getThisTurnCast(validFilter, source, sa); + } else { + res = AbilityUtils.getDefinedCards(source, def, sa); + } + for (final Card c : res) { + for (CardType.CoreType type : c.getType().getCoreTypes()) { + validTypes.add(type.name()); + } + } + + final String storedType = source.getChosenType(); + while (validTypes.size() > 0) { + String chosenT = player.getController().chooseSomeType("card", sa, validTypes, null); + source.setChosenType(chosenT); + AbilityUtils.resolve(repeat); + validTypes.remove(chosenT); + } + source.setChosenType(storedType); + } + if (sa.hasParam("RepeatPlayers")) { final FCollection repeatPlayers = AbilityUtils.getDefinedPlayers(source, sa.getParam("RepeatPlayers"), sa); if (sa.hasParam("ClearRememberedBeforeLoop")) { diff --git a/forge-gui/res/cardsfolder/upcoming/hurkyl_master_wizard.txt b/forge-gui/res/cardsfolder/upcoming/hurkyl_master_wizard.txt index e46803b1d8f..8fc9df1d0fd 100644 --- a/forge-gui/res/cardsfolder/upcoming/hurkyl_master_wizard.txt +++ b/forge-gui/res/cardsfolder/upcoming/hurkyl_master_wizard.txt @@ -1,24 +1,14 @@ Name:Hurkyl, Master Wizard ManaCost:1 U U -Types:Legendary Creature - Human Wizard Advisor +Types:Legendary Creature Human Wizard Advisor PT:2/4 T:Mode$ Phase | Phase$ End of Turn | ValidPlayer$ You | TriggerZones$ Battlefield | CheckSVar$ X | SVarCompare$ GE1 | Execute$ TrigDig | TriggerDescription$ At the beginning of your end step, if you've cast a noncreature spell this turn, reveal the top five cards of your library. For each card type among noncreature spells you've cast this turn, you may put a card of that type from among the revealed cards into your hand. Put the rest on the bottom of your library in a random order. -SVar:TrigDig:DB$ Dig | DigNum$ 5 | Reveal$ True | NoMove$ True | RememberRevealed$ True | SubAbility$ DBChooseCardOne -SVar:DBChooseCardOne:DB$ ChooseCard | Defined$ You | Choices$ Instant.YouCtrl+IsRemembered | ImprintChosen$ True | ConditionCheckSVar$ CheckInstant | ConditionSVarCompare$ EQ1 | ChoiceTitle$ You may choose an instant card if you cast an instant spell this turn | ChoiceZone$ Library | AILogic$ BestCard | SubAbility$ DBChooseCardTwo -SVar:DBChooseCardTwo:DB$ ChooseCard | Defined$ You | Choices$ Sorcery.YouCtrl+IsRemembered | ImprintChosen$ True | ConditionCheckSVar$ CheckSorcery | ConditionSVarCompare$ EQ1 | ChoiceTitle$ You may choose a sorcery card if you cast a sorcery spell this turn | ChoiceZone$ Library | AILogic$ BestCard | SubAbility$ DBChooseCardThree -SVar:DBChooseCardThree:DB$ ChooseCard | Defined$ You | Choices$ Planeswalker.YouCtrl+IsRemembered | ImprintChosen$ True | ConditionCheckSVar$ CheckPlaneswalker | ConditionSVarCompare$ EQ1 | ChoiceTitle$ You may choose a planeswalker card if you cast a planeswalker spell this turn | ChoiceZone$ Library | AILogic$ BestCard | SubAbility$ DBChooseCardFour -SVar:DBChooseCardFour:DB$ ChooseCard | Defined$ You | Choices$ Tribal.YouCtrl+IsRemembered | ImprintChosen$ True | ConditionCheckSVar$ CheckTribal | ConditionSVarCompare$ EQ1 | ChoiceTitle$ You may choose a tribal card if you cast a tribal spell this turn | ChoiceZone$ Library | AILogic$ BestCard | SubAbility$ DBChooseCardFive -SVar:DBChooseCardFive:DB$ ChooseCard | Defined$ You | Choices$ Enchantment.YouCtrl+IsRemembered | ImprintChosen$ True | ConditionCheckSVar$ CheckEnchantment | ConditionSVarCompare$ EQ1 | ChoiceTitle$ You may choose an enchantment card if you cast an enchantment spell this turn | ChoiceZone$ Library | AILogic$ BestCard | SubAbility$ DBChooseCardSix -SVar:DBChooseCardSix:DB$ ChooseCard | Defined$ You | Choices$ Artifact.YouCtrl+IsRemembered | ImprintChosen$ True | ChoiceTitle$ You may choose an artifact card if you cast an artifact spell this turn | ChoiceZone$ Library | AILogic$ BestCard | ConditionCheckSVar$ CheckArtifact | ConditionSVarCompare$ EQ1 | SubAbility$ DBChangeZoneAll +SVar:TrigDig:DB$ Dig | DigNum$ 5 | Reveal$ True | NoMove$ True | RememberRevealed$ True | SubAbility$ DBRepeatEach +SVar:DBRepeatEach:DB$ RepeatEach | RepeatTypesFromDefined$ ThisTurnCast_Card.nonCreature+YouCtrl | RepeatSubAbility$ ChooseCard | SubAbility$ DBChangeZoneAll +SVar:ChooseCard:DB$ ChooseCard | Choices$ Card.IsRemembered+ChosenType | ImprintChosen$ True | ForgetChosen$ True | ChoiceTitle$ You may choose a card of this type to put into your hand | ChoiceZone$ Library | AILogic$ BestCard SVar:DBChangeZoneAll:DB$ ChangeZone | Defined$ Imprinted | Origin$ Library | Destination$ Hand | SubAbility$ DBRestRandomOrder SVar:DBRestRandomOrder:DB$ ChangeZoneAll | ChangeType$ Card.IsRemembered | Origin$ Library | Destination$ Library | LibraryPosition$ -1 | RandomOrder$ True | SubAbility$ DBCleanup -SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True | ClearImprinted$ True +SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True | ClearImprinted$ True | ClearChosenCard$ True SVar:X:Count$ThisTurnCast_Card.nonCreature+YouCtrl -SVar:CheckArtifact:Count$ThisTurnCast_Card.Artifact.YouCtrl -SVar:CheckEnchantment:Count$ThisTurnCast_Enchantment.YouCtrl -SVar:CheckInstant:Count$ThisTurnCast_Instant.YouCtrl -SVar:CheckSorcery:Count$ThisTurnCast_Sorcery.YouCtrl -SVar:CheckPlaneswalker:Count$ThisTurnCast_Planeswalker.YouCtrl -SVar:CheckTribal:Count$ThisTurnCast_Tribal.YouCtrl -DeckHints:Type$Artifact +SVar:BuffedBy:Card.nonCreature Oracle:At the beginning of your end step, if you've cast a noncreature spell this turn, reveal the top five cards of your library. For each card type among noncreature spells you've cast this turn, you may put a card of that type from among the revealed cards into your hand. Put the rest on the bottom of your library in a random order.