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.setDescription(newSA.getDescription() + " (Splicing " + c + " onto it)");
|
||||||
newSA.addSplicedCards(c);
|
newSA.addSplicedCards(c);
|
||||||
|
|
||||||
// copy all subAbilities
|
newSA.setActivatingPlayer(sa.getActivatingPlayer());
|
||||||
SpellAbility child = newSA;
|
|
||||||
while (child.getSubAbility() != null) {
|
|
||||||
AbilitySub newChild = child.getSubAbility().getCopy();
|
|
||||||
child.setSubAbility(newChild);
|
|
||||||
child.setActivatingPlayer(newSA.getActivatingPlayer());
|
|
||||||
child = newChild;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
newSA.setHostCard(source);
|
||||||
//add the spliced ability to the end of the chain
|
//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);
|
newSAs.add(newSA);
|
||||||
allSaCombinations.add(++i, newSA);
|
allSaCombinations.add(++i, newSA);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -204,18 +204,12 @@ public class CardFactory {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
copySA = sa.copy();
|
copySA = sa.copy();
|
||||||
copySA.setHostCard(c);
|
AbilitySub subSA = copySA.getSubAbility();
|
||||||
SpellAbility parentSA = copySA;
|
|
||||||
SpellAbility subSA = copySA.getSubAbility();
|
|
||||||
while (subSA != null) {
|
while (subSA != null) {
|
||||||
AbilitySub copySubSA = ((AbilitySub) subSA).getCopy();
|
subSA.setCopied(true);
|
||||||
parentSA.setSubAbility(copySubSA);
|
subSA = subSA.getSubAbility();
|
||||||
copySubSA.setParent(parentSA);
|
|
||||||
copySubSA.setHostCard(c);
|
|
||||||
copySubSA.setCopied(true);
|
|
||||||
parentSA = copySubSA;
|
|
||||||
subSA = copySubSA.getSubAbility();
|
|
||||||
}
|
}
|
||||||
|
copySA.setHostCard(c);
|
||||||
}
|
}
|
||||||
c.getCurrentState().setNonManaAbilities(copySA);
|
c.getCurrentState().setNonManaAbilities(copySA);
|
||||||
copySA.setCopied(true);
|
copySA.setCopied(true);
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import forge.game.ability.ApiType;
|
|||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
import forge.game.card.CardCollection;
|
import forge.game.card.CardCollection;
|
||||||
import forge.game.card.CardCollectionView;
|
import forge.game.card.CardCollectionView;
|
||||||
|
import forge.game.card.CardFactory;
|
||||||
import forge.game.cost.Cost;
|
import forge.game.cost.Cost;
|
||||||
import forge.game.cost.CostPart;
|
import forge.game.cost.CostPart;
|
||||||
import forge.game.cost.CostPartMana;
|
import forge.game.cost.CostPartMana;
|
||||||
@@ -197,6 +198,11 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
|||||||
public void setHostCard(final Card c) {
|
public void setHostCard(final Card c) {
|
||||||
if (hostCard == c) { return; }
|
if (hostCard == c) { return; }
|
||||||
super.setHostCard(c);
|
super.setHostCard(c);
|
||||||
|
|
||||||
|
if (subAbility != null) {
|
||||||
|
subAbility.setHostCard(c);
|
||||||
|
}
|
||||||
|
|
||||||
view.updateHostCard(this);
|
view.updateHostCard(this);
|
||||||
view.updateDescription(this); //description can change if host card does
|
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) {
|
if (clone.hostCard != null && clone.hostCard.getGame() != null) {
|
||||||
clone.hostCard.getGame().addSpellAbility(clone.id, clone);
|
clone.hostCard.getGame().addSpellAbility(clone.id, clone);
|
||||||
}
|
}
|
||||||
|
|
||||||
// need to clone the maps too so they can be changed
|
// need to clone the maps too so they can be changed
|
||||||
clone.originalMapParams = Maps.newHashMap(this.originalMapParams);
|
clone.originalMapParams = Maps.newHashMap(this.originalMapParams);
|
||||||
clone.mapParams = Maps.newHashMap(this.mapParams);
|
clone.mapParams = Maps.newHashMap(this.mapParams);
|
||||||
|
|
||||||
|
// run special copy Ability to make a deep copy
|
||||||
|
CardFactory.copySpellAbility(this, clone);
|
||||||
} catch (final CloneNotSupportedException e) {
|
} catch (final CloneNotSupportedException e) {
|
||||||
System.err.println(e);
|
System.err.println(e);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user