Search in sources :

Example 1 with SimpleAssociatedObject

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

the class ConsolidatedListCommitStrategy method addToList.

@Override
public <T extends CDOMObject> AssociatedPrereqObject addToList(String tokenName, CDOMObject owner, CDOMReference<? extends CDOMList<? super T>> list, CDOMReference<T> allowed) {
    SimpleAssociatedObject a = new SimpleAssociatedObject();
    a.setAssociation(AssociationKey.TOKEN, tokenName);
    owner.putToList(list, allowed, a);
    return a;
}
Also used : SimpleAssociatedObject(pcgen.cdom.base.SimpleAssociatedObject)

Example 2 with SimpleAssociatedObject

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

the class DomainsTokenTest method testRoundRobinUnparseDirect.

@Test
public void testRoundRobinUnparseDirect() throws PersistenceLayerException {
    construct(primaryContext, "TestWP1");
    construct(primaryContext, "TestWP2");
    AssociatedPrereqObject apo = new SimpleAssociatedObject();
    apo.setAssociation(AssociationKey.TOKEN, "DOMAINS");
    primaryProf.putToList(Deity.DOMAINLIST, CDOMDirectSingleRef.getRef(primaryContext.getReferenceContext().silentlyGetConstructedCDOMObject(getTargetClass(), "TestWP1")), apo);
    primaryProf.putToList(Deity.DOMAINLIST, CDOMDirectSingleRef.getRef(primaryContext.getReferenceContext().silentlyGetConstructedCDOMObject(getTargetClass(), "TestWP2")), apo);
    String[] unparsed = getToken().unparse(primaryContext, primaryProf);
    assertNotNull(unparsed);
    assertEquals(1, unparsed.length);
    assertEquals("TestWP1,TestWP2", unparsed[0]);
}
Also used : AssociatedPrereqObject(pcgen.cdom.base.AssociatedPrereqObject) SimpleAssociatedObject(pcgen.cdom.base.SimpleAssociatedObject) Test(org.junit.Test)

Example 3 with SimpleAssociatedObject

use of pcgen.cdom.base.SimpleAssociatedObject 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 4 with SimpleAssociatedObject

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

the class PreVisionTest method testVisionNotPresentZero.

/**
	 * @throws Exception
	 */
public void testVisionNotPresentZero() throws Exception {
    final PlayerCharacter character = getCharacter();
    final PCTemplate template = new PCTemplate();
    final Prerequisite prereq = new Prerequisite();
    prereq.setKind("vision");
    prereq.setKey("darkvision");
    prereq.setOperator(PrerequisiteOperator.LT);
    prereq.setOperand("ANY");
    boolean passes = PrereqHandler.passes(prereq, character, null);
    assertTrue(passes);
    template.putToList(Vision.VISIONLIST, CDOMDirectSingleRef.getRef(new Vision(VisionType.getVisionType("Darkvision"), FormulaFactory.ZERO)), new SimpleAssociatedObject());
    character.addTemplate(template);
    passes = PrereqHandler.passes(prereq, character, null);
    assertFalse(passes);
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) Vision(pcgen.core.Vision) PCTemplate(pcgen.core.PCTemplate) SimpleAssociatedObject(pcgen.cdom.base.SimpleAssociatedObject)

Example 5 with SimpleAssociatedObject

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

the class PreVisionTest method testVisionNotZeroZero.

/**
	 * @throws Exception
	 */
public void testVisionNotZeroZero() throws Exception {
    final PlayerCharacter character = getCharacter();
    final PCTemplate template = new PCTemplate();
    final Prerequisite prereq = new Prerequisite();
    prereq.setKind("vision");
    prereq.setKey("darkvision");
    prereq.setOperator(PrerequisiteOperator.LT);
    prereq.setOperand("0");
    boolean passes = PrereqHandler.passes(prereq, character, null);
    assertFalse(passes);
    template.putToList(Vision.VISIONLIST, CDOMDirectSingleRef.getRef(new Vision(VisionType.getVisionType("Darkvision"), FormulaFactory.ZERO)), new SimpleAssociatedObject());
    character.addTemplate(template);
    passes = PrereqHandler.passes(prereq, character, null);
    assertFalse(passes);
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) Vision(pcgen.core.Vision) PCTemplate(pcgen.core.PCTemplate) SimpleAssociatedObject(pcgen.cdom.base.SimpleAssociatedObject)

Aggregations

SimpleAssociatedObject (pcgen.cdom.base.SimpleAssociatedObject)19 PCTemplate (pcgen.core.PCTemplate)13 Vision (pcgen.core.Vision)12 PlayerCharacter (pcgen.core.PlayerCharacter)11 CDOMObject (pcgen.cdom.base.CDOMObject)2 CDOMDirectSingleRef (pcgen.cdom.reference.CDOMDirectSingleRef)2 Deity (pcgen.core.Deity)2 Domain (pcgen.core.Domain)2 Race (pcgen.core.Race)2 Test (org.junit.Test)1 AssociatedPrereqObject (pcgen.cdom.base.AssociatedPrereqObject)1 Language (pcgen.core.Language)1 QualifiedObject (pcgen.core.QualifiedObject)1