Search in sources :

Example 36 with Ability

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

the class AddAbilityVirtualTest method testMult.

@Test
public void testMult() throws PersistenceLayerException {
    TokenRegistration.register(new NoChoiceToken());
    TokenRegistration.register(new StackToken());
    Domain source = create(Domain.class, "Source");
    PCClass pcc = create(PCClass.class, "Class");
    Ability a = createGrantedObject();
    context.unconditionallyProcess(a, "MULT", "YES");
    context.unconditionallyProcess(a, "STACK", "YES");
    context.unconditionallyProcess(a, "CHOOSE", "NOCHOICE");
    runToken(source);
    processToken(source);
    assocCheck = new AssocCheck() {

        public boolean check(CNAbility g) {
            if (pc.getDetailedAssociationCount(g) == 2) {
                return true;
            } else {
                System.err.println("Incorrect Association Count");
                return false;
            }
        }
    };
    assertEquals(0, getCount());
    ClassSource classSource = new ClassSource(pcc);
    domainFacet.add(id, source, classSource);
    assertTrue(containsExpected(a));
    assertEquals(2, getCount());
    domainFacet.remove(id, source);
    assertEquals(0, getCount());
}
Also used : Ability(pcgen.core.Ability) CNAbility(pcgen.cdom.content.CNAbility) CNAbility(pcgen.cdom.content.CNAbility) NoChoiceToken(plugin.lsttokens.choose.NoChoiceToken) StackToken(plugin.lsttokens.ability.StackToken) Domain(pcgen.core.Domain) PCClass(pcgen.core.PCClass) AssocCheck(tokenmodel.testsupport.AssocCheck) ClassSource(pcgen.cdom.helper.ClassSource) Test(org.junit.Test) AbstractAddListTokenTest(tokenmodel.testsupport.AbstractAddListTokenTest)

Example 37 with Ability

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

the class AddAbilityVirtualTest method createGrantedObject.

@Override
protected Ability createGrantedObject() {
    Ability a = super.createGrantedObject();
    context.getReferenceContext().reassociateCategory(AbilityCategory.FEAT, a);
    return a;
}
Also used : Ability(pcgen.core.Ability) CNAbility(pcgen.cdom.content.CNAbility)

Example 38 with Ability

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

the class AddTargetedAbilityNormalTest method createGrantedObject.

@Override
protected Ability createGrantedObject() {
    context.getReferenceContext().constructCDOMObject(Language.class, "English");
    Ability a = super.createGrantedObject();
    ParseResult result = AUTO_LANG_TOKEN.parseToken(context, a, "%LIST");
    if (result != ParseResult.SUCCESS) {
        result.printMessages();
        fail("Test Setup Failed");
    }
    result = ABILITY_MULT_TOKEN.parseToken(context, a, "YES");
    if (result != ParseResult.SUCCESS) {
        result.printMessages();
        fail("Test Setup Failed");
    }
    result = CHOOSE_LANG_TOKEN.parseToken(context, a, "ALL");
    if (result != ParseResult.SUCCESS) {
        result.printMessages();
        fail("Test Setup Failed");
    }
    context.getReferenceContext().reassociateCategory(AbilityCategory.FEAT, a);
    return a;
}
Also used : Ability(pcgen.core.Ability) CNAbility(pcgen.cdom.content.CNAbility) ParseResult(pcgen.rules.persistence.token.ParseResult)

Example 39 with Ability

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

the class AddTargetedAbilityVirtualTest method createGrantedObject.

@Override
protected Ability createGrantedObject() {
    context.getReferenceContext().constructCDOMObject(Language.class, "English");
    Ability a = super.createGrantedObject();
    ParseResult result = AUTO_LANG_TOKEN.parseToken(context, a, "%LIST");
    if (result != ParseResult.SUCCESS) {
        result.printMessages();
        fail("Test Setup Failed");
    }
    result = ABILITY_MULT_TOKEN.parseToken(context, a, "YES");
    if (result != ParseResult.SUCCESS) {
        result.printMessages();
        fail("Test Setup Failed");
    }
    result = CHOOSE_LANG_TOKEN.parseToken(context, a, "ALL");
    if (result != ParseResult.SUCCESS) {
        result.printMessages();
        fail("Test Setup Failed");
    }
    context.getReferenceContext().reassociateCategory(AbilityCategory.FEAT, a);
    return a;
}
Also used : Ability(pcgen.core.Ability) CNAbility(pcgen.cdom.content.CNAbility) ParseResult(pcgen.rules.persistence.token.ParseResult)

Example 40 with Ability

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

the class GlobalSpellKnownTest method testConditional.

public void testConditional() {
    Ability source = create(Ability.class, "Source");
    context.getReferenceContext().reassociateCategory(AbilityCategory.FEAT, source);
    ParseResult result = token.parseToken(context, source, "CLASS|Wizard=2|Fireball|PREVARLTEQ:3,MyCasterLevel");
    if (result != ParseResult.SUCCESS) {
        result.printMessages();
        fail("Test Setup Failed");
    }
    finishLoad();
    assertEquals(baseCount(), targetFacetCount());
    CNAbilitySelection cas = new CNAbilitySelection(CNAbilityFactory.getCNAbility(AbilityCategory.FEAT, Nature.AUTOMATIC, source));
    directAbilityFacet.add(id, cas, UserSelection.getInstance());
    assertFalse(containsExpected());
    PCTemplate varsource = create(PCTemplate.class, "VarSource");
    varsource.put(VariableKey.getConstant("MyCasterLevel"), FormulaFactory.getFormulaFor(4.0));
    templateInputFacet.directAdd(id, varsource, null);
    pc.calcActiveBonuses();
    assertTrue(containsExpected());
    assertEquals(baseCount() + 1, targetFacetCount());
    directAbilityFacet.remove(id, cas, UserSelection.getInstance());
    pc.calcActiveBonuses();
    assertEquals(baseCount(), targetFacetCount());
}
Also used : Ability(pcgen.core.Ability) ParseResult(pcgen.rules.persistence.token.ParseResult) CNAbilitySelection(pcgen.cdom.helper.CNAbilitySelection) PCTemplate(pcgen.core.PCTemplate)

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