Search in sources :

Example 96 with Ability

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

the class AbilityTokenTest method testRoundRobinType.

@Test
public void testRoundRobinType() throws PersistenceLayerException {
    Ability ab = primaryContext.getReferenceContext().constructCDOMObject(Ability.class, "Fireball");
    primaryContext.getReferenceContext().reassociateCategory(AbilityCategory.FEAT, ab);
    ab.addToListFor(ListKey.TYPE, Type.getConstant("Test"));
    ab = secondaryContext.getReferenceContext().constructCDOMObject(Ability.class, "Fireball");
    secondaryContext.getReferenceContext().reassociateCategory(AbilityCategory.FEAT, ab);
    ab.addToListFor(ListKey.TYPE, Type.getConstant("Test"));
    runRoundRobin("CATEGORY=FEAT|TYPE=Test");
}
Also used : Ability(pcgen.core.Ability) Test(org.junit.Test)

Example 97 with Ability

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

the class PCQualifierTokenTest method construct.

@Override
protected CDOMObject construct(LoadContext loadContext, String one) {
    Ability a = (Ability) super.construct(loadContext, one);
    loadContext.getReferenceContext().reassociateCategory(AbilityCategory.FEAT, a);
    return a;
}
Also used : Ability(pcgen.core.Ability)

Example 98 with Ability

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

the class AbilityToken method removeChoice.

@Override
public void removeChoice(PlayerCharacter pc, CDOMObject owner, CNAbilitySelection choice) {
    CNAbility cna = choice.getCNAbility();
    Ability ab = cna.getAbility();
    AbilityCategory cat = (AbilityCategory) cna.getAbilityCategory();
    if (cna.getNature().equals(Nature.NORMAL)) {
        pc.adjustAbilities(cat, ab.getSafe(ObjectKey.SELECTION_COST).negate());
        pc.removeAbility(choice, UserSelection.getInstance(), UserSelection.getInstance());
    } else {
        pc.removeSavedAbility(choice, UserSelection.getInstance(), UserSelection.getInstance());
    }
}
Also used : CNAbility(pcgen.cdom.content.CNAbility) Ability(pcgen.core.Ability) CNAbility(pcgen.cdom.content.CNAbility) AbilityCategory(pcgen.core.AbilityCategory)

Example 99 with Ability

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

the class AbilityToken method applyChoice.

@Override
public void applyChoice(CDOMObject owner, CNAbilitySelection choice, PlayerCharacter pc) {
    CNAbility cna = choice.getCNAbility();
    Ability ab = cna.getAbility();
    AbilityCategory cat = (AbilityCategory) cna.getAbilityCategory();
    boolean isVirtual = Nature.VIRTUAL.equals(cna.getNature());
    if (isVirtual) {
        pc.addSavedAbility(choice, UserSelection.getInstance(), UserSelection.getInstance());
    } else {
        pc.addAbility(choice, UserSelection.getInstance(), UserSelection.getInstance());
        pc.adjustAbilities(cat, ab.getSafe(ObjectKey.SELECTION_COST));
    }
}
Also used : CNAbility(pcgen.cdom.content.CNAbility) Ability(pcgen.core.Ability) CNAbility(pcgen.cdom.content.CNAbility) AbilityCategory(pcgen.core.AbilityCategory)

Example 100 with Ability

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

the class AbilityToken method allow.

@Override
public boolean allow(CNAbilitySelection choice, PlayerCharacter pc, boolean allowStack) {
    CNAbility cna = choice.getCNAbility();
    Ability ability = cna.getAbility();
    if (!ability.getSafe(ObjectKey.VISIBILITY).equals(Visibility.DEFAULT)) {
        return false;
    }
    boolean isVirtual = Nature.VIRTUAL.equals(cna.getNature());
    if (!isVirtual && !ability.qualifies(pc, ability)) {
        return false;
    }
    String selection = choice.getSelection();
    // Avoid any already selected
    return !AbilityUtilities.alreadySelected(pc, ability, selection, allowStack);
}
Also used : CNAbility(pcgen.cdom.content.CNAbility) Ability(pcgen.core.Ability) CNAbility(pcgen.cdom.content.CNAbility)

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