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

Class CNAbilitySelection

code/src/java/pcgen/cdom/helper/CNAbilitySelection.java:36–220  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34import pcgen.rules.context.LoadContext;
35
36public 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('|');

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected