Search in sources :

Example 1 with HashMapToList

use of pcgen.base.util.HashMapToList 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 2 with HashMapToList

use of pcgen.base.util.HashMapToList in project pcgen by PCGen.

the class KitTemplate method buildSelectedTemplateMap.

/**
	 * Extract the templates to be applied and their choices
	 * @param aPC The PC the kit is being applied to.
	 * @param apply Is this a real application, false if a test run. 
	 * @return The map of templates and child templates to be added
	 */
private HashMapToList<PCTemplate, PCTemplate> buildSelectedTemplateMap(PlayerCharacter aPC, boolean apply) {
    boolean tempShowHP = SettingsHandler.getShowHPDialogAtLevelUp();
    SettingsHandler.setShowHPDialogAtLevelUp(false);
    if (!apply) {
        ChooserFactory.pushChooserClassname(//$NON-NLS-1$
        "pcgen.util.chooser.RandomChooser");
    }
    HashMapToList<PCTemplate, PCTemplate> selectedMap = new HashMapToList<>();
    for (CDOMSingleRef<PCTemplate> ref : templateList.getKeySet()) {
        PCTemplate templateToAdd = ref.get();
        List<CDOMSingleRef<PCTemplate>> subList = templateList.getListFor(ref);
        List<PCTemplate> subAdded = new ArrayList<>();
        if (subList != null) {
            for (CDOMSingleRef<PCTemplate> subRef : subList) {
                PCTemplate ownedTemplate = subRef.get();
                subAdded.add(ownedTemplate);
                aPC.setTemplatesAdded(templateToAdd, ownedTemplate);
            }
        }
        aPC.addTemplate(templateToAdd);
        selectedMap.initializeListFor(templateToAdd);
        selectedMap.addAllToListFor(templateToAdd, subAdded);
    }
    if (!apply) {
        ChooserFactory.popChooserClassname();
    }
    SettingsHandler.setShowHPDialogAtLevelUp(tempShowHP);
    return selectedMap;
}
Also used : HashMapToList(pcgen.base.util.HashMapToList) ArrayList(java.util.ArrayList) PCTemplate(pcgen.core.PCTemplate) CDOMSingleRef(pcgen.cdom.reference.CDOMSingleRef)

Example 3 with HashMapToList

use of pcgen.base.util.HashMapToList in project pcgen by PCGen.

the class VFeatListToken method getAbilityList.

/**
	 * @see pcgen.io.exporttoken.AbilityListToken#getAbilityList(pcgen.core.PlayerCharacter, pcgen.core.AbilityCategory)
	 */
@Override
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 (aCat.getParentCategory().equals(aCategory)) {
            for (CNAbility cna : pc.getPoolAbilities(aCat, Nature.VIRTUAL)) {
                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 4 with HashMapToList

use of pcgen.base.util.HashMapToList in project pcgen by PCGen.

the class VAbilityListToken method getAbilityList.

/**
	 * @see pcgen.io.exporttoken.AbilityListToken#getAbilityList(pcgen.core.PlayerCharacter, pcgen.core.AbilityCategory)
	 */
@Override
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.VIRTUAL)) {
                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 5 with HashMapToList

use of pcgen.base.util.HashMapToList in project pcgen by PCGen.

the class VAbilityToken method getAbilityList.

/**
	 * @see pcgen.io.exporttoken.AbilityToken#getAbilityList(pcgen.core.PlayerCharacter, pcgen.core.AbilityCategory)
	 */
@Override
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.VIRTUAL)) {
                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)

Aggregations

HashMapToList (pcgen.base.util.HashMapToList)24 CNAbility (pcgen.cdom.content.CNAbility)15 Ability (pcgen.core.Ability)14 AbilityCategory (pcgen.core.AbilityCategory)14 ArrayList (java.util.ArrayList)5 TreeSet (java.util.TreeSet)5 CDOMReference (pcgen.cdom.base.CDOMReference)4 HashSet (java.util.HashSet)3 Set (java.util.Set)3 AssociatedPrereqObject (pcgen.cdom.base.AssociatedPrereqObject)3 CDOMSingleRef (pcgen.cdom.reference.CDOMSingleRef)3 Prerequisite (pcgen.core.prereq.Prerequisite)3 CDOMObject (pcgen.cdom.base.CDOMObject)2 CategorizedCDOMReference (pcgen.cdom.reference.CategorizedCDOMReference)2 Qualifier (pcgen.cdom.reference.Qualifier)2 QualifiedObject (pcgen.core.QualifiedObject)2 StringWriter (java.io.StringWriter)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 IdentityHashMap (java.util.IdentityHashMap)1