Merge pull request #5212 from magefree/5189-recast-spells-keep-their-previous-targets

Fix that cards that are cast using alternative cost effects keep their previous targets
This commit is contained in:
quercitron 2018-08-11 02:48:07 +03:00 committed by GitHub
commit db2db4c27a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 120 additions and 1 deletions

View file

@ -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);