Search in sources :

Example 91 with CDOMObject

use of pcgen.cdom.base.CDOMObject in project pcgen by PCGen.

the class BonusConvertPlugin method processBonus.

private String processBonus(TokenProcessEvent tpe, String key, String value) {
    try {
        LoadContext context = tpe.getContext();
        CDOMObject obj = tpe.getPrimary();
        if (context.processToken(obj, key, value)) {
            context.commit();
        } else {
            context.rollback();
            Logging.replayParsedMessages();
        }
        Logging.clearParseMessages();
        Collection<String> output = context.unparse(obj);
        if (output == null || output.isEmpty()) {
            // Uh Oh
            return ("Unable to unparse: " + key + ':' + value);
        }
        boolean needTab = false;
        for (String s : output) {
            if (needTab) {
                tpe.append('\t');
            }
            needTab = true;
            tpe.append(s);
        }
        tpe.consume();
    } catch (PersistenceLayerException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return null;
}
Also used : PersistenceLayerException(pcgen.persistence.PersistenceLayerException) CDOMObject(pcgen.cdom.base.CDOMObject) EditorLoadContext(pcgen.rules.context.EditorLoadContext) LoadContext(pcgen.rules.context.LoadContext)

Example 92 with CDOMObject

use of pcgen.cdom.base.CDOMObject in project pcgen by PCGen.

the class AbstractListInputTokenTestCase method testRoundRobinTestEqualThree.

@Test
public void testRoundRobinTestEqualThree() throws PersistenceLayerException {
    if (isTypeLegal()) {
        CDOMObject a = (CDOMObject) construct(primaryContext, "Typed1");
        a.addToListFor(ListKey.TYPE, Type.getConstant("TestType"));
        a.addToListFor(ListKey.TYPE, Type.getConstant("TestAltType"));
        a.addToListFor(ListKey.TYPE, Type.getConstant("TestThirdType"));
        CDOMObject c = (CDOMObject) construct(secondaryContext, "Typed1");
        c.addToListFor(ListKey.TYPE, Type.getConstant("TestType"));
        c.addToListFor(ListKey.TYPE, Type.getConstant("TestAltType"));
        c.addToListFor(ListKey.TYPE, Type.getConstant("TestThirdType"));
        runRoundRobin("TYPE=TestAltType.TestThirdType.TestType");
    }
}
Also used : CDOMObject(pcgen.cdom.base.CDOMObject) Test(org.junit.Test)

Example 93 with CDOMObject

use of pcgen.cdom.base.CDOMObject in project pcgen by PCGen.

the class AbstractQualifierTokenTestCase method testRoundRobinQualifiedFourAndOr.

@Test
public void testRoundRobinQualifiedFourAndOr() throws PersistenceLayerException {
    CDOMObject a = construct(primaryContext, "Typed1");
    a.addToListFor(ListKey.TYPE, Type.getConstant("Type1"));
    CDOMObject b = construct(primaryContext, "Typed2");
    b.addToListFor(ListKey.TYPE, Type.getConstant("Type2"));
    CDOMObject c = construct(secondaryContext, "Typed1");
    c.addToListFor(ListKey.TYPE, Type.getConstant("Type1"));
    CDOMObject d = construct(secondaryContext, "Typed2");
    d.addToListFor(ListKey.TYPE, Type.getConstant("Type2"));
    CDOMObject e = construct(primaryContext, "Typed3");
    e.addToListFor(ListKey.TYPE, Type.getConstant("Type3"));
    CDOMObject f = construct(primaryContext, "Typed4");
    f.addToListFor(ListKey.TYPE, Type.getConstant("Type4"));
    CDOMObject g = construct(secondaryContext, "Typed3");
    g.addToListFor(ListKey.TYPE, Type.getConstant("Type3"));
    CDOMObject h = construct(secondaryContext, "Typed4");
    h.addToListFor(ListKey.TYPE, Type.getConstant("Type4"));
    runRoundRobin(getSubTokenName() + '|' + qualifier + "[!TYPE=Type1,TYPE=Type2|!TYPE=Type3,TYPE=Type4]");
}
Also used : CDOMObject(pcgen.cdom.base.CDOMObject) Test(org.junit.Test)

Example 94 with CDOMObject

use of pcgen.cdom.base.CDOMObject in project pcgen by PCGen.

the class AbstractQualifierTokenTestCase method testRoundRobinNotQualifierTestEqualThree.

@Test
public void testRoundRobinNotQualifierTestEqualThree() throws PersistenceLayerException {
    if (allowsNotQualifier()) {
        CDOMObject a = construct(primaryContext, "Typed1");
        a.addToListFor(ListKey.TYPE, Type.getConstant("TestType"));
        a.addToListFor(ListKey.TYPE, Type.getConstant("TestThirdType"));
        a.addToListFor(ListKey.TYPE, Type.getConstant("TestAltType"));
        CDOMObject c = construct(secondaryContext, "Typed1");
        c.addToListFor(ListKey.TYPE, Type.getConstant("TestType"));
        c.addToListFor(ListKey.TYPE, Type.getConstant("TestThirdType"));
        c.addToListFor(ListKey.TYPE, Type.getConstant("TestAltType"));
        runRoundRobin(getSubTokenName() + '|' + "!" + qualifier + "[TYPE=TestAltType.TestThirdType.TestType]");
    }
}
Also used : CDOMObject(pcgen.cdom.base.CDOMObject) Test(org.junit.Test)

Example 95 with CDOMObject

use of pcgen.cdom.base.CDOMObject in project pcgen by PCGen.

the class AbstractQualifierTokenTestCase method testRoundRobinNotQualifierWithEqualType.

@Test
public void testRoundRobinNotQualifierWithEqualType() throws PersistenceLayerException {
    if (allowsNotQualifier()) {
        construct(primaryContext, getTargetClass(), "TestWP1");
        construct(primaryContext, getTargetClass(), "TestWP2");
        construct(secondaryContext, getTargetClass(), "TestWP1");
        construct(secondaryContext, getTargetClass(), "TestWP2");
        CDOMObject a = construct(primaryContext, "Typed1");
        a.addToListFor(ListKey.TYPE, Type.getConstant("TestType"));
        CDOMObject b = construct(primaryContext, "Typed2");
        b.addToListFor(ListKey.TYPE, Type.getConstant("OtherTestType"));
        CDOMObject c = construct(secondaryContext, "Typed1");
        c.addToListFor(ListKey.TYPE, Type.getConstant("TestType"));
        CDOMObject d = construct(secondaryContext, "Typed2");
        d.addToListFor(ListKey.TYPE, Type.getConstant("OtherTestType"));
        runRoundRobin(getSubTokenName() + '|' + "!" + qualifier + "[TestWP1|TestWP2|TYPE=OtherTestType|TYPE=TestType]");
    }
}
Also used : CDOMObject(pcgen.cdom.base.CDOMObject) Test(org.junit.Test)

Aggregations

CDOMObject (pcgen.cdom.base.CDOMObject)235 Test (org.junit.Test)68 CharID (pcgen.cdom.enumeration.CharID)53 PCTemplate (pcgen.core.PCTemplate)30 ArrayList (java.util.ArrayList)22 PCClass (pcgen.core.PCClass)18 DataFacetChangeEvent (pcgen.cdom.facet.event.DataFacetChangeEvent)17 Race (pcgen.core.Race)17 Equipment (pcgen.core.Equipment)15 PlayerCharacter (pcgen.core.PlayerCharacter)15 Map (java.util.Map)14 AssociatedPrereqObject (pcgen.cdom.base.AssociatedPrereqObject)14 CDOMReference (pcgen.cdom.base.CDOMReference)14 BonusObj (pcgen.core.bonus.BonusObj)14 IdentityHashMap (java.util.IdentityHashMap)12 Set (java.util.Set)12 VariableKey (pcgen.cdom.enumeration.VariableKey)11 HashMap (java.util.HashMap)10 CNAbility (pcgen.cdom.content.CNAbility)10 Spell (pcgen.core.spell.Spell)9