diff --git a/forge-game/src/main/java/forge/game/ability/effects/UntapAllEffect.java b/forge-game/src/main/java/forge/game/ability/effects/UntapAllEffect.java index 684a00d7874..6a6f4c83471 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/UntapAllEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/UntapAllEffect.java @@ -1,11 +1,13 @@ package forge.game.ability.effects; import com.google.common.collect.Maps; +import forge.game.Game; import forge.game.ability.AbilityKey; +import forge.game.ability.AbilityUtils; import forge.game.ability.SpellAbilityEffect; import forge.game.card.Card; import forge.game.card.CardCollection; -import forge.game.card.CardLists; +import forge.game.card.CardCollectionView; import forge.game.player.Player; import forge.game.spellability.AbilitySub; import forge.game.spellability.SpellAbility; @@ -27,22 +29,32 @@ protected String getStackDescription(SpellAbility sa) { public void resolve(SpellAbility sa) { final Card card = sa.getHostCard(); final Player activator = sa.getActivatingPlayer(); - final String valid = sa.getParamOrDefault("ValidCards", ""); + final Game game = activator.getGame(); Map untapMap = Maps.newHashMap(); - for (Player p : getTargetPlayers(sa)) { - for (Card c : CardLists.getValidCards(p.getCardsIn(ZoneType.Battlefield), valid, activator, card, sa)) { - if (c.untap(true)) { - untapMap.computeIfAbsent(p, i -> new CardCollection()).add(c); + CardCollectionView list = !sa.usesTargeting() && !sa.hasParam("Defined") ? + game.getCardsIn(ZoneType.Battlefield) : + getDefinedPlayersOrTargeted(sa).getCardsIn(ZoneType.Battlefield); + + list = AbilityUtils.filterListByType(list, sa.getParamOrDefault("ValidCards", ""), sa); + + Player untapper = activator; + + for (Card c : list) { + if (sa.hasParam("ControllerUntaps")) { + untapper = c.getController(); + } + if (c.untap(true)) { + untapMap.computeIfAbsent(untapper, i -> new CardCollection()).add(c); if (sa.hasParam("RememberUntapped")) card.addRemembered(c); - } + } } if (!untapMap.isEmpty()) { final Map runParams = AbilityKey.newMap(); runParams.put(AbilityKey.Map, untapMap); - activator.getGame().getTriggerHandler().runTrigger(TriggerType.UntapAll, runParams, false); + game.getTriggerHandler().runTrigger(TriggerType.UntapAll, runParams, false); } } } diff --git a/forge-game/src/main/java/forge/game/ability/effects/UntapEffect.java b/forge-game/src/main/java/forge/game/ability/effects/UntapEffect.java index 489be143f5e..1a9485cdd91 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/UntapEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/UntapEffect.java @@ -44,7 +44,7 @@ protected String getStackDescription(SpellAbility sa) { @Override public void resolve(SpellAbility sa) { final Player activator = sa.getActivatingPlayer(); - final boolean ETB = sa.hasParam("ETB"); + final boolean etb = sa.hasParam("ETB"); if (sa.hasParam("UntapUpTo")) { untapChoose(sa, false); @@ -62,12 +62,12 @@ public void resolve(SpellAbility sa) { if (tgtC.isInPlay()) { if (tgtC.untap(true)) untapped.add(tgtC); } - if (ETB) { + if (etb) { // do not fire triggers tgtC.setTapped(false); } } - if (!untapped.isEmpty() && !ETB) { + if (!untapped.isEmpty() && !etb) { final Map runParams = AbilityKey.newMap(); final Map map = Maps.newHashMap(); map.put(activator, untapped); diff --git a/forge-gui/res/cardsfolder/g/great_oak_guardian.txt b/forge-gui/res/cardsfolder/g/great_oak_guardian.txt index 8fb9166bc1f..a074b239208 100644 --- a/forge-gui/res/cardsfolder/g/great_oak_guardian.txt +++ b/forge-gui/res/cardsfolder/g/great_oak_guardian.txt @@ -4,7 +4,7 @@ Types:Creature Treefolk PT:4/5 K:Flash K:Reach -T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ TrigPumpAll | TriggerDescription$ When Great Oak Guardian enters the battlefield, creatures target player controls get +2/+2 until end of turn. Untap them. -SVar:TrigPumpAll:DB$ PumpAll | ValidTgts$ Player | TgtPrompt$ Select target player | ValidCards$ Creature | NumAtt$ +2 | NumDef$ +2 | SubAbility$ DBUntapAll -SVar:DBUntapAll:DB$ UntapAll | Defined$ Targeted | ValidCards$ Creature +T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ TrigPumpAll | TriggerDescription$ When CARDNAME enters the battlefield, creatures target player controls get +2/+2 until end of turn. Untap them. +SVar:TrigPumpAll:DB$ PumpAll | ValidTgts$ Player | ValidCards$ Creature | NumAtt$ +2 | NumDef$ +2 | SubAbility$ DBUntapAll +SVar:DBUntapAll:DB$ UntapAll | ValidCards$ Creature.TargetedPlayerCtrl Oracle:Flash (You may cast this spell any time you could cast an instant.)\nReach\nWhen Great Oak Guardian enters the battlefield, creatures target player controls get +2/+2 until end of turn. Untap them. diff --git a/forge-gui/res/cardsfolder/r/reins_of_power.txt b/forge-gui/res/cardsfolder/r/reins_of_power.txt index 82498d6c296..88508700158 100644 --- a/forge-gui/res/cardsfolder/r/reins_of_power.txt +++ b/forge-gui/res/cardsfolder/r/reins_of_power.txt @@ -1,7 +1,7 @@ Name:Reins of Power ManaCost:2 U U Types:Instant -A:SP$ UntapAll | Cost$ 2 U U | ValidTgts$ Opponent | TgtPrompt$ Select target opponent | ValidCards$ Creature.YouCtrl,Creature.TargetedPlayerCtrl | SubAbility$ DBGainCtrl | SpellDescription$ Untap all creatures you control and all creatures target opponent controls. You and that opponent each gain control of all creatures the other controls until end of turn. Those creatures gain haste until end of turn. +A:SP$ UntapAll | ValidTgts$ Opponent | Defined$ TargetedAndYou | ValidCards$ Creature | SubAbility$ DBGainCtrl | SpellDescription$ Untap all creatures you control and all creatures target opponent controls. You and that opponent each gain control of all creatures the other controls until end of turn. Those creatures gain haste until end of turn. SVar:DBGainCtrl:DB$ GainControl | AllValid$ Creature.TargetedPlayerCtrl | AddKWs$ Haste | NewController$ You | LoseControl$ EOT | RememberControlled$ True | StackDescription$ None | SubAbility$ DBGainCtrlOpp SVar:DBGainCtrlOpp:DB$ GainControl | AllValid$ Creature.IsNotRemembered+YouCtrl | AddKWs$ Haste | NewController$ Targeted | LoseControl$ EOT | StackDescription$ None | SubAbility$ DBCleanup SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True diff --git a/forge-gui/res/cardsfolder/t/twist_allegiance.txt b/forge-gui/res/cardsfolder/t/twist_allegiance.txt index e00b8c9e287..d00a897aa40 100644 --- a/forge-gui/res/cardsfolder/t/twist_allegiance.txt +++ b/forge-gui/res/cardsfolder/t/twist_allegiance.txt @@ -1,8 +1,10 @@ Name:Twist Allegiance ManaCost:6 R Types:Sorcery -A:SP$ GainControl | Cost$ 6 R | ValidTgts$ Opponent | TgtPrompt$ Select target opponent | AllValid$ Creature.TargetedPlayerCtrl | AddKWs$ Haste | Untap$ True | NewController$ You | LoseControl$ EOT | RememberControlled$ True | StackDescription$ SpellDescription | SubAbility$ DBGainCtrlOpp | SpellDescription$ You and target opponent each gain control of all creatures the other controls until end of turn. Untap those creatures. Those creatures gain haste until end of turn. -SVar:DBGainCtrlOpp:DB$ GainControl | AllValid$ Creature.IsNotRemembered+YouCtrl | AddKWs$ Haste | NewController$ Targeted | Untap$ True | LoseControl$ EOT | StackDescription$ None | SubAbility$ DBCleanup +A:SP$ GainControl | ValidTgts$ Opponent | AllValid$ Creature.TargetedPlayerCtrl | NewController$ You | LoseControl$ EOT | RememberControlled$ True | StackDescription$ REP You_{p:You} & target opponent_{p:Targeted} | SubAbility$ DBGainCtrlOpp | SpellDescription$ You and target opponent each gain control of all creatures the other controls until end of turn. Untap those creatures. Those creatures gain haste until end of turn. +SVar:DBGainCtrlOpp:DB$ GainControl | AllValid$ Creature.IsNotRemembered+YouCtrl | NewController$ Targeted | LoseControl$ EOT | RememberControlled$ True | StackDescription$ None | SubAbility$ DBUntapAll +SVar:DBDUntapAll:DB$ UntapAll | ValidCards$ Creature.IsRemembered | SubAbility$ DBPumpAll +SVar:PumpAll:DB$ PumpAll | ValidCards$ Creature.IsRemembered | KW$ Haste | SubAbility$ DBCleanup SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True AI:RemoveDeck:All Oracle:You and target opponent each gain control of all creatures the other controls until end of turn. Untap those creatures. Those creatures gain haste until end of turn.