| 34 | import pcgen.rules.context.LoadContext; |
| 35 | |
| 36 | public class CNAbilitySelection extends ConcretePrereqObject implements QualifyingObject, Reducible |
| 37 | { |
| 38 | |
| 39 | private final CNAbility cna; |
| 40 | |
| 41 | private final String selection; |
| 42 | |
| 43 | public CNAbilitySelection(CNAbility cna) |
| 44 | { |
| 45 | this(cna, null); |
| 46 | } |
| 47 | |
| 48 | public CNAbilitySelection(CNAbility cna, String choice) |
| 49 | { |
| 50 | Ability abil = cna.getAbility(); |
| 51 | if (choice != null && !abil.getSafe(ObjectKey.MULTIPLE_ALLOWED)) |
| 52 | { |
| 53 | throw new IllegalArgumentException( |
| 54 | "AbilitySelection " + choice + " with MULT:NO Ability " + abil + " must not have choices"); |
| 55 | } |
| 56 | if (choice == null && abil.getSafe(ObjectKey.MULTIPLE_ALLOWED)) |
| 57 | { |
| 58 | throw new IllegalArgumentException( |
| 59 | "AbilitySelection with MULT:YES Ability " + abil + ": must have choices"); |
| 60 | } |
| 61 | this.cna = cna; |
| 62 | selection = choice; |
| 63 | } |
| 64 | |
| 65 | public CNAbility getCNAbility() |
| 66 | { |
| 67 | return cna; |
| 68 | } |
| 69 | |
| 70 | public String getSelection() |
| 71 | { |
| 72 | return selection; |
| 73 | } |
| 74 | |
| 75 | public String getAbilityKey() |
| 76 | { |
| 77 | return cna.getAbilityKey(); |
| 78 | } |
| 79 | |
| 80 | public boolean containsAssociation(String assoc) |
| 81 | { |
| 82 | return (assoc == null) ? (selection == null) : assoc.equals(selection); |
| 83 | } |
| 84 | |
| 85 | public String getPersistentFormat() |
| 86 | { |
| 87 | StringBuilder sb = new StringBuilder(50); |
| 88 | sb.append("CATEGORY="); |
| 89 | sb.append(cna.getAbilityCategory().getKeyName()); |
| 90 | sb.append('|'); |
| 91 | sb.append("NATURE="); |
| 92 | sb.append(cna.getNature()); |
| 93 | sb.append('|'); |
nothing calls this directly
no outgoing calls
no test coverage detected