forked from External/mage
fixed ids for copied abilities
This commit is contained in:
parent
2e21d38416
commit
f2ef2e40e5
6 changed files with 32 additions and 1 deletions
|
|
@ -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.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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())) {
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -305,6 +305,9 @@ public class StackAbility implements StackObject, Ability {
|
|||
@Override
|
||||
public void newId() {}
|
||||
|
||||
@Override
|
||||
public void newOriginalId() {}
|
||||
|
||||
@Override
|
||||
public Ability getStackAbility() {
|
||||
return ability;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue