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

Method getAspectText

code/src/java/pcgen/cdom/helper/Aspect.java:223–285  ·  view source on GitHub ↗

Gets the name string after having substituting all variables. @param aPC The PlayerCharacter used to evaluate formulas. @param abilities the abilities for which the Aspect text should be compiled @return The fully substituted description string.

(final PlayerCharacter aPC, List<CNAbility> abilities)

Source from the content-addressed store, hash-verified

221 * @return The fully substituted description string.
222 */
223 public String getAspectText(final PlayerCharacter aPC, List<CNAbility> abilities)
224 {
225 final StringBuilder buf = new StringBuilder(50);
226
227 if ((abilities == null) || (abilities.isEmpty()))
228 {
229 return "";
230 }
231 Ability sampleAbilityObject = abilities.get(0).getAbility();
232 if (!qualifies(aPC, sampleAbilityObject))
233 {
234 return "";
235 }
236 for (final String comp : theComponents)
237 {
238 if (comp.startsWith(VAR_MARKER))
239 {
240 final int ind = Integer.parseInt(comp.substring(VAR_MARKER.length()));
241 if (theVariables == null || ind > theVariables.size())
242 {
243 buf.append(Constants.EMPTY_STRING);
244 continue;
245 }
246 final String var = theVariables.get(ind - 1);
247 if (var.equals(VAR_NAME))
248 {
249 buf.append(sampleAbilityObject.getOutputName());
250 }
251 else if (var.equals(VAR_LIST))
252 {
253 List<String> assocList = new ArrayList<>();
254 for (CNAbility cna : abilities)
255 {
256 assocList.addAll(aPC.getAssociationList(cna));
257 }
258 String joinString;
259 if (assocList.size() == 2)
260 {
261 joinString = " and ";
262 }
263 else
264 {
265 joinString = ", ";
266 }
267 Collections.sort(assocList);
268 buf.append(StringUtil.join(assocList, joinString));
269 }
270 else if (var.startsWith("\"")) //$NON-NLS-1$
271 {
272 buf.append(var.substring(1, var.length() - 1));
273 }
274 else
275 {
276 buf.append(aPC.getVariableValue(var, "Aspect").intValue()); //$NON-NLS-1$
277 }
278 }
279 else
280 {

Callers 11

testEmptyDescMethod · 0.95
testNullMethod · 0.95
testSimpleDescMethod · 0.95
testSimpleReplacementMethod · 0.95
testEmptyReplacementMethod · 0.95
testExtraVariablesMethod · 0.95
printAspectMethod · 0.95

Calls 15

joinMethod · 0.95
parseIntMethod · 0.80
intValueMethod · 0.80
isEmptyMethod · 0.65
getMethod · 0.65
qualifiesMethod · 0.65
sizeMethod · 0.65
equalsMethod · 0.65
addAllMethod · 0.65
getVariableValueMethod · 0.65
toStringMethod · 0.65
getAbilityMethod · 0.45

Tested by 10

testEmptyDescMethod · 0.76
testNullMethod · 0.76
testSimpleDescMethod · 0.76
testSimpleReplacementMethod · 0.76
testEmptyReplacementMethod · 0.76
testExtraVariablesMethod · 0.76