| 28 | import pcgen.util.Logging; |
| 29 | |
| 30 | public final class SAProcessor implements QualifiedActor<SpecialAbility, SpecialAbility> |
| 31 | { |
| 32 | private final PlayerCharacter pc; |
| 33 | |
| 34 | public SAProcessor(PlayerCharacter pc) |
| 35 | { |
| 36 | this.pc = pc; |
| 37 | } |
| 38 | |
| 39 | @Override |
| 40 | public SpecialAbility act(SpecialAbility sa, Object source) |
| 41 | { |
| 42 | final String key = sa.getKeyName(); |
| 43 | final int idx = key.indexOf("%CHOICE"); |
| 44 | |
| 45 | if (idx == -1) |
| 46 | { |
| 47 | return sa; |
| 48 | } |
| 49 | |
| 50 | StringBuilder sb = new StringBuilder(100); |
| 51 | sb.append(key.substring(0, idx)); |
| 52 | |
| 53 | if (source instanceof ChooseDriver object) |
| 54 | { |
| 55 | if (pc.hasAssociations(object)) |
| 56 | { |
| 57 | List<String> associationList = pc.getAssociationList(object); |
| 58 | Collections.sort(associationList); |
| 59 | sb.append(StringUtil.join(associationList, ", ")); |
| 60 | } |
| 61 | } |
| 62 | else |
| 63 | { |
| 64 | Logging.errorPrint( |
| 65 | "In SpecialAbility resolution, " + "Error using object of type: " + source.getClass().getName() |
| 66 | + " because " + "%CHOICE" + " was requested but the object does not support CHOOSE"); |
| 67 | sb.append("<undefined>"); |
| 68 | } |
| 69 | |
| 70 | sb.append(key.substring(idx + 7)); |
| 71 | return new SpecialAbility(sb.toString(), sa.getSADesc()); |
| 72 | } |
| 73 | } |
nothing calls this directly
no outgoing calls
no test coverage detected