MCPcopy Index your code
hub / github.com/PCGen/pcgen / getDescription

Method getDescription

code/src/java/pcgen/core/Description.java:165–305  ·  view source on GitHub ↗

Gets the description string after having tested all prereqs and substituting all variables. @param aPC The PlayerCharacter used to evaluate formulas. @return The fully substituted description string.

(final PlayerCharacter aPC, List<? extends Object> objList)

Source from the content-addressed store, hash-verified

163 * @return The fully substituted description string.
164 */
165 public String getDescription(final PlayerCharacter aPC, List<? extends Object> objList)
166 {
167 if (objList.isEmpty())
168 {
169 return Constants.EMPTY_STRING;
170 }
171 PObject sampleObject;
172 Object b = objList.get(0);
173 if (b instanceof PObject)
174 {
175 sampleObject = (PObject) b;
176 }
177 else if (b instanceof CNAbility)
178 {
179 sampleObject = ((CNAbility) b).getAbility();
180 }
181 else
182 {
183 Logging.errorPrint("Unable to resolve Description with object of type: " + b.getClass().getName());
184 return Constants.EMPTY_STRING;
185 }
186
187 final StringBuilder buf = new StringBuilder(250);
188 if (this.qualifies(aPC, sampleObject))
189 {
190 for (final String comp : theComponents)
191 {
192 if (comp.startsWith(VAR_MARKER))
193 {
194 final int ind = Integer.parseInt(comp.substring(VAR_MARKER.length()));
195 if (theVariables == null || ind > theVariables.size())
196 {
197 continue;
198 }
199 final String var = theVariables.get(ind - 1);
200 if (var.equals(VAR_NAME))
201 {
202 if (sampleObject != null)
203 {
204 buf.append(sampleObject.getOutputName());
205 }
206 }
207 else if (var.equals(VAR_CHOICE))
208 {
209 if (b instanceof ChooseDriver object)
210 {
211 if (aPC.hasAssociations(object))
212 {
213 //TODO This is ill defined
214 buf.append(aPC.getAssociationExportList(object).get(0));
215 }
216 }
217 else
218 {
219 Logging.errorPrint("In Description resolution, " + "Ignoring object of type: "
220 + b.getClass().getName() + " because " + VAR_CHOICE
221 + " was requested but the object does not support CHOOSE");
222 continue;

Callers 5

testEmptyDescMethod · 0.95
testSimpleDescMethod · 0.95
testPreReqsMethod · 0.95
testSimpleReplacementMethod · 0.95

Calls 15

errorPrintMethod · 0.95
getOutputNameMethod · 0.95
joinMethod · 0.95
getContextMethod · 0.95
parseIntMethod · 0.80
intValueMethod · 0.80
isEmptyMethod · 0.65
getMethod · 0.65
getNameMethod · 0.65
qualifiesMethod · 0.65

Tested by 5

testEmptyDescMethod · 0.76
testSimpleDescMethod · 0.76
testPreReqsMethod · 0.76
testSimpleReplacementMethod · 0.76