mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
Card: fix addChangedCardTraits when multiple StaticAbilities has the same timestamp
This commit is contained in:
@@ -3657,9 +3657,16 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
public final void addChangedCardTraits(Collection<SpellAbility> spells, Collection<SpellAbility> removedAbilities,
|
public final void addChangedCardTraits(Collection<SpellAbility> spells, Collection<SpellAbility> removedAbilities,
|
||||||
Collection<Trigger> trigger, Collection<ReplacementEffect> replacements, Collection<StaticAbility> statics,
|
Collection<Trigger> trigger, Collection<ReplacementEffect> replacements, Collection<StaticAbility> statics,
|
||||||
boolean removeAll, boolean removeNonMana, boolean removeIntrinsic, long timestamp) {
|
boolean removeAll, boolean removeNonMana, boolean removeIntrinsic, long timestamp) {
|
||||||
changedCardTraits.put(timestamp, new CardTraitChanges(
|
// in case two static abilities has the same timestamp
|
||||||
spells, removedAbilities, trigger, replacements, statics, removeAll, removeNonMana, removeIntrinsic
|
if (changedCardTraits.containsKey(timestamp)) {
|
||||||
));
|
changedCardTraits.get(timestamp).merge(
|
||||||
|
spells, removedAbilities, trigger, replacements, statics, removeAll, removeNonMana, removeIntrinsic
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
changedCardTraits.put(timestamp, new CardTraitChanges(
|
||||||
|
spells, removedAbilities, trigger, replacements, statics, removeAll, removeNonMana, removeIntrinsic
|
||||||
|
));
|
||||||
|
}
|
||||||
// update view
|
// update view
|
||||||
updateAbilityTextForView();
|
updateAbilityTextForView();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,13 +19,19 @@ public class CardTraitChanges implements Cloneable {
|
|||||||
|
|
||||||
private List<SpellAbility> removedAbilities = Lists.newArrayList();
|
private List<SpellAbility> removedAbilities = Lists.newArrayList();
|
||||||
|
|
||||||
private boolean removeAll;
|
private boolean removeAll = false;
|
||||||
private boolean removeNonMana;
|
private boolean removeNonMana = false;
|
||||||
private boolean removeIntrinsic;
|
private boolean removeIntrinsic = false;
|
||||||
|
|
||||||
public CardTraitChanges(Collection<SpellAbility> spells, Collection<SpellAbility> removedAbilities,
|
public CardTraitChanges(Collection<SpellAbility> spells, Collection<SpellAbility> removedAbilities,
|
||||||
Collection<Trigger> trigger, Collection<ReplacementEffect> res, Collection<StaticAbility> st,
|
Collection<Trigger> trigger, Collection<ReplacementEffect> res, Collection<StaticAbility> st,
|
||||||
boolean removeAll, boolean removeNonMana, boolean removeIntrinsic) {
|
boolean removeAll, boolean removeNonMana, boolean removeIntrinsic) {
|
||||||
|
merge(spells, removedAbilities, trigger, res, st, removeAll, removeNonMana, removeIntrinsic);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void merge(Collection<SpellAbility> spells, Collection<SpellAbility> removedAbilities,
|
||||||
|
Collection<Trigger> trigger, Collection<ReplacementEffect> res, Collection<StaticAbility> st,
|
||||||
|
boolean removeAll, boolean removeNonMana, boolean removeIntrinsic) {
|
||||||
if (spells != null) {
|
if (spells != null) {
|
||||||
this.abilities.addAll(spells);
|
this.abilities.addAll(spells);
|
||||||
}
|
}
|
||||||
@@ -41,10 +47,10 @@ public class CardTraitChanges implements Cloneable {
|
|||||||
if (st != null) {
|
if (st != null) {
|
||||||
this.staticAbilities.addAll(st);
|
this.staticAbilities.addAll(st);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.removeAll = removeAll;
|
this.removeAll |= removeAll;
|
||||||
this.removeNonMana = removeNonMana;
|
this.removeNonMana |= removeNonMana;
|
||||||
this.removeIntrinsic = removeIntrinsic;
|
this.removeIntrinsic |= removeIntrinsic;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user