Search in sources :

Example 66 with CNAbility

use of pcgen.cdom.content.CNAbility in project pcgen by PCGen.

the class CNAbilitySelectionUtilitiesTest method testStack.

@Test
public void testStack() {
    CNAbility n1 = CNAbilityFactory.getCNAbility(feat, Nature.NORMAL, stackyes);
    CNAbility n2 = CNAbilityFactory.getCNAbility(feat, Nature.NORMAL, stackyes);
    CNAbilitySelection cnas1 = new CNAbilitySelection(n1, "English");
    CNAbilitySelection cnas2 = new CNAbilitySelection(n2, "English");
    assertTrue(CNAbilitySelectionUtilities.canCoExist(cnas1, cnas2));
}
Also used : CNAbility(pcgen.cdom.content.CNAbility) Test(org.junit.Test)

Example 67 with CNAbility

use of pcgen.cdom.content.CNAbility in project pcgen by PCGen.

the class AbilityTargetSaveRestoreTest method remove.

@Override
protected void remove(Object o) {
    Ability abil = (Ability) o;
    CNAbility cna = CNAbilityFactory.getCNAbility(AbilityCategory.FEAT, Nature.NORMAL, abil);
    String assoc = null;
    if (ChooseActivation.hasNewChooseToken(abil)) {
        assoc = "Granted";
    }
    CNAbilitySelection cnas = new CNAbilitySelection(cna, assoc);
    reloadedPC.removeAbility(cnas, UserSelection.getInstance(), UserSelection.getInstance());
    //TODO These need to be moved into being core behaviors somehow
    CDOMObjectUtilities.removeAdds(abil, reloadedPC);
    CDOMObjectUtilities.restoreRemovals(abil, reloadedPC);
    reloadedPC.adjustMoveRates();
}
Also used : Ability(pcgen.core.Ability) CNAbility(pcgen.cdom.content.CNAbility) CNAbility(pcgen.cdom.content.CNAbility) CNAbilitySelection(pcgen.cdom.helper.CNAbilitySelection)

Example 68 with CNAbility

use of pcgen.cdom.content.CNAbility 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 69 with CNAbility

use of pcgen.cdom.content.CNAbility in project pcgen by PCGen.

the class FeatToken method getList.

private <R> List<R> getList(PlayerCharacter pc, Ability a) {
    // workaround for cloning issue
    List<R> availableList = new ArrayList<>();
    List<CNAbility> theFeats = pc.getMatchingCNAbilities(a);
    for (CNAbility ability : theFeats) {
        @SuppressWarnings("unchecked") List<? extends R> list = (List<? extends R>) pc.getDetailedAssociations(ability);
        if (list != null) {
            availableList.addAll(list);
        }
    }
    return availableList;
}
Also used : CNAbility(pcgen.cdom.content.CNAbility) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 70 with CNAbility

use of pcgen.cdom.content.CNAbility in project pcgen by PCGen.

the class AbstractCharacterTestCase method removeAbility.

protected void removeAbility(AbilityCategory cat, Ability a) {
    if (a.getSafe(ObjectKey.MULTIPLE_ALLOWED)) {
        fail("addAbility takes Mult:NO Abilities");
    }
    CNAbility cna = CNAbilityFactory.getCNAbility(cat, Nature.NORMAL, a);
    character.removeAbility(new CNAbilitySelection(cna, null), UserSelection.getInstance(), UserSelection.getInstance());
}
Also used : CNAbility(pcgen.cdom.content.CNAbility) CNAbilitySelection(pcgen.cdom.helper.CNAbilitySelection)

Aggregations

CNAbility (pcgen.cdom.content.CNAbility)131 Ability (pcgen.core.Ability)77 ArrayList (java.util.ArrayList)37 CNAbilitySelection (pcgen.cdom.helper.CNAbilitySelection)28 AbilityCategory (pcgen.core.AbilityCategory)26 Test (org.junit.Test)21 HashMapToList (pcgen.base.util.HashMapToList)16 List (java.util.List)15 PlayerCharacter (pcgen.core.PlayerCharacter)9 Language (pcgen.core.Language)7 HashSet (java.util.HashSet)5 Nature (pcgen.cdom.enumeration.Nature)5 SpecialAbility (pcgen.core.SpecialAbility)5 BonusObj (pcgen.core.bonus.BonusObj)5 BigDecimal (java.math.BigDecimal)4 CDOMObject (pcgen.cdom.base.CDOMObject)4 LoadContext (pcgen.rules.context.LoadContext)4 StringTokenizer (java.util.StringTokenizer)3 GenericMapToList (pcgen.base.util.GenericMapToList)3 PCClass (pcgen.core.PCClass)3