diff options
Diffstat (limited to 'src/main/java/tlIItools/AffixSet.java')
| -rw-r--r-- | src/main/java/tlIItools/AffixSet.java | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/src/main/java/tlIItools/AffixSet.java b/src/main/java/tlIItools/AffixSet.java index 8f59d7b4..569649ec 100644 --- a/src/main/java/tlIItools/AffixSet.java +++ b/src/main/java/tlIItools/AffixSet.java @@ -1,9 +1,9 @@ package tlIItools; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; /** * Container of a set of affixes. * @@ -13,15 +13,15 @@ public class AffixSet { /** * All of the affix groups contained in this set. * - * An affix group is a set of affixs that generally have the same or - * similiar effects, but have different intensities or spawn levels. + * An affix group is a set of affixes that generally have the same or + * similar effects, but have different intensities or spawn levels. */ - public Map<String, List<Affix>> affixGroups; + public Map<String, Set<Affix>> affixGroups; /** * All of the ungrouped affixes contained in this set. */ - public List<Affix> ungroupedAffixes; + public Set<Affix> ungroupedAffixes; /** * Create a new blank affix set. @@ -29,6 +29,33 @@ public class AffixSet { public AffixSet() { affixGroups = new HashMap<>(); - ungroupedAffixes = new ArrayList<>(); + ungroupedAffixes = new HashSet<>(); + } + + /** + * Add an affix to this set. + * + * @param afx The affix to add. + */ + public void addAffixByContents(Affix afx) { + String afxGroup = afx.getAffixGroupName(); + + if (afxGroup.equals("")) { + ungroupedAffixes.add(afx); + } else { + affixGroups.compute(afxGroup, (key, val) -> { + if (val == null) { + Set<Affix> afxSet = new HashSet<>(); + + afxSet.add(afx); + + return afxSet; + } else { + val.add(afx); + + return val; + } + }); + } } } |
