Search in sources :

Example 71 with PCTemplate

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

the class VariableFacetTest method testAddEmptyObject.

@Test
public void testAddEmptyObject() {
    Object source = new Object();
    CDOMObject t1 = new PCTemplate();
    DataFacetChangeEvent<CharID, CDOMObject> dfce = new DataFacetChangeEvent<>(id, t1, source, DataFacetChangeEvent.DATA_ADDED);
    getFacet().dataAdded(dfce);
    VariableKey vk = VariableKey.getConstant("Var1");
    assertFalse(getFacet().contains(id, vk));
}
Also used : DataFacetChangeEvent(pcgen.cdom.facet.event.DataFacetChangeEvent) CDOMObject(pcgen.cdom.base.CDOMObject) VariableKey(pcgen.cdom.enumeration.VariableKey) CDOMObject(pcgen.cdom.base.CDOMObject) PCTemplate(pcgen.core.PCTemplate) CharID(pcgen.cdom.enumeration.CharID) Test(org.junit.Test)

Example 72 with PCTemplate

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

the class VariableFacetTest method testAddRemove1First.

@Test
public void testAddRemove1First() {
    Object source = new Object();
    CDOMObject t1 = new PCTemplate();
    CDOMObject t2 = new PCTemplate();
    VariableKey vk = VariableKey.getConstant("Var1");
    t1.put(vk, FormulaFactory.getFormulaFor(2));
    t2.put(vk, FormulaFactory.getFormulaFor(4));
    DataFacetChangeEvent<CharID, CDOMObject> dfce = new DataFacetChangeEvent<>(id, t1, source, DataFacetChangeEvent.DATA_ADDED);
    getFacet().dataAdded(dfce);
    assertTrue(getFacet().contains(id, vk));
    assertFalse(getFacet().contains(altid, vk));
    assertFalse(getFacet().contains(id, VariableKey.getConstant("Var2")));
    dfce = new DataFacetChangeEvent<>(id, t2, source, DataFacetChangeEvent.DATA_ADDED);
    getFacet().dataAdded(dfce);
    assertTrue(getFacet().contains(id, vk));
    assertFalse(getFacet().contains(altid, vk));
    assertFalse(getFacet().contains(id, VariableKey.getConstant("Var2")));
    dfce = new DataFacetChangeEvent<>(id, t1, source, DataFacetChangeEvent.DATA_REMOVED);
    getFacet().dataRemoved(dfce);
    assertTrue(getFacet().contains(id, vk));
    dfce = new DataFacetChangeEvent<>(id, t2, source, DataFacetChangeEvent.DATA_REMOVED);
    getFacet().dataRemoved(dfce);
    assertFalse(getFacet().contains(id, vk));
}
Also used : DataFacetChangeEvent(pcgen.cdom.facet.event.DataFacetChangeEvent) CDOMObject(pcgen.cdom.base.CDOMObject) VariableKey(pcgen.cdom.enumeration.VariableKey) CDOMObject(pcgen.cdom.base.CDOMObject) PCTemplate(pcgen.core.PCTemplate) CharID(pcgen.cdom.enumeration.CharID) Test(org.junit.Test)

Example 73 with PCTemplate

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

the class VariableFacetTest method testUselessRemove.

@Test
public void testUselessRemove() {
    Object source = new Object();
    CDOMObject t1 = new PCTemplate();
    VariableKey vk1 = VariableKey.getConstant("Var1");
    DataFacetChangeEvent<CharID, CDOMObject> dfce = new DataFacetChangeEvent<>(id, t1, source, DataFacetChangeEvent.DATA_REMOVED);
    getFacet().dataRemoved(dfce);
    assertFalse(getFacet().contains(id, vk1));
}
Also used : DataFacetChangeEvent(pcgen.cdom.facet.event.DataFacetChangeEvent) CDOMObject(pcgen.cdom.base.CDOMObject) VariableKey(pcgen.cdom.enumeration.VariableKey) CDOMObject(pcgen.cdom.base.CDOMObject) PCTemplate(pcgen.core.PCTemplate) CharID(pcgen.cdom.enumeration.CharID) Test(org.junit.Test)

Example 74 with PCTemplate

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

the class VisionFacetTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    CDOMObject cdo1 = new PCTemplate();
    cdo1.setName("Template1");
    CDOMObject cdo2 = new Race();
    cdo2.setName("Race1");
    Vision vision1 = new Vision(VisionType.getVisionType("Normal"), FormulaFactory.getFormulaFor(30));
    Vision vision2 = new Vision(VisionType.getVisionType("Darkvision"), FormulaFactory.getFormulaFor(20));
    CDOMDirectSingleRef<Vision> ref1 = new CDOMDirectSingleRef<>(vision1);
    SimpleAssociatedObject apo1 = new SimpleAssociatedObject();
    cdo1.putToList(Vision.VISIONLIST, ref1, apo1);
    CDOMDirectSingleRef<Vision> ref2 = new CDOMDirectSingleRef<>(vision2);
    SimpleAssociatedObject apo2 = new SimpleAssociatedObject();
    cdo2.putToList(Vision.VISIONLIST, ref2, apo2);
    QualifiedObject<Vision> st1 = new QualifiedObject<>(vision1);
    QualifiedObject<Vision> st2 = new QualifiedObject<>(vision2);
    source = new CDOMObject[] { cdo1, cdo2 };
    target = new QualifiedObject[] { st1, st2 };
}
Also used : CDOMDirectSingleRef(pcgen.cdom.reference.CDOMDirectSingleRef) QualifiedObject(pcgen.core.QualifiedObject) CDOMObject(pcgen.cdom.base.CDOMObject) Vision(pcgen.core.Vision) Race(pcgen.core.Race) PCTemplate(pcgen.core.PCTemplate) SimpleAssociatedObject(pcgen.cdom.base.SimpleAssociatedObject)

Example 75 with PCTemplate

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

the class HandedFacetTest method testWithNothingInTemplates.

@Test
public void testWithNothingInTemplates() {
    tfacet.add(id, new PCTemplate(), this);
    assertEquals(Handed.getDefaultValue(), facet.getHanded(id));
}
Also used : PCTemplate(pcgen.core.PCTemplate) Test(org.junit.Test)

Aggregations

PCTemplate (pcgen.core.PCTemplate)215 Test (org.junit.Test)105 Race (pcgen.core.Race)66 PlayerCharacter (pcgen.core.PlayerCharacter)38 CDOMObject (pcgen.cdom.base.CDOMObject)31 ArrayList (java.util.ArrayList)19 CharID (pcgen.cdom.enumeration.CharID)18 ParseResult (pcgen.rules.persistence.token.ParseResult)14 SimpleAssociatedObject (pcgen.cdom.base.SimpleAssociatedObject)13 Vision (pcgen.core.Vision)12 LoadContext (pcgen.rules.context.LoadContext)12 PCClass (pcgen.core.PCClass)11 StringTokenizer (java.util.StringTokenizer)10 VariableKey (pcgen.cdom.enumeration.VariableKey)8 DataFacetChangeEvent (pcgen.cdom.facet.event.DataFacetChangeEvent)8 Ability (pcgen.core.Ability)8 Formula (pcgen.base.formula.Formula)6 Equipment (pcgen.core.Equipment)6 PCStat (pcgen.core.PCStat)6 AbstractTokenModelTest (tokenmodel.testsupport.AbstractTokenModelTest)6