mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
SpellAbility: clone now makes a DeepCopy of the SubAbilities too
GameActionUtil: no need to copy the Subabilities extra and use appendSubAbility CardFactory: no need to copy
This commit is contained in:
@@ -404,25 +404,12 @@ public final class GameActionUtil {
|
||||
newSA.setDescription(newSA.getDescription() + " (Splicing " + c + " onto it)");
|
||||
newSA.addSplicedCards(c);
|
||||
|
||||
// copy all subAbilities
|
||||
SpellAbility child = newSA;
|
||||
while (child.getSubAbility() != null) {
|
||||
AbilitySub newChild = child.getSubAbility().getCopy();
|
||||
child.setSubAbility(newChild);
|
||||
child.setActivatingPlayer(newSA.getActivatingPlayer());
|
||||
child = newChild;
|
||||
}
|
||||
newSA.setActivatingPlayer(sa.getActivatingPlayer());
|
||||
|
||||
newSA.setHostCard(source);
|
||||
//add the spliced ability to the end of the chain
|
||||
child.setSubAbility(subAbility);
|
||||
newSA.appendSubAbility(subAbility);
|
||||
|
||||
//set correct source and activating player to all the spliced abilities
|
||||
child = subAbility;
|
||||
while (child != null) {
|
||||
child.setHostCard(source);
|
||||
child.setActivatingPlayer(newSA.getActivatingPlayer());
|
||||
child = child.getSubAbility();
|
||||
}
|
||||
newSAs.add(newSA);
|
||||
allSaCombinations.add(++i, newSA);
|
||||
}
|
||||
|
||||
@@ -204,18 +204,12 @@ public class CardFactory {
|
||||
}
|
||||
else {
|
||||
copySA = sa.copy();
|
||||
copySA.setHostCard(c);
|
||||
SpellAbility parentSA = copySA;
|
||||
SpellAbility subSA = copySA.getSubAbility();
|
||||
AbilitySub subSA = copySA.getSubAbility();
|
||||
while (subSA != null) {
|
||||
AbilitySub copySubSA = ((AbilitySub) subSA).getCopy();
|
||||
parentSA.setSubAbility(copySubSA);
|
||||
copySubSA.setParent(parentSA);
|
||||
copySubSA.setHostCard(c);
|
||||
copySubSA.setCopied(true);
|
||||
parentSA = copySubSA;
|
||||
subSA = copySubSA.getSubAbility();
|
||||
subSA.setCopied(true);
|
||||
subSA = subSA.getSubAbility();
|
||||
}
|
||||
copySA.setHostCard(c);
|
||||
}
|
||||
c.getCurrentState().setNonManaAbilities(copySA);
|
||||
copySA.setCopied(true);
|
||||
|
||||
@@ -32,6 +32,7 @@ import forge.game.ability.ApiType;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardCollection;
|
||||
import forge.game.card.CardCollectionView;
|
||||
import forge.game.card.CardFactory;
|
||||
import forge.game.cost.Cost;
|
||||
import forge.game.cost.CostPart;
|
||||
import forge.game.cost.CostPartMana;
|
||||
@@ -197,6 +198,11 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
||||
public void setHostCard(final Card c) {
|
||||
if (hostCard == c) { return; }
|
||||
super.setHostCard(c);
|
||||
|
||||
if (subAbility != null) {
|
||||
subAbility.setHostCard(c);
|
||||
}
|
||||
|
||||
view.updateHostCard(this);
|
||||
view.updateDescription(this); //description can change if host card does
|
||||
}
|
||||
@@ -664,9 +670,13 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
||||
if (clone.hostCard != null && clone.hostCard.getGame() != null) {
|
||||
clone.hostCard.getGame().addSpellAbility(clone.id, clone);
|
||||
}
|
||||
|
||||
// need to clone the maps too so they can be changed
|
||||
clone.originalMapParams = Maps.newHashMap(this.originalMapParams);
|
||||
clone.mapParams = Maps.newHashMap(this.mapParams);
|
||||
|
||||
// run special copy Ability to make a deep copy
|
||||
CardFactory.copySpellAbility(this, clone);
|
||||
} catch (final CloneNotSupportedException e) {
|
||||
System.err.println(e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user