diff --git a/Mage/src/mage/abilities/Abilities.java b/Mage/src/mage/abilities/Abilities.java index eeaa751359..40488a4615 100644 --- a/Mage/src/mage/abilities/Abilities.java +++ b/Mage/src/mage/abilities/Abilities.java @@ -183,6 +183,11 @@ public interface Abilities extends List, Serializable { * @see mage.cards.CardImpl#assignNewId() */ public void setSourceId(UUID sourceId); + + /** + * Assigns a new {@link java.util.UUID} + */ + public void newId(); /** * Searches this set of abilities to see if the ability represented by the abilityId diff --git a/Mage/src/mage/abilities/AbilitiesImpl.java b/Mage/src/mage/abilities/AbilitiesImpl.java index e63ac8d181..4e3d47f667 100644 --- a/Mage/src/mage/abilities/AbilitiesImpl.java +++ b/Mage/src/mage/abilities/AbilitiesImpl.java @@ -177,6 +177,13 @@ public class AbilitiesImpl extends ArrayList implements Ab } } + @Override + public void newId() { + for (Ability ability: this) { + ability.newId(); + } + } + @Override public boolean contains(T ability) { for (T test: this) { diff --git a/Mage/src/mage/abilities/AbilityImpl.java b/Mage/src/mage/abilities/AbilityImpl.java index 7da8d31819..f62619ec0f 100644 --- a/Mage/src/mage/abilities/AbilityImpl.java +++ b/Mage/src/mage/abilities/AbilityImpl.java @@ -121,6 +121,7 @@ public abstract class AbilityImpl> implements Ability { @Override public void newId() { this.id = UUID.randomUUID(); + getEffects().newId(); } @Override diff --git a/Mage/src/mage/abilities/effects/Effect.java b/Mage/src/mage/abilities/effects/Effect.java index 5faebb5e29..b3ad0bda78 100644 --- a/Mage/src/mage/abilities/effects/Effect.java +++ b/Mage/src/mage/abilities/effects/Effect.java @@ -44,6 +44,7 @@ import mage.target.targetpointer.TargetPointer; public interface Effect> extends Serializable { public UUID getId(); + public void newId(); public String getText(Mode mode); public boolean apply(Game game, Ability source); public Outcome getOutcome(); diff --git a/Mage/src/mage/abilities/effects/EffectImpl.java b/Mage/src/mage/abilities/effects/EffectImpl.java index 7a39d61b90..7916351123 100644 --- a/Mage/src/mage/abilities/effects/EffectImpl.java +++ b/Mage/src/mage/abilities/effects/EffectImpl.java @@ -103,4 +103,9 @@ public abstract class EffectImpl> implements Effect { public TargetPointer getTargetPointer() { return this.targetPointer; } + + @Override + public void newId() { + this.id = UUID.randomUUID(); + } } diff --git a/Mage/src/mage/abilities/effects/Effects.java b/Mage/src/mage/abilities/effects/Effects.java index 6fa43fff6f..bad39ef3a7 100644 --- a/Mage/src/mage/abilities/effects/Effects.java +++ b/Mage/src/mage/abilities/effects/Effects.java @@ -88,4 +88,10 @@ public class Effects extends ArrayList { } return total; } + + public void newId() { + for (Effect effect: this) { + effect.newId(); + } + } } diff --git a/Mage/src/mage/cards/CardImpl.java b/Mage/src/mage/cards/CardImpl.java index 874d55f701..976c422f68 100644 --- a/Mage/src/mage/cards/CardImpl.java +++ b/Mage/src/mage/cards/CardImpl.java @@ -98,6 +98,7 @@ public abstract class CardImpl> extends MageObjectImpl @Override public void assignNewId() { this.objectId = UUID.randomUUID(); + this.abilities.newId(); this.abilities.setSourceId(objectId); } diff --git a/Mage/src/mage/util/functions/CopyFunction.java b/Mage/src/mage/util/functions/CopyFunction.java index f16ccd1182..d994f11805 100644 --- a/Mage/src/mage/util/functions/CopyFunction.java +++ b/Mage/src/mage/util/functions/CopyFunction.java @@ -69,7 +69,10 @@ public class CopyFunction implements Function { target.setExpansionSetCode(source.getExpansionSetCode()); target.getAbilities().clear(); - for (Ability ability : source.getAbilities()) { + for (Ability ability0 : source.getAbilities()) { + Ability ability = ability0.copy(); + ability.newId(); + ability.setSourceId(target.getId()); target.addAbility(ability); } diff --git a/Mage/src/mage/util/functions/CopyTokenFunction.java b/Mage/src/mage/util/functions/CopyTokenFunction.java index 177b64b2f5..f65345c75a 100644 --- a/Mage/src/mage/util/functions/CopyTokenFunction.java +++ b/Mage/src/mage/util/functions/CopyTokenFunction.java @@ -71,6 +71,7 @@ public class CopyTokenFunction implements Function { for (Ability ability0 : source.getAbilities()) { Ability ability = ability0.copy(); + ability.newId(); ability.setSourceId(target.getId()); target.addAbility(ability); }