From 6e3eac1258968c4fc50f0def2e5e5d8792b2c74c Mon Sep 17 00:00:00 2001 From: Agetian Date: Wed, 23 Sep 2015 06:09:05 +0000 Subject: [PATCH] - A somewhat cleaner implementation for the fixes for Explorer's Scope and Quest for Ula's Temple. --- .../forge/game/ability/effects/DigEffect.java | 31 +++++++++++-------- .../res/cardsfolder/e/explorers_scope.txt | 2 +- .../cardsfolder/q/quest_for_ulas_temple.txt | 2 +- 3 files changed, 20 insertions(+), 15 deletions(-) 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 3cf0adf2ac3..e5c96301d8d 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 @@ -73,6 +73,14 @@ public class DigEffect extends SpellAbilityEffect { final boolean noMove = sa.hasParam("NoMove"); final boolean skipReorder = sa.hasParam("SkipReorder"); + // A hack for cards like Explorer's Scope that need to ensure that a card is revealed to the player activating the ability + final boolean forceRevealToController = sa.hasParam("ForceRevealToController"); + + // These parameters are used to indicate that a dialog box must be show to the player asking if the player wants to proceed + // with an optional ability, otherwise the optional ability is skipped. + final boolean mayBeSkipped = sa.hasParam("PromptToSkipOptionalAbility"); + final String optionalAbilityPrompt = sa.hasParam("OptionalAbilityPrompt") ? sa.getParam("OptionalAbilityPrompt") : ""; + boolean changeAll = false; boolean allButOne = false; final List keywords = new ArrayList(); @@ -189,24 +197,21 @@ public class DigEffect extends SpellAbilityEffect { andOrCards = new CardCollection(); } - if (sa.hasParam("ForcedRevealToController")) { - // TODO: this parameter is used on Explorer's Scope to ensure the card is shown to the ability controller - // (making this global for ChangeNum=All,NumToDig=1 causes cards like Quest for Ula's Temple to reveal the card multiple times, - // but something has to be done about this to make it more universal) + if (forceRevealToController) { + // Force revealing the card to the player activating the ability (e.g. Explorer's Scope) game.getAction().revealTo(top, player); } + // Optional abilities that use a dialog box to prompt the user to skip the ability (e.g. Explorer's Scope, Quest for Ula's Temple) + if (optional && mayBeSkipped && !valid.isEmpty()) { + String prompt = !optionalAbilityPrompt.isEmpty() ? optionalAbilityPrompt : "Would you like to proceed with the optional ability for " + sa.getHostCard() + "?\n\n(" + sa.getDescription() + ")"; + if (!p.getController().confirmAction(sa, null, prompt)) { + return; + } + } + if (changeAll) { movedCards = new CardCollection(valid); - - if (optional && !valid.isEmpty() && sa.hasParam("ShowOptionalAbilityPrompt")) { - // TODO: Without ShowOptionalAbilityPrompt, ChangeAll mode with NumToDig = 1 does not give the player any confirmation request - // (however, making it global for this mode causes it to appear for cards with subabilities which do not require extra - // prompting, e.g. Write into Being or Quest for Ula's Temple). - if (!p.getController().confirmAction(sa, null, sa.getParam("ShowOptionalAbilityPrompt"))) { - return; - } - } } else if (sa.hasParam("RandomChange")) { int numChanging = Math.min(destZone1ChangeNum, valid.size()); diff --git a/forge-gui/res/cardsfolder/e/explorers_scope.txt b/forge-gui/res/cardsfolder/e/explorers_scope.txt index 7f882058d95..457d250447e 100644 --- a/forge-gui/res/cardsfolder/e/explorers_scope.txt +++ b/forge-gui/res/cardsfolder/e/explorers_scope.txt @@ -3,6 +3,6 @@ ManaCost:1 Types:Artifact Equipment K:Equip 1 T:Mode$ Attacks | ValidCard$ Card.AttachedBy | Execute$ TrigDig | TriggerDescription$ Whenever equipped creature attacks, look at the top card of your library. If it's a land card, you may put it onto the battlefield tapped. -SVar:TrigDig:AB$Dig | Cost$ 0 | DigNum$ 1 | ChangeNum$ All | ForcedRevealToController$ True | Optional$ True | ShowOptionalAbilityPrompt$ Would you like to put the land onto the battlefield tapped? | ChangeValid$ Land | DestinationZone$ Battlefield | Tapped$ True | LibraryPosition2$ 0 +SVar:TrigDig:AB$Dig | Cost$ 0 | DigNum$ 1 | ChangeNum$ All | ForceRevealToController$ True | Optional$ True | PromptToSkipOptionalAbility$ True | OptionalAbilityPrompt$ Would you like to put the land onto the battlefield tapped? | ChangeValid$ Land | DestinationZone$ Battlefield | Tapped$ True | LibraryPosition2$ 0 SVar:Picture:http://www.wizards.com/global/images/magic/general/explorers_scope.jpg Oracle:Whenever equipped creature attacks, look at the top card of your library. If it's a land card, you may put it onto the battlefield tapped.\nEquip {1} ({1}: Attach to target creature you control. Equip only as a sorcery diff --git a/forge-gui/res/cardsfolder/q/quest_for_ulas_temple.txt b/forge-gui/res/cardsfolder/q/quest_for_ulas_temple.txt index 85a869fb18c..704da256696 100644 --- a/forge-gui/res/cardsfolder/q/quest_for_ulas_temple.txt +++ b/forge-gui/res/cardsfolder/q/quest_for_ulas_temple.txt @@ -3,7 +3,7 @@ ManaCost:U Types:Enchantment T:Mode$ Phase | Phase$ Upkeep | ValidPlayer$ You | Execute$ TrigDig | TriggerZones$ Battlefield | OptionalDecider$ You | TriggerDescription$ At the beginning of your upkeep, you may look at the top card of your library. If it's a creature card, you may reveal it and put a quest counter on Quest for CARDNAME. SVar:TrigDig:AB$ Dig | Cost$ 0 | DigNum$ 1 | DestinationZone$ Library | LibraryPosition$ 0 | LibraryPosition2$ 0 | SubAbility$ TrigDig2 -SVar:TrigDig2:DB$ Dig | Cost$ 0 | DigNum$ 1 | ChangeNum$ All | RevealValid$ Creature | ChangeValid$ Creature | Optional$ True | ShowOptionalAbilityPrompt$ Would you like to reveal the creature and put a quest counter on Quest for Ula's Temple? | DestinationZone$ Library | LibraryPosition$ 0 | LibraryPosition2$ 0 | RememberChanged$ True | SubAbility$ DBPutCounter +SVar:TrigDig2:DB$ Dig | Cost$ 0 | DigNum$ 1 | ChangeNum$ All | RevealValid$ Creature | ChangeValid$ Creature | Optional$ True | PromptToSkipOptionalAbility$ True | OptionalAbilityPrompt$ Would you like to reveal the creature and put a quest counter on Quest for Ula's Temple? | DestinationZone$ Library | LibraryPosition$ 0 | LibraryPosition2$ 0 | RememberChanged$ True | SubAbility$ DBPutCounter SVar:DBPutCounter:DB$ PutCounter | CounterType$ QUEST | CounterNum$ 1 | Defined$ Self | ConditionDefined$ Remembered | ConditionPresent$ Creature | ConditionCompare$ EQ1 | SubAbility$ DBCleanup T:Mode$ Phase | Phase$ End of Turn | ValidPlayer$ Player | Execute$ TrigChangeZone | OptionalDecider$ You | TriggerZones$ Battlefield | IsPresent$ Card.Self+counters_GE3_QUEST | PresentCompare$ EQ1 | TriggerDescription$ At the beginning of each end step, if there are three or more quest counters on Quest for CARDNAME, you may put a Kraken, Leviathan, Octopus, or Serpent creature card from your hand onto the battlefield. SVar:TrigChangeZone:AB$ ChangeZone | Cost$ 0 | Origin$ Hand | Destination$ Battlefield | ChangeType$ Creature.Kraken,Creature.Leviathan,Creature.Octopus,Creature.Serpent | ChangeNum$ 1 | Hidden$ True