When copying spell-abilities to a new card, update the hostCard.

(Not sure what this affects, but noticed that it wasn't being done.)
This commit is contained in:
Myrd
2016-12-27 04:20:56 +00:00
parent 741d38f50b
commit 0fe2afb3c0
2 changed files with 6 additions and 1 deletions

View File

@@ -647,7 +647,7 @@ public class CardFactory {
to.setReplacementEffects(fromCharacteristics.getReplacementEffects());
// add abilities
for (SpellAbility sa : fromCharacteristics.getIntrinsicSpellAbilities()) {
to.addSpellAbility(sa.copy());
to.addSpellAbility(sa.copy(to));
}
for (String staticAbility : to.getStaticAbilityStrings()) {

View File

@@ -755,11 +755,16 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
}
public SpellAbility copy() {
return copy(hostCard);
}
public SpellAbility copy(Card newHostCard) {
SpellAbility clone = null;
try {
clone = (SpellAbility) clone();
clone.id = nextId();
clone.view = new SpellAbilityView(clone);
clone.hostCard = newHostCard;
if (clone.hostCard != null && clone.hostCard.getGame() != null) {
clone.hostCard.getGame().addSpellAbility(clone.id, clone);
}