Search in sources :

Example 11 with HashMapToList

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

the class AbilityAllListToken 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.NORMAL)) {
                listOfAbilities.addToListFor(cna.getAbility(), cna);
            }
            for (CNAbility cna : pc.getPoolAbilities(aCat, Nature.AUTOMATIC)) {
                listOfAbilities.addToListFor(cna.getAbility(), cna);
            }
            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 12 with HashMapToList

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

the class AbilityAllToken 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.NORMAL)) {
                listOfAbilities.addToListFor(cna.getAbility(), cna);
            }
            for (CNAbility cna : pc.getPoolAbilities(aCat, Nature.AUTOMATIC)) {
                listOfAbilities.addToListFor(cna.getAbility(), cna);
            }
            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 13 with HashMapToList

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

the class VFeatToken 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 (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 14 with HashMapToList

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

the class ChangeprofLst method unparse.

@Override
public String[] unparse(LoadContext context, CDOMObject obj) {
    Changes<ChangeProf> changes = context.getObjectContext().getListChanges(obj, ListKey.CHANGEPROF);
    Collection<ChangeProf> added = changes.getAdded();
    if (added == null || added.isEmpty()) {
        // Zero indicates no Token
        return null;
    }
    HashMapToList<CDOMGroupRef<WeaponProf>, CDOMReference<WeaponProf>> m = new HashMapToList<>();
    for (ChangeProf cp : added) {
        CDOMReference<WeaponProf> source = cp.getSource();
        CDOMGroupRef<WeaponProf> result = cp.getResult();
        m.addToListFor(result, source);
    }
    SortedSet<CDOMReference<WeaponProf>> set = new TreeSet<>(ReferenceUtilities.REFERENCE_SORTER);
    Set<String> returnSet = new TreeSet<>();
    for (CDOMGroupRef<WeaponProf> result : m.getKeySet()) {
        StringBuilder sb = new StringBuilder();
        boolean needComma = false;
        set.clear();
        set.addAll(m.getListFor(result));
        for (CDOMReference<WeaponProf> source : set) {
            if (needComma) {
                sb.append(Constants.COMMA);
            }
            needComma = true;
            String sourceLst = source.getLSTformat(false);
            if (sourceLst.startsWith(Constants.LST_TYPE_EQUAL)) {
                sb.append(Constants.LST_TYPE_DOT);
                sb.append(sourceLst.substring(5));
            } else {
                sb.append(sourceLst);
            }
        }
        sb.append(Constants.EQUALS).append(result.getLSTformat(false).substring(5));
        returnSet.add(sb.toString());
    }
    return new String[] { StringUtil.join(returnSet, Constants.PIPE) };
}
Also used : WeaponProf(pcgen.core.WeaponProf) HashMapToList(pcgen.base.util.HashMapToList) ChangeProf(pcgen.cdom.content.ChangeProf) CDOMGroupRef(pcgen.cdom.reference.CDOMGroupRef) TreeSet(java.util.TreeSet) CDOMReference(pcgen.cdom.base.CDOMReference)

Example 15 with HashMapToList

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

the class FeatAutoToken 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 (aCat.getParentCategory().equals(aCategory)) {
            for (CNAbility cna : pc.getPoolAbilities(aCat, Nature.AUTOMATIC)) {
                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