From ebcfa5b084c47571cb31d1c921520b86a8a5bcf4 Mon Sep 17 00:00:00 2001 From: Lyu Zong-Hong Date: Fri, 23 Jul 2021 11:38:55 +0900 Subject: [PATCH] Add ValidSA check to LandPlayed trigger --- .../src/main/java/forge/game/player/Player.java | 4 +++- .../java/forge/game/spellability/LandAbility.java | 2 +- .../java/forge/game/trigger/TriggerLandPlayed.java | 12 ++++++++---- .../res/cardsfolder/upcoming/share_the_spoils.txt | 9 ++++----- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/forge-game/src/main/java/forge/game/player/Player.java b/forge-game/src/main/java/forge/game/player/Player.java index 96e3bd91b87..b19b3fb8138 100644 --- a/forge-game/src/main/java/forge/game/player/Player.java +++ b/forge-game/src/main/java/forge/game/player/Player.java @@ -1778,7 +1778,9 @@ public class Player extends GameEntity implements Comparable { game.fireEvent(new GameEventLandPlayed(this, land)); // Run triggers - game.getTriggerHandler().runTrigger(TriggerType.LandPlayed, AbilityKey.mapFromCard(land), false); + Map runParams = AbilityKey.mapFromCard(land); + runParams.put(AbilityKey.SpellAbility, cause); + game.getTriggerHandler().runTrigger(TriggerType.LandPlayed, runParams, false); game.getStack().unfreezeStack(); addLandPlayedThisTurn(); diff --git a/forge-game/src/main/java/forge/game/spellability/LandAbility.java b/forge-game/src/main/java/forge/game/spellability/LandAbility.java index 507543b155d..f02d2143c47 100644 --- a/forge-game/src/main/java/forge/game/spellability/LandAbility.java +++ b/forge-game/src/main/java/forge/game/spellability/LandAbility.java @@ -71,7 +71,7 @@ public class LandAbility extends Ability { @Override public void resolve() { getHostCard().setSplitStateToPlayAbility(this); - final Card result = getActivatingPlayer().playLandNoCheck(getHostCard(), null); + final Card result = getActivatingPlayer().playLandNoCheck(getHostCard(), this); // increase mayplay used if (getMayPlay() != null) { diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerLandPlayed.java b/forge-game/src/main/java/forge/game/trigger/TriggerLandPlayed.java index a9344aec192..aecc30fbb46 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerLandPlayed.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerLandPlayed.java @@ -6,12 +6,12 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ @@ -28,7 +28,7 @@ import forge.util.Localizer; *

* Trigger_LandPlayed class. *

- * + * * @author Forge * @version $Id$ */ @@ -38,7 +38,7 @@ public class TriggerLandPlayed extends Trigger { *

* Constructor for Trigger_LandPlayed. *

- * + * * @param params * a {@link java.util.HashMap} object. * @param host @@ -71,6 +71,10 @@ public class TriggerLandPlayed extends Trigger { return false; } + if (!matchesValidParam("ValidSA", runParams.get(AbilityKey.SpellAbility))) { + return false; + } + if (hasParam("NotFirstLand")) { Card land = (Card) runParams.get(AbilityKey.Card); if (land.getController().getLandsPlayedThisTurn() < 1) { diff --git a/forge-gui/res/cardsfolder/upcoming/share_the_spoils.txt b/forge-gui/res/cardsfolder/upcoming/share_the_spoils.txt index 16739f05f8b..ce4a88bd5a8 100644 --- a/forge-gui/res/cardsfolder/upcoming/share_the_spoils.txt +++ b/forge-gui/res/cardsfolder/upcoming/share_the_spoils.txt @@ -1,8 +1,7 @@ Name:Share the Spoils ManaCost:1 R Types:Enchantment -T:Mode$ ChangesZone | ValidCard$ Card.nonLand+IsRemembered | Origin$ Exile | Destination$ Any | ExcludedDestinations$ Stack | TriggerZones$ Battlefield | Execute$ TrigForget | Static$ True -T:Mode$ ChangesZone | ValidCard$ Land.IsRemembered | Origin$ Exile | Destination$ Any | ExcludedDestinations$ Battlefield | TriggerZones$ Battlefield | Execute$ TrigForget | Static$ True +T:Mode$ ChangesZone | ValidCard$ Card.IsRemembered | Origin$ Exile | Destination$ Any | TriggerZones$ Battlefield | Execute$ TrigForget | Static$ True SVar:TrigForget:DB$ Pump | ForgetObjects$ TriggeredCard T:Mode$ ChangesZone | ValidCard$ Card.Self | Origin$ Battlefield | Destination$ Any | Execute$ DBCleanup | Static$ True SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True @@ -10,7 +9,7 @@ T:Mode$ ChangesZone | ValidCard$ Card.Self | Origin$ Any | Destination$ Battlefi T:Mode$ LosesGame | ValidPlayer$ Player.Opponent | TriggerZones$ Battlefield | Execute$ TrigExile | Secondary$ True | TriggerDescription$ When CARDNAME enters the battlefield or an opponent loses the game, exile the top card of each player's library. SVar:TrigExile:DB$ Dig | DigNum$ 1 | ChangeNum$ All | Defined$ Player | DestinationZone$ Exile | RememberChanged$ True S:Mode$ Continuous | Affected$ Card.IsRemembered | MayPlay$ True | MayPlayLimit$ 1 | MayPlayIgnoreColor$ True | MayPlayPlayer$ ActivePlayer | EffectZone$ Battlefield | AffectedZone$ Exile | Description$ During each player's turn, that player may play a land or cast a spell from among cards exiled with CARDNAME, and they may spend mana as though it were mana of any color to cast that spell. When they do, exile the top card of their library. -T:Mode$ SpellCast | ValidCard$ Card.IsRemembered | TriggerZones$ Battlefield | Execute$ TrigExileTop | Secondary$ True | TriggerDescription$ When they do, exile the top card of their library. -T:Mode$ LandPlayed | ValidCard$ Card.IsRemembered | TriggerZones$ Battlefield | Execute$ TrigExileTop | Secondary$ True | TriggerDescription$ When they do, exile the top card of their library. -SVar:TrigExileTop:DB$ Dig | DigNum$ 1 | ChangeNum$ All | Defined$ TriggeredCardController | DestinationZone$ Exile | RememberChanged$ True | SubAbility$ TrigForget +T:Mode$ SpellCast | ValidCard$ Card | ValidSA$ Spell.MayPlaySource | TriggerZones$ Battlefield | Execute$ TrigExileTop | Secondary$ True | TriggerDescription$ When they do, exile the top card of their library. +T:Mode$ LandPlayed | ValidCard$ Land | ValidSA$ SpellAbility.MayPlaySource | TriggerZones$ Battlefield | Execute$ TrigExileTop | Secondary$ True | TriggerDescription$ When they do, exile the top card of their library. +SVar:TrigExileTop:DB$ Dig | DigNum$ 1 | ChangeNum$ All | Defined$ TriggeredCardController | DestinationZone$ Exile | RememberChanged$ True Oracle:When Share the Spoils enters the battlefield or an opponent loses the game, exile the top card of each player's library.\nDuring each player's turn, that player may play a land or cast a spell from among cards exiled with Share the Spoils, and they may spend mana as though it were mana of any color to cast that spell. When they do, exile the top card of their library.