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)
| 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 | { |