fixed ids for copied abilities

This commit is contained in:
BetaSteward 2011-09-27 22:27:03 -04:00
parent 2e21d38416
commit f2ef2e40e5
6 changed files with 32 additions and 1 deletions

View file

@ -190,6 +190,11 @@ public interface Abilities<T extends Ability> extends List<T>, Serializable {
public void newId();
/**
* Assigns a new {@link java.util.UUID}
*/
public void newOriginalId();
/**
* Searches this set of abilities to see if the ability represented by the abilityId
* is contained within. Can be used to find usages of singleton abilities.
*

View file

@ -185,6 +185,13 @@ public class AbilitiesImpl<T extends Ability> extends ArrayList<T> implements Ab
}
@Override
public void newOriginalId() {
for (Ability ability: this) {
ability.newOriginalId();
}
}
@Override
public boolean contains(T ability) {
for (T test: this) {
if (ability.getId().equals(test.getId()) || ability.getRule().equals(test.getRule())) {

View file

@ -71,6 +71,15 @@ public interface Ability extends Serializable {
public void newId();
/**
* Assigns a new {@link java.util.UUID}
*
* @see mage.players.PlayerImpl#playAbility(mage.abilities.ActivatedAbility, mage.game.Game)
* @see mage.game.GameImpl#addTriggeredAbility(mage.abilities.TriggeredAbility)
* @see mage.game.GameImpl#addDelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility)
*/
public void newOriginalId();
/**
* Gets the {@link AbilityType} of this ability.
*
* @return The {@link AbilityType type} of this ability.

View file

@ -123,6 +123,13 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> implements Ability {
}
@Override
public void newOriginalId() {
this.id = UUID.randomUUID();
this.originalId = id;
getEffects().newId();
}
@Override
public AbilityType getAbilityType() {
return this.abilityType;
}

View file

@ -110,7 +110,7 @@ public abstract class CardImpl<T extends CardImpl<T>> extends MageObjectImpl<T>
@Override
public void assignNewId() {
this.objectId = UUID.randomUUID();
this.abilities.newId();
this.abilities.newOriginalId();
this.abilities.setSourceId(objectId);
this.watchers.setSourceId(objectId);
}

View file

@ -305,6 +305,9 @@ public class StackAbility implements StackObject, Ability {
@Override
public void newId() {}
@Override
public void newOriginalId() {}
@Override
public Ability getStackAbility() {
return ability;