From aebde7a1d0dab15d0d1772b62e449bcfead9ab53 Mon Sep 17 00:00:00 2001 From: tool4ever Date: Sun, 22 Sep 2024 19:54:02 +0200 Subject: [PATCH] Fix NPE with Starforged Sword (#6188) * Fix NPE * Fix The Lord of Pain --------- Co-authored-by: TRT <> --- .../java/forge/game/ability/SpellAbilityEffect.java | 2 +- .../main/java/forge/game/player/PlayerProperty.java | 10 +++++----- forge-gui/res/cardsfolder/d/decoy_gambit.txt | 2 +- forge-gui/res/cardsfolder/r/research_development.txt | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/forge-game/src/main/java/forge/game/ability/SpellAbilityEffect.java b/forge-game/src/main/java/forge/game/ability/SpellAbilityEffect.java index a8f232bb366..5f145d9af5f 100644 --- a/forge-game/src/main/java/forge/game/ability/SpellAbilityEffect.java +++ b/forge-game/src/main/java/forge/game/ability/SpellAbilityEffect.java @@ -64,7 +64,7 @@ public abstract class SpellAbilityEffect { // prelude for when this is root ability if (!(sa instanceof AbilitySub)) { sb.append(sa.getHostCard()).append(" -"); - if (sa.getHostCard().hasPromisedGift()) { + if (sa.getHostCard().hasPromisedGift() && sa.hasAdditionalAbility("GiftAbility")) { sb.append(" Gift "). append(sa.getAdditionalAbility("GiftAbility").getParam("GiftDescription")). append(" to ").append(sa.getHostCard().getPromisedGift()).append(". "); diff --git a/forge-game/src/main/java/forge/game/player/PlayerProperty.java b/forge-game/src/main/java/forge/game/player/PlayerProperty.java index aaf3db80bee..e2915155497 100644 --- a/forge-game/src/main/java/forge/game/player/PlayerProperty.java +++ b/forge-game/src/main/java/forge/game/player/PlayerProperty.java @@ -24,11 +24,11 @@ public class PlayerProperty { public static boolean playerHasProperty(Player player, String property, Player sourceController, Card source, CardTraitBase spellAbility) { Game game = player.getGame(); - if (property.endsWith("Activator")) { - sourceController = spellAbility.getHostCard().getController(); - property = property.substring(0, property.length() - 9); - } - if (property.equals("You")) { + if (property.equals("Activator")) { + if (!player.equals(spellAbility.getHostCard().getController())) { + return false; + } + } else if (property.equals("You")) { if (!player.equals(sourceController)) { return false; } diff --git a/forge-gui/res/cardsfolder/d/decoy_gambit.txt b/forge-gui/res/cardsfolder/d/decoy_gambit.txt index 4b28e783873..852d3c3a8fe 100644 --- a/forge-gui/res/cardsfolder/d/decoy_gambit.txt +++ b/forge-gui/res/cardsfolder/d/decoy_gambit.txt @@ -3,6 +3,6 @@ ManaCost:2 U Types:Instant A:SP$ Pump | ValidTgts$ Creature.OppCtrl | TgtPrompt$ Choose up to one target creature each opponent controls | TargetMin$ 0 | TargetMax$ OneEach | TargetsForEachPlayer$ True | SubAbility$ DBRepeat | SpellDescription$ For each opponent, choose up to one target creature that player controls, then return that creature to its owner's hand unless its controller has you draw a card. SVar:DBRepeat:DB$ RepeatEach | DefinedCards$ Targeted | RepeatSubAbility$ DBReturn -SVar:DBReturn:DB$ ChangeZone | Defined$ Remembered | Origin$ Battlefield | Destination$ Hand | UnlessCost$ Draw<1/Player.YouActivator> | UnlessPayer$ RememberedController +SVar:DBReturn:DB$ ChangeZone | Defined$ Remembered | Origin$ Battlefield | Destination$ Hand | UnlessCost$ Draw<1/Player.Activator> | UnlessPayer$ RememberedController SVar:OneEach:PlayerCountOpponents$Amount Oracle:For each opponent, choose up to one target creature that player controls, then return that creature to its owner's hand unless its controller has you draw a card. diff --git a/forge-gui/res/cardsfolder/r/research_development.txt b/forge-gui/res/cardsfolder/r/research_development.txt index f6ec3f9b409..bd8b3526f55 100644 --- a/forge-gui/res/cardsfolder/r/research_development.txt +++ b/forge-gui/res/cardsfolder/r/research_development.txt @@ -12,5 +12,5 @@ Name:Development ManaCost:3 U R Types:Instant A:SP$ Repeat | RepeatSubAbility$ DBToken | MaxRepeat$ 3 | StackDescription$ SpellDescription | SpellDescription$ Create a 3/1 red Elemental creature token unless any opponent has you draw a card. Repeat this process two more times. -SVar:DBToken:DB$ Token | TokenAmount$ 1 | TokenScript$ r_3_1_elemental | TokenOwner$ You | UnlessPayer$ Player.Opponent | UnlessCost$ Draw<1/Player.YouActivator> | UnlessAI$ MorePowerful +SVar:DBToken:DB$ Token | TokenAmount$ 1 | TokenScript$ r_3_1_elemental | TokenOwner$ You | UnlessPayer$ Player.Opponent | UnlessCost$ Draw<1/Player.Activator> | UnlessAI$ MorePowerful Oracle:Create a 3/1 red Elemental creature token unless any opponent has you draw a card. Repeat this process two more times.