Search in sources :

Example 26 with ParseResult

use of pcgen.rules.persistence.token.ParseResult in project pcgen by PCGen.

the class RaceMonCSkillTest method testDirect.

@Test
public void testDirect() throws PersistenceLayerException {
    Race source = create(Race.class, "Source");
    ParseResult result = token.parseToken(context, source, "MySkill");
    if (result != ParseResult.SUCCESS) {
        result.printMessages();
        fail("Test Setup Failed");
    }
    finishLoad();
    raceFacet.directSet(id, source, getAssoc());
    ClassSkillList dragonCSL = context.getReferenceContext().silentlyGetConstructedCDOMObject(ClassSkillList.class, "Dragon");
    assertTrue(lscFacet.contains(id, dragonCSL, SkillCost.CLASS, sk));
    assertEquals(SkillCost.CROSS_CLASS, pc.getSkillCostForClass(sk, dragon));
    pc.incrementClassLevel(1, dragon);
    assertEquals(SkillCost.CLASS, pc.getSkillCostForClass(sk, dragon));
    raceFacet.remove(id);
    assertFalse(lscFacet.contains(id, dragonCSL, SkillCost.CLASS, sk));
}
Also used : ParseResult(pcgen.rules.persistence.token.ParseResult) Race(pcgen.core.Race) ClassSkillList(pcgen.cdom.list.ClassSkillList) Test(org.junit.Test) AbstractTokenModelTest(tokenmodel.testsupport.AbstractTokenModelTest)

Example 27 with ParseResult

use of pcgen.rules.persistence.token.ParseResult in project pcgen by PCGen.

the class SkillClassesTest method testDirect.

@Test
public void testDirect() throws PersistenceLayerException {
    ParseResult result = token.parseToken(context, sk, "Dragon");
    if (result != ParseResult.SUCCESS) {
        result.printMessages();
        fail("Test Setup Failed");
    }
    finishLoad();
    pc.incrementClassLevel(1, dragon);
    assertEquals(SkillCost.CLASS, pc.getSkillCostForClass(sk, dragon));
}
Also used : ParseResult(pcgen.rules.persistence.token.ParseResult) Test(org.junit.Test) AbstractTokenModelTest(tokenmodel.testsupport.AbstractTokenModelTest)

Example 28 with ParseResult

use of pcgen.rules.persistence.token.ParseResult 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)

Example 29 with ParseResult

use of pcgen.rules.persistence.token.ParseResult in project pcgen by PCGen.

the class GlobalUdamTest method processToken.

@Override
public void processToken(CDOMObject source) {
    ParseResult result = token.parseToken(context, source, "7");
    if (result != ParseResult.SUCCESS) {
        result.printMessages();
        fail("Test Setup Failed");
    }
    finishLoad();
}
Also used : ParseResult(pcgen.rules.persistence.token.ParseResult)

Example 30 with ParseResult

use of pcgen.rules.persistence.token.ParseResult in project pcgen by PCGen.

the class GlobalUnencumberedMoveLoadTest method processToken.

@Override
public void processToken(CDOMObject source) {
    ParseResult result = token.parseToken(context, source, "LightLoad");
    if (result != ParseResult.SUCCESS) {
        result.printMessages();
        fail("Test Setup Failed");
    }
    finishLoad();
}
Also used : ParseResult(pcgen.rules.persistence.token.ParseResult)

Aggregations

ParseResult (pcgen.rules.persistence.token.ParseResult)210 StringTokenizer (java.util.StringTokenizer)68 Test (org.junit.Test)45 CDOMReference (pcgen.cdom.base.CDOMReference)30 AbstractTokenModelTest (tokenmodel.testsupport.AbstractTokenModelTest)26 Ability (pcgen.core.Ability)21 ArrayList (java.util.ArrayList)18 Formula (pcgen.base.formula.Formula)18 ParsingSeparator (pcgen.base.text.ParsingSeparator)18 Prerequisite (pcgen.core.prereq.Prerequisite)18 PCClass (pcgen.core.PCClass)17 Ungranted (pcgen.cdom.base.Ungranted)15 PCTemplate (pcgen.core.PCTemplate)14 CNAbility (pcgen.cdom.content.CNAbility)13 PersistenceLayerException (pcgen.persistence.PersistenceLayerException)11 ComplexParseResult (pcgen.rules.persistence.token.ComplexParseResult)11 BigDecimal (java.math.BigDecimal)10 Race (pcgen.core.Race)10 ConcretePersistentTransitionChoice (pcgen.cdom.base.ConcretePersistentTransitionChoice)9 LegalScope (pcgen.base.formula.base.LegalScope)8