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)
| 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; |