Hurray! Fixed Issue 61. This also fixes card copies not working (e.g. Basilisk Collar copied several times with Prototype Portal).

This commit is contained in:
magenoxx 2011-08-01 20:01:44 +04:00
parent 180a472bc6
commit 5e8aa0036e
9 changed files with 31 additions and 1 deletions

View file

@ -184,6 +184,11 @@ public interface Abilities<T extends Ability> extends List<T>, Serializable {
*/ */
public void setSourceId(UUID sourceId); 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 * 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. * is contained within. Can be used to find usages of singleton abilities.

View file

@ -177,6 +177,13 @@ public class AbilitiesImpl<T extends Ability> extends ArrayList<T> implements Ab
} }
} }
@Override
public void newId() {
for (Ability ability: this) {
ability.newId();
}
}
@Override @Override
public boolean contains(T ability) { public boolean contains(T ability) {
for (T test: this) { for (T test: this) {

View file

@ -121,6 +121,7 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> implements Ability {
@Override @Override
public void newId() { public void newId() {
this.id = UUID.randomUUID(); this.id = UUID.randomUUID();
getEffects().newId();
} }
@Override @Override

View file

@ -44,6 +44,7 @@ import mage.target.targetpointer.TargetPointer;
public interface Effect<T extends Effect<T>> extends Serializable { public interface Effect<T extends Effect<T>> extends Serializable {
public UUID getId(); public UUID getId();
public void newId();
public String getText(Mode mode); public String getText(Mode mode);
public boolean apply(Game game, Ability source); public boolean apply(Game game, Ability source);
public Outcome getOutcome(); public Outcome getOutcome();

View file

@ -103,4 +103,9 @@ public abstract class EffectImpl<T extends Effect<T>> implements Effect<T> {
public TargetPointer getTargetPointer() { public TargetPointer getTargetPointer() {
return this.targetPointer; return this.targetPointer;
} }
@Override
public void newId() {
this.id = UUID.randomUUID();
}
} }

View file

@ -88,4 +88,10 @@ public class Effects extends ArrayList<Effect> {
} }
return total; return total;
} }
public void newId() {
for (Effect effect: this) {
effect.newId();
}
}
} }

View file

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

View file

@ -69,7 +69,10 @@ public class CopyFunction implements Function<Card, Card> {
target.setExpansionSetCode(source.getExpansionSetCode()); target.setExpansionSetCode(source.getExpansionSetCode());
target.getAbilities().clear(); 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); target.addAbility(ability);
} }

View file

@ -71,6 +71,7 @@ public class CopyTokenFunction implements Function<Token, Card> {
for (Ability ability0 : source.getAbilities()) { for (Ability ability0 : source.getAbilities()) {
Ability ability = ability0.copy(); Ability ability = ability0.copy();
ability.newId();
ability.setSourceId(target.getId()); ability.setSourceId(target.getId());
target.addAbility(ability); target.addAbility(ability);
} }