MCPcopy Create free account
hub / github.com/PCGen/pcgen / sumActiveBonusMap

Method sumActiveBonusMap

code/src/java/pcgen/core/BonusManager.java:90–204  ·  view source on GitHub ↗

@param fullyQualifiedBonusType @return Total bonus for prefix from the activeBonus HashMap

(String fullyQualifiedBonusType)

Source from the content-addressed store, hash-verified

88 * @return Total bonus for prefix from the activeBonus HashMap
89 */
90 private double sumActiveBonusMap(String fullyQualifiedBonusType)
91 {
92 double bonus = 0;
93 if (fullyQualifiedBonusType == null)
94 {
95 Logging.errorPrint("Unable to sum BONUS when request is null");
96 return bonus;
97 }
98
99 fullyQualifiedBonusType = fullyQualifiedBonusType.toUpperCase();
100 if (cachedActiveBonusSumsMap.containsKey(fullyQualifiedBonusType))
101 {
102 return cachedActiveBonusSumsMap.get(fullyQualifiedBonusType);
103 }
104
105 final List<String> aList = new ArrayList<>();
106 boolean found = false;
107
108 for (String fullyQualifedCurrentBonus : activeBonusMap.keySet())
109 {
110 // aKey is either of the form:
111 // COMBAT.AC
112 // or
113 // COMBAT.AC:Luck
114 // or
115 // COMBAT.AC:Armor.REPLACE
116 if (aList.contains(fullyQualifedCurrentBonus))
117 {
118 continue;
119 }
120
121 if (fullyQualifedCurrentBonus == null)
122 {
123 Logging.errorPrint(
124 "null BONUS: loaded into activeBonusMap. " + fullyQualifiedBonusType + " was requested");
125 continue;
126 }
127
128 String currentTypedBonusNameInfo = fullyQualifedCurrentBonus;
129
130 // rString could be something like:
131 // COMBAT.AC:Armor.REPLACE
132 // So need to remove the .STACK or .REPLACE
133 // to get a match for prefix like: COMBAT.AC:Armor
134 if (currentTypedBonusNameInfo.endsWith(".STACK"))
135 {
136 currentTypedBonusNameInfo =
137 currentTypedBonusNameInfo.substring(0, currentTypedBonusNameInfo.length() - 6);
138 }
139 else if (currentTypedBonusNameInfo.endsWith(".REPLACE"))
140 {
141 currentTypedBonusNameInfo =
142 currentTypedBonusNameInfo.substring(0, currentTypedBonusNameInfo.length() - 8);
143 }
144
145 // if prefix is of the form:
146 // COMBAT.AC
147 // then is must match rstring:

Callers 2

getBonusDueToTypeMethod · 0.95
getTotalBonusToMethod · 0.95

Calls 9

errorPrintMethod · 0.95
containsKeyMethod · 0.65
getMethod · 0.65
containsMethod · 0.65
addMethod · 0.65
putMethod · 0.65
keySetMethod · 0.45
maxMethod · 0.45

Tested by

no test coverage detected