Search in sources :

Example 71 with Ability

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

the class Aspect method printAspect.

public static String printAspect(PlayerCharacter pc, AspectName key, List<CNAbility> abilities, boolean printName) {
    if (abilities.isEmpty()) {
        return "";
    }
    Ability sampleAbilityObject = abilities.get(0).getAbility();
    StringBuilder buff = new StringBuilder(50);
    List<Aspect> aspects = sampleAbilityObject.get(MapKey.ASPECT, key);
    Aspect aspect = lastPassingAspect(aspects, pc, sampleAbilityObject);
    if (aspect != null) {
        if (printName) {
            buff.append(aspect.getName()).append(": ");
        }
        buff.append(aspect.getAspectText(pc, abilities));
    }
    return buff.toString();
}
Also used : Ability(pcgen.core.Ability) CNAbility(pcgen.cdom.content.CNAbility)

Example 72 with Ability

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

the class CNAbilitySelectionUtilities method canCoExist.

public static boolean canCoExist(CNAbilitySelection cnas1, CNAbilitySelection cnas2) {
    CNAbility cna = cnas1.getCNAbility();
    Ability a = cna.getAbility();
    CNAbility ocna = cnas2.getCNAbility();
    if (!ocna.getAbilityCategory().getParentCategory().equals(cna.getAbilityCategory().getParentCategory())) {
        //This test is only required because Ability only checks key :/
        return true;
    }
    if (!ocna.getAbility().equals(a)) {
        //Different abilities, so doesn't matter...
        return true;
    }
    //Same ability here
    if (!a.getSafe(ObjectKey.MULTIPLE_ALLOWED)) {
        //If MULT:NO, then can't coexist...
        return false;
    }
    //MULT:YES here
    if (a.getSafe(ObjectKey.STACKS)) {
        //Allows stacking, so always true (give or take NUMCHOICES?)
        return true;
    }
    //STACK:NO here
    if (cnas1.getSelection().equals(cnas2.getSelection())) {
        //enforce STACK:NO
        return false;
    }
    return true;
}
Also used : CNAbility(pcgen.cdom.content.CNAbility) Ability(pcgen.core.Ability) CNAbility(pcgen.cdom.content.CNAbility)

Example 73 with Ability

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

the class AbilityTargetSelector method applyChoice.

@Override
public void applyChoice(ChooseDriver obj, T choice, PlayerCharacter pc) {
    Ability ab = ability.get();
    ChooseInformation ci = ab.get(ObjectKey.CHOOSE_INFO);
    detailedApply(obj, ci, choice, pc);
}
Also used : Ability(pcgen.core.Ability) ChooseInformation(pcgen.cdom.base.ChooseInformation)

Example 74 with Ability

use of pcgen.core.Ability 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 75 with Ability

use of pcgen.core.Ability 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)

Aggregations

Ability (pcgen.core.Ability)279 CNAbility (pcgen.cdom.content.CNAbility)128 AbilityCategory (pcgen.core.AbilityCategory)60 PlayerCharacter (pcgen.core.PlayerCharacter)54 Test (org.junit.Test)46 ArrayList (java.util.ArrayList)43 CNAbilitySelection (pcgen.cdom.helper.CNAbilitySelection)25 ParseResult (pcgen.rules.persistence.token.ParseResult)21 HashMapToList (pcgen.base.util.HashMapToList)15 PCClass (pcgen.core.PCClass)15 Spell (pcgen.core.spell.Spell)15 StringTokenizer (java.util.StringTokenizer)14 TestContext (plugin.lsttokens.editcontext.testsupport.TestContext)13 LoadContext (pcgen.rules.context.LoadContext)12 SpecialAbility (pcgen.core.SpecialAbility)11 CharacterSpell (pcgen.core.character.CharacterSpell)11 PreParserFactory (pcgen.persistence.lst.prereq.PreParserFactory)11 List (java.util.List)10 CDOMObject (pcgen.cdom.base.CDOMObject)10 CDOMSingleRef (pcgen.cdom.reference.CDOMSingleRef)10