Calculate the token value (return string) for the ability token. @param tokenSource The text of the export token. @param pc The character being exported. @param eh The export handler. @param abilityIndex The location of the ability in the list. @param aMa
(String tokenSource, PlayerCharacter pc, ExportHandler eh, int abilityIndex, MapToList<Ability, CNAbility> aMapToList)
| 481 | * @return The token value. |
| 482 | */ |
| 483 | private String getRetString(String tokenSource, PlayerCharacter pc, ExportHandler eh, int abilityIndex, |
| 484 | MapToList<Ability, CNAbility> aMapToList) |
| 485 | { |
| 486 | String retString = ""; |
| 487 | Ability aAbility; |
| 488 | List<Ability> aList = new ArrayList<>(aMapToList.getKeySet()); |
| 489 | // If the ability index given is within a valid range |
| 490 | if (abilityIndex >= 0 && abilityIndex < aList.size()) |
| 491 | { |
| 492 | aAbility = aList.get(abilityIndex); |
| 493 | List<CNAbility> abilities = aMapToList.getListFor(aAbility); |
| 494 | if (abilities.isEmpty()) |
| 495 | { |
| 496 | return ""; |
| 497 | } |
| 498 | |
| 499 | // If it is the last item and there's a valid export handler and ??? TODO |
| 500 | // Then tell the ExportHandler that there is no more processing needed |
| 501 | if (abilityIndex == aList.size() - 1 && eh != null && eh.getExistsOnly()) |
| 502 | { |
| 503 | eh.setNoMoreItems(true); |
| 504 | } |
| 505 | |
| 506 | if (tokenSource.contains(".HASINFO.")) |
| 507 | { |
| 508 | final String key = ".INFO."+tokenSource.substring(tokenSource.indexOf(".HASINFO.") + 9); |
| 509 | retString = getHasInfoString(pc, aAbility, key); |
| 510 | } |
| 511 | else if (tokenSource.contains(".INFO.")) |
| 512 | { |
| 513 | final String key = tokenSource.substring(tokenSource.indexOf(".INFO.") + 6); |
| 514 | retString = getInfoString(pc, aAbility, key); |
| 515 | } |
| 516 | else if (tokenSource.endsWith(".DESC") && !tokenSource.contains(".ASPECT.")) |
| 517 | { |
| 518 | retString = pc.getDescription(abilities); |
| 519 | } |
| 520 | else if (tokenSource.endsWith(".BENEFIT")) |
| 521 | { |
| 522 | retString = BenefitFormatting.getBenefits(pc, abilities); |
| 523 | } |
| 524 | else if (tokenSource.endsWith(".TYPE")) |
| 525 | { |
| 526 | retString = aAbility.getType().toUpperCase(); |
| 527 | } |
| 528 | else if (tokenSource.endsWith(".ASSOCIATED")) |
| 529 | { |
| 530 | List<String> assocs = new ArrayList<>(); |
| 531 | for (CNAbility cna : abilities) |
| 532 | { |
| 533 | assocs.addAll(pc.getAssociationExportList(cna)); |
| 534 | } |
| 535 | Collections.sort(assocs); |
| 536 | retString = StringUtil.join(assocs, ","); |
| 537 | } |
| 538 | else if (tokenSource.contains(".ASSOCIATED.")) |
| 539 | { |
| 540 | final String key = tokenSource.substring(tokenSource.indexOf(".ASSOCIATED.") + 12); |
no test coverage detected