diff --git a/forge-game/src/main/java/forge/game/ability/effects/ChangeTargetsEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ChangeTargetsEffect.java index 57a4910a6db..cfd51b6d696 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ChangeTargetsEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ChangeTargetsEffect.java @@ -65,8 +65,6 @@ public class ChangeTargetsEffect extends SpellAbilityEffect { changingTgtSI = changingTgtSI.getSubInstance(); } if (allTargets.isEmpty()) { - // is it an error or not? - System.err.println("Player managed to target a spell without targets with Spellskite's ability."); return; } @@ -98,7 +96,6 @@ public class ChangeTargetsEffect extends SpellAbilityEffect { // random target and DefinedMagnet works on single targets if (sa.hasParam("RandomTarget")) { int div = changingTgtSA.getTotalDividedValue(); - changingTgtSA.resetTargets(); List candidates = changingTgtSA.getTargetRestrictions().getAllCandidates(changingTgtSA, true); if (sa.hasParam("RandomTargetRestriction")) { candidates.removeIf(new java.util.function.Predicate() { @@ -108,6 +105,11 @@ public class ChangeTargetsEffect extends SpellAbilityEffect { } }); } + // CR 115.7a If a target can't be changed to another legal target, the original target is unchanged + if (candidates.isEmpty()) { + return; + } + changingTgtSA.resetTargets(); GameEntity choice = Aggregates.random(candidates); changingTgtSA.getTargets().add(choice); if (changingTgtSA.isDividedAsYouChoose()) { diff --git a/forge-game/src/main/java/forge/game/ability/effects/CopySpellAbilityEffect.java b/forge-game/src/main/java/forge/game/ability/effects/CopySpellAbilityEffect.java index b5fe6b70b30..c27cbb1ffec 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/CopySpellAbilityEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/CopySpellAbilityEffect.java @@ -180,8 +180,10 @@ public class CopySpellAbilityEffect extends SpellAbilityEffect { } }); } - GameEntity choice = Aggregates.random(candidates); - resetFirstTargetOnCopy(copy, choice, chosenSA); + if (!candidates.isEmpty()) { + GameEntity choice = Aggregates.random(candidates); + resetFirstTargetOnCopy(copy, choice, chosenSA); + } } // extra case for Epic to remove the keyword and the last part of the SpellAbility