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

Method appendTempBonuses

code/src/java/pcgen/io/PCGVer2Creator.java:2204–2268  ·  view source on GitHub ↗
(StringBuilder buffer)

Source from the content-addressed store, hash-verified

2202 }
2203
2204 private void appendTempBonuses(StringBuilder buffer)
2205 {
2206 final List<String> trackList = new ArrayList<>();
2207 TreeSet<Map.Entry<BonusObj, BonusManager.TempBonusInfo>> sortedbonus = new TreeSet<>(
2208
2209 (a, b) -> {
2210 BonusObj keyA = a.getKey();
2211 BonusObj keyB = b.getKey();
2212 if (!keyA.getBonusName().equals(keyB.getBonusName()))
2213 {
2214 return keyA.getBonusName().compareTo(keyB.getBonusName());
2215 }
2216 if (!keyA.getBonusInfo().equals(keyB.getBonusInfo()))
2217 {
2218 return keyA.getBonusInfo().compareTo(keyB.getBonusInfo());
2219 }
2220 return keyA.getPCCText().compareTo(keyB.getPCCText());
2221 });
2222 sortedbonus.addAll(thePC.getTempBonusMap().entrySet());
2223
2224 //for (BonusManager.TempBonusInfo tbi : thePC.getTempBonusMap().values())
2225 for (Map.Entry<BonusObj, BonusManager.TempBonusInfo> me : sortedbonus)
2226 {
2227 TempBonusInfo tbi = me.getValue();
2228 Object creObj = tbi.source;
2229 Object tarObj = tbi.target;
2230 final String outString = tempBonusName(creObj, tarObj);
2231 if (trackList.contains(outString))
2232 {
2233 continue;
2234 }
2235 trackList.add(outString);
2236 buffer.append(outString);
2237
2238 String bonusName = BonusDisplay.getBonusDisplayName(tbi);
2239 if (thePC.getTempBonusFilters().contains(bonusName))
2240 {
2241 buffer.append('|');
2242 buffer.append(IOConstants.TAG_TEMPBONUSACTIVE).append(":N");
2243 }
2244
2245 /*
2246 * Why do we loop through the bonuses again? It is looped through
2247 * again so that only items associated with this source (e.g.
2248 * Template and Target object) are written, but that ALL of the
2249 * items are written on one line.
2250 */
2251 for (Map.Entry<BonusObj, BonusManager.TempBonusInfo> subme : sortedbonus)
2252 {
2253 BonusObj subBonus = subme.getKey();
2254 TempBonusInfo subtbi = subme.getValue();
2255 Object cObj = subtbi.source;
2256 Object tObj = subtbi.target;
2257 final String inString = tempBonusName(cObj, tObj);
2258 if (inString.equals(outString))
2259 {
2260 buffer.append('|');
2261 buffer.append(IOConstants.TAG_TEMPBONUSBONUS).append(':');

Callers 1

createPCGStringMethod · 0.95

Calls 15

getBonusNameMethod · 0.95
getBonusInfoMethod · 0.95
getPCCTextMethod · 0.95
tempBonusNameMethod · 0.95
getBonusDisplayNameMethod · 0.95
encodeMethod · 0.95
getKeyMethod · 0.65
equalsMethod · 0.65
addAllMethod · 0.65
getValueMethod · 0.65
containsMethod · 0.65
addMethod · 0.65

Tested by

no test coverage detected