use of pcgen.core.Ability in project pcgen by PCGen.
the class Gui2InfoFactory method getChoices.
@Override
public String getChoices(AbilityFacade abilityFacade) {
if (abilityFacade == null || !(abilityFacade instanceof Ability)) {
return EMPTY_STRING;
}
final Ability ability = (Ability) abilityFacade;
final StringBuilder result = new StringBuilder(100);
Collection<CNAbility> targetAbilities = pc.getMatchingCNAbilities(ability);
if (ability.getSafe(ObjectKey.MULTIPLE_ALLOWED)) {
ChooseInformation<?> chooseInfo = ability.get(ObjectKey.CHOOSE_INFO);
processAbilities(result, targetAbilities, chooseInfo);
}
return result.toString();
}
use of pcgen.core.Ability in project pcgen by PCGen.
the class SourceFileLoader method createLangBonusObject.
public static void createLangBonusObject(LoadContext context) {
Ability a = context.getReferenceContext().constructCDOMObject(Ability.class, "*LANGBONUS");
context.getReferenceContext().reassociateCategory(AbilityCategory.LANGBONUS, a);
a.put(ObjectKey.INTERNAL, true);
context.unconditionallyProcess(a, "CHOOSE", "LANG|!PC,LANGBONUS");
context.unconditionallyProcess(a, "VISIBLE", "NO");
context.unconditionallyProcess(a, "AUTO", "LANG|%LIST");
context.unconditionallyProcess(a, "MULT", "YES");
}
use of pcgen.core.Ability in project pcgen by PCGen.
the class FeatLoader method loadDefaultFeats.
/**
* This method loads the default feats with the first feat source.
* @param context
* @param firstSource CampaignSourceEntry first loaded by this loader
*/
private void loadDefaultFeats(LoadContext context, CampaignSourceEntry firstSource) {
Ability wpFeat = context.getReferenceContext().silentlyGetConstructedCDOMObject(Ability.class, AbilityCategory.FEAT, Constants.INTERNAL_WEAPON_PROF);
if (wpFeat == null) {
/* Add catch-all feat for weapon proficiencies that cannot be granted as part
* of a Feat eg. Simple weapons should normally be applied to the Simple
* Weapon Proficiency feat, but it does not allow multiples (either all or
* nothing). So monk class weapons will get dumped into this bucket. */
String aLine = Constants.INTERNAL_WEAPON_PROF + "\tOUTPUTNAME:Weapon Proficiency\tTYPE:General" + "\tVISIBLE:NO\tMULT:YES\tSTACK:YES\tCHOOSE:NOCHOICE" + "\tDESC:You attack with this specific weapon normally," + " non-proficiency incurs a -4 to hit penalty." + "\tSOURCELONG:PCGen Internal";
try {
parseLine(context, null, aLine, firstSource);
} catch (PersistenceLayerException ple) {
Logging.errorPrint("Unable to parse the internal default feats '" + aLine + "': " + ple.getMessage());
}
defaultFeatsLoaded = true;
}
}
use of pcgen.core.Ability in project pcgen by PCGen.
the class AbilityLoader method includeObject.
/**
* This method should be called by finishObject implementations in
* order to check if the parsed object is affected by an INCLUDE or
* EXCLUDE request.
*
* @param cdo PObject to determine whether to include in
* Globals etc.
* @return boolean true if the object should be included, else false
* to exclude it
*/
@Override
protected final boolean includeObject(SourceEntry source, CDOMObject cdo) {
// Null check; never add nulls or objects without a name/key name
if ((cdo == null) || (cdo.getDisplayName() == null) || (cdo.getDisplayName().trim().isEmpty()) || (cdo.getKeyName() == null) || (cdo.getKeyName().trim().isEmpty())) {
return false;
}
Ability ability = (Ability) cdo;
// If includes were present, check includes for given object
List<String> includeItems = source.getIncludeItems();
if (!includeItems.isEmpty()) {
if (includeItems.contains(ability.getCategory() + "," + ability.getKeyName())) {
return true;
}
if (includeItems.contains(ability.getKeyName())) {
Logging.deprecationPrint("Deprecated INCLUDE value when loading " + source.getURI() + " . Abilities (including feats) must always have " + "categories (e.g. " + "INCLUDE:CATEGORY=cat1,key1,key2|CATEGORY=cat2,key3 ).");
return true;
}
return false;
}
// If excludes were present, check excludes for given object
List<String> excludeItems = source.getExcludeItems();
if (!excludeItems.isEmpty()) {
if (excludeItems.contains(ability.getCategory() + "," + ability.getKeyName())) {
return false;
}
if (excludeItems.contains(ability.getKeyName())) {
Logging.deprecationPrint("Deprecated EXCLUDE value when loading " + source.getURI() + " . Abilities (including feats) must always have " + "categories (e.g. " + "EXCLUDE:CATEGORY=cat1,key1,key2|CATEGORY=cat2,key3 ).");
return false;
}
return true;
}
return true;
}
use of pcgen.core.Ability in project pcgen by PCGen.
the class Aspect method getAspectText.
/**
* Gets the name string after having substituting all variables.
*
* @param aPC The PlayerCharacter used to evaluate formulas.
* @param abilities the abilities for which the Aspect text should be compiled
*
* @return The fully substituted description string.
*/
public String getAspectText(final PlayerCharacter aPC, List<CNAbility> abilities) {
final StringBuilder buf = new StringBuilder(50);
if ((abilities == null) || (abilities.isEmpty())) {
return "";
}
Ability sampleAbilityObject = abilities.get(0).getAbility();
if (!qualifies(aPC, sampleAbilityObject)) {
return "";
}
for (final String comp : theComponents) {
if (comp.startsWith(VAR_MARKER)) {
final int ind = Integer.parseInt(comp.substring(VAR_MARKER.length()));
if (theVariables == null || ind > theVariables.size()) {
buf.append(Constants.EMPTY_STRING);
continue;
}
final String var = theVariables.get(ind - 1);
if (var.equals(VAR_NAME)) {
buf.append(sampleAbilityObject.getOutputName());
} else if (var.equals(VAR_LIST)) {
List<String> assocList = new ArrayList<>();
for (CNAbility cna : abilities) {
assocList.addAll(aPC.getAssociationList(cna));
}
String joinString;
if (assocList.size() == 2) {
joinString = " and ";
} else {
joinString = ", ";
}
Collections.sort(assocList);
buf.append(StringUtil.joinToStringBuilder(assocList, joinString));
} else if (//$NON-NLS-1$
var.startsWith("\"")) {
buf.append(var.substring(1, var.length() - 1));
} else {
//$NON-NLS-1$
buf.append(aPC.getVariableValue(var, "Aspect").intValue());
}
} else {
buf.append(comp);
}
}
return buf.toString();
}
Aggregations