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;
}
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]);
}
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 };
}
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);
}
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);
}
Aggregations