summaryrefslogtreecommitdiff
path: root/src/main/java/tlIItools/AffixSet.java
diff options
context:
space:
mode:
authorBen Culkin <scorpress@gmail.com>2020-07-02 16:01:39 -0400
committerBen Culkin <scorpress@gmail.com>2020-07-02 16:01:39 -0400
commit2f81b826524599859ce4c8bf6164bab83debf662 (patch)
treed2b3c0028d6ef02bba1dc8a8a32a2a5ed8c09a69 /src/main/java/tlIItools/AffixSet.java
parent4d1f759a298b3f7d2c908c90b4d7bcf03b3b111b (diff)
Implement affix grouping by contents
Implements a basic way to 'group' affixes together. An affix group is a collection of affixes which generally provide the same benefits, but at varying levels. For example, '+2 strength' and '+4 strength' would be considered grouped affixes, assuming that they were spawning on the same items and such
Diffstat (limited to 'src/main/java/tlIItools/AffixSet.java')
-rw-r--r--src/main/java/tlIItools/AffixSet.java41
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;
+ }
+ });
+ }
}
}