use of pcgen.cdom.content.CNAbility in project pcgen by PCGen.
the class AbilityDepthTest method containsExpected.
protected boolean containsExpected(Ability granted) {
Collection<CNAbility> abilities = grantedAbilityFacet.getPoolAbilities(id, AbilityCategory.FEAT);
if (abilities.isEmpty()) {
System.err.println("No Abilities");
return false;
}
for (CNAbility a : abilities) {
boolean abilityExpected = a.getAbility().equals(granted);
if (abilityExpected) {
boolean c = assocCheck.check(a);
if (!c) {
System.err.println("Incorrect Associations");
}
return c;
}
}
System.err.println("Did not find Ability: " + granted.getKeyName());
return false;
}
use of pcgen.cdom.content.CNAbility in project pcgen by PCGen.
the class CharacterFacadeImpl method refreshLanguageList.
/**
* Regenerate the character's list of languages.
*/
void refreshLanguageList() {
long startTime = new Date().getTime();
List<Language> sortedLanguages = new ArrayList<>(charDisplay.getLanguageSet());
Collections.sort(sortedLanguages);
languages.updateContents(sortedLanguages);
autoLanguagesCache = null;
boolean allowBonusLangAfterFirst = Globals.checkRule(RuleConstants.INTBONUSLANG);
boolean atFirstLvl = theCharacter.getTotalLevels() <= 1;
int bonusLangMax = theCharacter.getBonusLanguageCount();
currBonusLangs = new ArrayList<>();
CNAbility a = theCharacter.getBonusLanguageAbility();
List<String> currBonusLangNameList = theCharacter.getAssociationList(a);
for (LanguageFacade langFacade : languages) {
Language lang = (Language) langFacade;
if (currBonusLangNameList.contains(lang.getKeyName())) {
currBonusLangs.add(lang);
}
}
int bonusLangRemain = bonusLangMax - currBonusLangs.size();
if (!allowBonusLangAfterFirst && !atFirstLvl) {
bonusLangRemain = 0;
}
numBonusLang.set(bonusLangRemain);
if (bonusLangRemain > 0) {
if (allowBonusLangAfterFirst) {
todoManager.addTodo(new TodoFacadeImpl(Tab.SUMMARY, "Languages", "in_sumTodoBonusLanguage", 110));
todoManager.removeTodo("in_sumTodoBonusLanguageFirstOnly");
} else {
todoManager.addTodo(new TodoFacadeImpl(Tab.SUMMARY, "Languages", "in_sumTodoBonusLanguageFirstOnly", 110));
todoManager.removeTodo("in_sumTodoBonusLanguage");
}
} else {
todoManager.removeTodo("in_sumTodoBonusLanguage");
todoManager.removeTodo("in_sumTodoBonusLanguageFirstOnly");
}
int numSkillLangSelected = 0;
int skillLangMax = 0;
//TODO: Need to cope with multiple skill languages
SkillFacade speakLangSkill = dataSet.getSpeakLanguageSkill();
if (speakLangSkill != null) {
Skill skill = (Skill) speakLangSkill;
List<String> langList = theCharacter.getAssociationList(skill);
numSkillLangSelected = langList.size();
skillLangMax = SkillRankControl.getTotalRank(theCharacter, skill).intValue();
}
int skillLangRemain = skillLangMax - numSkillLangSelected;
numSkillLang.set(skillLangRemain);
if (skillLangRemain > 0) {
todoManager.addTodo(new TodoFacadeImpl(Tab.SUMMARY, "Languages", "in_sumTodoSkillLanguage", 112));
} else {
todoManager.removeTodo("in_sumTodoSkillLanguage");
}
if (skillLangRemain < 0) {
todoManager.addTodo(new TodoFacadeImpl(Tab.SUMMARY, "Languages", "in_sumTodoSkillLanguageTooMany", 112));
} else {
todoManager.removeTodo("in_sumTodoSkillLanguageTooMany");
}
long endTime = new Date().getTime();
Logging.log(Logging.DEBUG, "refreshLanguageList took " + (endTime - startTime) + " ms.");
}
use of pcgen.cdom.content.CNAbility in project pcgen by PCGen.
the class CharacterFacadeImpl method getAbilityNature.
/**
* @see pcgen.core.facade.CharacterFacade#getAbilityNature(pcgen.core.facade.AbilityFacade)
*/
@Override
public Nature getAbilityNature(AbilityFacade ability) {
if (ability == null || !(ability instanceof Ability)) {
return null;
}
/*
* TODO This is making a somewhat DRASTIC assumption that ANY Ability
* Category is appropriate. Unfortunately, the point at which this
* method is called from the UI it is unclear to the untrained eye how
* to get the category.
*/
List<CNAbility> cnas = theCharacter.getMatchingCNAbilities((Ability) ability);
Nature nature = null;
for (CNAbility cna : cnas) {
nature = Nature.getBestNature(nature, cna.getNature());
}
return nature;
}
use of pcgen.cdom.content.CNAbility in project pcgen by PCGen.
the class CharacterAbilities method addElement.
private void addElement(Map<AbilityCategoryFacade, DefaultListFacade<AbilityFacade>> workingAbilityListMap, CNAbilitySelection cnas) {
CNAbility cas = cnas.getCNAbility();
Ability ability = cas.getAbility();
if (!ability.getSafe(ObjectKey.VISIBILITY).isVisibleTo(View.VISIBLE_DISPLAY)) {
// Filter out hidden abilities
return;
}
AbilityCategoryFacade cat = (AbilityCategoryFacade) cas.getAbilityCategory();
DefaultListFacade<AbilityFacade> listFacade = workingAbilityListMap.get(cat);
if (listFacade == null) {
listFacade = new DefaultListFacade<>();
workingAbilityListMap.put(cat, listFacade);
}
if (!listFacade.containsElement(ability)) {
listFacade.addElement(ability);
}
}
use of pcgen.cdom.content.CNAbility in project pcgen by PCGen.
the class CharacterAbilities method removeAbility.
/**
* Process a request by the user to remove an ability. The user will be
* informed if the request cannot be allowed. Updates to the displayed
* lists are handled by events (see initForCharacter).
*
* @param categoryFacade The category from which the ability is being removed.
* @param abilityFacade The ability to be removed.
*/
public void removeAbility(AbilityCategoryFacade categoryFacade, AbilityFacade abilityFacade) {
if (abilityFacade == null || !(abilityFacade instanceof Ability) || categoryFacade == null || !(categoryFacade instanceof AbilityCategory)) {
return;
}
Ability anAbility = (Ability) abilityFacade;
AbilityCategory theCategory = (AbilityCategory) categoryFacade;
try {
Ability pcAbility = theCharacter.getMatchingAbility(theCategory, anAbility, Nature.NORMAL);
if (pcAbility != null) {
CNAbility cna = CNAbilityFactory.getCNAbility(theCategory, Nature.NORMAL, anAbility);
AbilityUtilities.driveChooseAndAdd(cna, theCharacter, false);
theCharacter.adjustMoveRates();
}
} catch (Exception exc) {
//$NON-NLS-1$
Logging.errorPrintLocalised("in_iayFailedToRemoveAbility", exc);
delegate.showErrorMessage(Constants.APPLICATION_NAME, LanguageBundle.getString(//$NON-NLS-1$
"in_iayRemoveAbility") + ": " + exc.getMessage());
return;
}
theCharacter.calcActiveBonuses();
// update the ability info
rebuildAbilityLists();
return;
}
Aggregations