mirror of
https://github.com/correl/mage.git
synced 2024-11-15 19:19:33 +00:00
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:
parent
180a472bc6
commit
5e8aa0036e
9 changed files with 31 additions and 1 deletions
|
@ -184,6 +184,11 @@ public interface Abilities<T extends Ability> extends List<T>, Serializable {
|
|||
*/
|
||||
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
|
||||
* is contained within. Can be used to find usages of singleton abilities.
|
||||
|
|
|
@ -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
|
||||
public boolean contains(T ability) {
|
||||
for (T test: this) {
|
||||
|
|
|
@ -121,6 +121,7 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> implements Ability {
|
|||
@Override
|
||||
public void newId() {
|
||||
this.id = UUID.randomUUID();
|
||||
getEffects().newId();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -44,6 +44,7 @@ import mage.target.targetpointer.TargetPointer;
|
|||
public interface Effect<T extends Effect<T>> extends Serializable {
|
||||
|
||||
public UUID getId();
|
||||
public void newId();
|
||||
public String getText(Mode mode);
|
||||
public boolean apply(Game game, Ability source);
|
||||
public Outcome getOutcome();
|
||||
|
|
|
@ -103,4 +103,9 @@ public abstract class EffectImpl<T extends Effect<T>> implements Effect<T> {
|
|||
public TargetPointer getTargetPointer() {
|
||||
return this.targetPointer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void newId() {
|
||||
this.id = UUID.randomUUID();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,4 +88,10 @@ public class Effects extends ArrayList<Effect> {
|
|||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
public void newId() {
|
||||
for (Effect effect: this) {
|
||||
effect.newId();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,6 +98,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.setSourceId(objectId);
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,10 @@ public class CopyFunction implements Function<Card, Card> {
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ public class CopyTokenFunction implements Function<Token, Card> {
|
|||
|
||||
for (Ability ability0 : source.getAbilities()) {
|
||||
Ability ability = ability0.copy();
|
||||
ability.newId();
|
||||
ability.setSourceId(target.getId());
|
||||
target.addAbility(ability);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue