Search in sources :

Example 6 with AbilityCategory

use of pcgen.core.AbilityCategory in project pcgen by PCGen.

the class AbilityToken method getToken.

/**
	 * @see pcgen.io.exporttoken.Token#getToken(java.lang.String,
	 *      pcgen.core.PlayerCharacter, pcgen.io.ExportHandler)
	 */
@Override
public String getToken(String tokenSource, PlayerCharacter pc, ExportHandler eh) {
    // Skip the ABILITY token itself
    final StringTokenizer aTok = new StringTokenizer(tokenSource, ".");
    final String tokenString = aTok.nextToken();
    // Get the Ability Category from the Gamemode given the key
    final String categoryString = aTok.nextToken();
    final AbilityCategory aCategory = "ANY".equals(categoryString) ? AbilityCategory.ANY : SettingsHandler.getGame().getAbilityCategory(categoryString);
    // Get the ABILITY token for the category
    return getTokenForCategory(tokenSource, pc, eh, aTok, tokenString, aCategory);
}
Also used : StringTokenizer(java.util.StringTokenizer) AbilityCategory(pcgen.core.AbilityCategory)

Example 7 with AbilityCategory

use of pcgen.core.AbilityCategory in project pcgen by PCGen.

the class AbilityToken method getAbilityList.

/**
	 * Returns the correct list of abilities for the character. This method is
	 * overridden in subclasses if they need to change the list of abilities
	 * looked at.
	 * 
	 * @param pc
	 *            The character who's abilities we are retrieving.
	 * @param aCategory
	 *            The category of ability being reported.
	 * @return List of abilities.
	 */
protected MapToList<Ability, CNAbility> getAbilityList(PlayerCharacter pc, final AbilityCategory aCategory) {
    final MapToList<Ability, CNAbility> listOfAbilities = new HashMapToList<>();
    Collection<AbilityCategory> allCats = SettingsHandler.getGame().getAllAbilityCategories();
    for (AbilityCategory aCat : allCats) {
        if (AbilityCategory.ANY.equals(aCategory) || aCat.getParentCategory().equals(aCategory)) {
            for (CNAbility cna : pc.getPoolAbilities(aCat, Nature.NORMAL)) {
                listOfAbilities.addToListFor(cna.getAbility(), cna);
            }
        }
    }
    return listOfAbilities;
}
Also used : Ability(pcgen.core.Ability) CNAbility(pcgen.cdom.content.CNAbility) CNAbility(pcgen.cdom.content.CNAbility) HashMapToList(pcgen.base.util.HashMapToList) AbilityCategory(pcgen.core.AbilityCategory)

Example 8 with AbilityCategory

use of pcgen.core.AbilityCategory in project pcgen by PCGen.

the class CharacterAbilities method getTotalSelections.

/**
	 * Get the total number of selections for this category.
	 * @param categoryFacade The ability category to be retrieved.
	 * @return The total number of choices.
	 */
public int getTotalSelections(AbilityCategoryFacade categoryFacade) {
    if (categoryFacade == null || !(categoryFacade instanceof AbilityCategory)) {
        return 0;
    }
    AbilityCategory category = (AbilityCategory) categoryFacade;
    BigDecimal pool = theCharacter.getTotalAbilityPool(category);
    return pool.intValue();
}
Also used : AbilityCategory(pcgen.core.AbilityCategory) BigDecimal(java.math.BigDecimal)

Example 9 with AbilityCategory

use of pcgen.core.AbilityCategory in project pcgen by PCGen.

the class CharacterAbilities method getRemainingSelections.

/**
	 * Get the number of selections that are remaining for this category.
	 * @param categoryFacade The ability category to be retrieved.
	 * @return The number of choices left.
	 */
public int getRemainingSelections(AbilityCategoryFacade categoryFacade) {
    if (categoryFacade == null || !(categoryFacade instanceof AbilityCategory)) {
        return 0;
    }
    AbilityCategory category = (AbilityCategory) categoryFacade;
    BigDecimal pool = theCharacter.getAvailableAbilityPool(category);
    return pool.intValue();
}
Also used : AbilityCategory(pcgen.core.AbilityCategory) BigDecimal(java.math.BigDecimal)

Example 10 with AbilityCategory

use of pcgen.core.AbilityCategory in project pcgen by PCGen.

the class CharacterAbilities method updateAbilityCategoryTodo.

private void updateAbilityCategoryTodo(Category<Ability> cat) {
    if (!(cat instanceof AbilityCategory)) {
        return;
    }
    AbilityCategory category = (AbilityCategory) cat;
    int numSelections = theCharacter.getAvailableAbilityPool(category).intValue();
    if (category.getVisibility().isVisibleTo(View.HIDDEN_DISPLAY)) {
        // Hide todos for categories that should not be displayed
        numSelections = 0;
    }
    if (numSelections < 0) {
        todoManager.addTodo(new TodoFacadeImpl(Tab.ABILITIES, category.getDisplayName(), "in_featTodoTooMany", category.getType(), //$NON-NLS-1$
        1));
        //$NON-NLS-1$
        todoManager.removeTodo("in_featTodoRemain", category.getDisplayName());
    } else if (numSelections > 0) {
        todoManager.addTodo(new TodoFacadeImpl(Tab.ABILITIES, category.getDisplayName(), "in_featTodoRemain", category.getType(), //$NON-NLS-1$
        1));
        //$NON-NLS-1$
        todoManager.removeTodo("in_featTodoTooMany", category.getDisplayName());
    } else {
        //$NON-NLS-1$
        todoManager.removeTodo("in_featTodoRemain", category.getDisplayName());
        //$NON-NLS-1$
        todoManager.removeTodo("in_featTodoTooMany", category.getDisplayName());
    }
}
Also used : AbilityCategory(pcgen.core.AbilityCategory)

Aggregations

AbilityCategory (pcgen.core.AbilityCategory)72 Ability (pcgen.core.Ability)60 CNAbility (pcgen.cdom.content.CNAbility)34 HashMapToList (pcgen.base.util.HashMapToList)14 ArrayList (java.util.ArrayList)10 PlayerCharacter (pcgen.core.PlayerCharacter)10 StringTokenizer (java.util.StringTokenizer)9 Test (org.junit.Test)9 CNAbilitySelection (pcgen.cdom.helper.CNAbilitySelection)7 Nature (pcgen.cdom.enumeration.Nature)6 BigDecimal (java.math.BigDecimal)5 AssociatedPrereqObject (pcgen.cdom.base.AssociatedPrereqObject)4 CDOMObject (pcgen.cdom.base.CDOMObject)4 CDOMReference (pcgen.cdom.base.CDOMReference)4 CDOMSingleRef (pcgen.cdom.reference.CDOMSingleRef)4 PCTemplate (pcgen.core.PCTemplate)3 SpecialAbility (pcgen.core.SpecialAbility)3 BonusObj (pcgen.core.bonus.BonusObj)3 ParseResult (pcgen.rules.persistence.token.ParseResult)3 HashSet (java.util.HashSet)2