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,
|
||||
Collection<Trigger> trigger, Collection<ReplacementEffect> replacements, Collection<StaticAbility> statics,
|
||||
boolean removeAll, boolean removeNonMana, boolean removeIntrinsic, long timestamp) {
|
||||
changedCardTraits.put(timestamp, new CardTraitChanges(
|
||||
spells, removedAbilities, trigger, replacements, statics, removeAll, removeNonMana, removeIntrinsic
|
||||
));
|
||||
// in case two static abilities has the same timestamp
|
||||
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
|
||||
updateAbilityTextForView();
|
||||
}
|
||||
|
||||
@@ -19,13 +19,19 @@ public class CardTraitChanges implements Cloneable {
|
||||
|
||||
private List<SpellAbility> removedAbilities = Lists.newArrayList();
|
||||
|
||||
private boolean removeAll;
|
||||
private boolean removeNonMana;
|
||||
private boolean removeIntrinsic;
|
||||
private boolean removeAll = false;
|
||||
private boolean removeNonMana = false;
|
||||
private boolean removeIntrinsic = false;
|
||||
|
||||
public CardTraitChanges(Collection<SpellAbility> spells, Collection<SpellAbility> removedAbilities,
|
||||
Collection<Trigger> trigger, Collection<ReplacementEffect> res, Collection<StaticAbility> st,
|
||||
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) {
|
||||
this.abilities.addAll(spells);
|
||||
}
|
||||
@@ -41,10 +47,10 @@ public class CardTraitChanges implements Cloneable {
|
||||
if (st != null) {
|
||||
this.staticAbilities.addAll(st);
|
||||
}
|
||||
|
||||
this.removeAll = removeAll;
|
||||
this.removeNonMana = removeNonMana;
|
||||
this.removeIntrinsic = removeIntrinsic;
|
||||
|
||||
this.removeAll |= removeAll;
|
||||
this.removeNonMana |= removeNonMana;
|
||||
this.removeIntrinsic |= removeIntrinsic;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user