blob: d7f1421126ade9830b0ed4d84ee676bf8b1afea8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
package tlIItools;
import java.util.*;
/**
* Container of a set of affixes.
*
* @author Ben Culkin
*/
public class AffixSet {
private static class AffixComparator implements Comparator<Affix> {
public int compare(Affix a1, Affix a2) {
if (a1.minLevel == a2.minLevel) {
return a1.maxLevel - a2.maxLevel;
}
return a1.minLevel - a2.minLevel;
}
}
/**
* All of the affix groups contained in this set.
*
* 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, Set<Affix>> affixGroups;
/**
* All of the ungrouped affixes contained in this set.
*/
public Set<Affix> ungroupedAffixes;
/**
* Create a new blank affix set.
*/
public AffixSet() {
affixGroups = new TreeMap<>();
ungroupedAffixes = new TreeSet<>(new AffixComparator());
}
/**
* 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;
}
});
}
}
}
|