From e3a33e589429dfa53bcc3029fd40cc264ebe2ba8 Mon Sep 17 00:00:00 2001 From: Quercitron Date: Fri, 10 Aug 2018 02:54:50 +0300 Subject: [PATCH] Fix that cards that are cast using alternative cost effects keep their previous targets (#5189) - Always copy ability on cast. --- Mage/src/main/java/mage/players/PlayerImpl.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Mage/src/main/java/mage/players/PlayerImpl.java b/Mage/src/main/java/mage/players/PlayerImpl.java index 0c5c860d1a..b6167fa214 100644 --- a/Mage/src/main/java/mage/players/PlayerImpl.java +++ b/Mage/src/main/java/mage/players/PlayerImpl.java @@ -1045,6 +1045,10 @@ public abstract class PlayerImpl implements Player, Serializable { if (game == null || ability == null) { return false; } + + // Use ability copy to avoid problems with targets and costs on recast (issue https://github.com/magefree/mage/issues/5189). + ability = ability.copy(); + ability.setControllerId(getId()); if (ability.getSpellAbilityType() != SpellAbilityType.BASE) { ability = chooseSpellAbilityForCast(ability, game, noMana); @@ -1267,7 +1271,7 @@ public abstract class PlayerImpl implements Player, Serializable { result = playManaAbility((ActivatedManaAbilityImpl) ability.copy(), game); break; case SPELL: - result = cast((SpellAbility) ability.copy(), game, false, activationStatus.getPermittingObject()); + result = cast((SpellAbility) ability, game, false, activationStatus.getPermittingObject()); break; default: result = playAbility(ability.copy(), game);