public ContinuousEffectsList(final ContinuousEffectsList<T> effects) { this.ensureCapacity(effects.size()); for (ContinuousEffect cost : effects) { this.add((T) cost.copy()); } for (Map.Entry<UUID, Set<Ability>> entry : effects.effectAbilityMap.entrySet()) { Set<Ability> newSet = new HashSet<>(); for (Ability ability : entry.getValue()) { newSet.add(ability.copy()); } effectAbilityMap.put(entry.getKey(), newSet); } }
/** * Adds an effect and its connected ability to the list. For each effect * will be stored, which abilities are connected to the effect. So an effect * can be connected to multiple abilities. * * @param effect - effect to add * @param source - connected ability */ public void addEffect(T effect, Ability source) { if (effectAbilityMap.containsKey(effect.getId())) { Set<Ability> set = effectAbilityMap.get(effect.getId()); for (Ability ability : set) { if (ability.getId().equals(source.getId()) && ability.getSourceId().equals(source.getSourceId())) { return; } } set.add(source); return; } Set<Ability> set = new HashSet<>(); set.add(source); this.effectAbilityMap.put(effect.getId(), set); this.add(effect); }