use of pcgen.core.spell.Spell in project pcgen by PCGen.
the class LoadContextTest method testCloneInMasterListsAssoc.
/**
* Test method for {@link pcgen.rules.context.LoadContext#cloneInMasterLists(pcgen.cdom.base.CDOMObject, java.lang.String)}.
* Verify that associations from other objects to the object being cloned
* are copied over.
*/
public final void testCloneInMasterListsAssoc() {
final LoadContext context = Globals.getContext();
FactKey.getConstant("ClassType", new StringManager());
FactKey.getConstant("SpellType", new StringManager());
Spell testSpell = TestHelper.makeSpell("LoadContextTest");
PCClass wiz = TestHelper.makeClass("Wizard");
CDOMReference<ClassSpellList> ref = TokenUtilities.getTypeOrPrimitive(context, ClassSpellList.class, wiz.getKeyName());
AssociatedPrereqObject edge = context.getListContext().addToMasterList("CLASSES", testSpell, ref, testSpell);
edge.setAssociation(AssociationKey.SPELL_LEVEL, 1);
context.getReferenceContext().buildDerivedObjects();
assertTrue(context.getReferenceContext().resolveReferences(null));
context.commit();
Spell newSpell = context.performCopy(testSpell, "New Spell");
context.commit();
assertEquals("Old spell name incorrect", "LoadContextTest", testSpell.getDisplayName());
assertEquals("New spell name incorrect", "New Spell", newSpell.getDisplayName());
// Check associations
MasterListInterface masterLists = SettingsHandler.getGame().getMasterLists();
Collection<AssociatedPrereqObject> assoc = masterLists.getAssociations(ref, testSpell);
assertEquals("Incorrect size of assoc list for orig spell", 1, assoc.size());
AssociatedPrereqObject apo = assoc.iterator().next();
assertEquals("Incorrect level", 1, apo.getAssociation(AssociationKey.SPELL_LEVEL).intValue());
assoc = masterLists.getAssociations(ref, newSpell);
assertEquals("Incorrect size of assoc list for new spell", 1, assoc.size());
apo = assoc.iterator().next();
assertEquals("Incorrect level", 1, apo.getAssociation(AssociationKey.SPELL_LEVEL).intValue());
}
use of pcgen.core.spell.Spell in project pcgen by PCGen.
the class TestHelper method makeSpell.
/**
* Set the important info about a Spell
* @param name The spell name
* @return The spell (which has also been added to global storage)
*/
public static Spell makeSpell(final String name) {
final Spell aSpell = new Spell();
aSpell.setName(name);
aSpell.put(StringKey.KEY_NAME, ("KEY_" + name));
Globals.getContext().getReferenceContext().importObject(aSpell);
return aSpell;
}
use of pcgen.core.spell.Spell in project pcgen by PCGen.
the class PreSpellTypeTest method additionalSetUp.
/*
* (non-Javadoc)
*
* @see junit.framework.TestCase#setUp()
*/
@Override
protected void additionalSetUp() throws Exception {
LoadContext context = Globals.getContext();
wiz = context.getReferenceContext().constructCDOMObject(PCClass.class, "Wizard");
BuildUtilities.setFact(wiz, "SpellType", "Arcane");
context.unconditionallyProcess(wiz, "KNOWNSPELLS", "LEVEL=1|LEVEL=2");
context.unconditionallyProcess(wiz.getOriginalClassLevel(1), "CAST", "1,1");
context.unconditionallyProcess(wiz.getOriginalClassLevel(2), "CAST", "2,2,2");
cle = context.getReferenceContext().constructCDOMObject(PCClass.class, "Cleric");
BuildUtilities.setFact(cle, "SpellType", "Divine");
context.unconditionallyProcess(cle, "KNOWNSPELLS", "LEVEL=1|LEVEL=2");
context.unconditionallyProcess(cle.getOriginalClassLevel(1), "CAST", "1,1");
context.unconditionallyProcess(cle.getOriginalClassLevel(2), "CAST", "1,1,1");
Arcaneball = new Spell();
Arcaneball.setName("Arcaneball");
context.getReferenceContext().importObject(Arcaneball);
context.unconditionallyProcess(Arcaneball, "CLASSES", "Wizard=2");
context.unconditionallyProcess(Arcaneball, "TYPE", "Arcane");
lightning = new Spell();
lightning.setName("Lightning Bolt");
context.getReferenceContext().importObject(lightning);
context.unconditionallyProcess(lightning, "CLASSES", "Wizard=2");
context.unconditionallyProcess(lightning, "TYPE", "Arcane");
burning = new Spell();
burning.setName("Burning Hands");
context.getReferenceContext().importObject(burning);
context.unconditionallyProcess(burning, "CLASSES", "Wizard=1");
context.unconditionallyProcess(burning, "TYPE", "Arcane");
heal = new Spell();
heal.setName("Heal");
context.getReferenceContext().importObject(heal);
context.unconditionallyProcess(heal, "CLASSES", "Cleric=2");
context.unconditionallyProcess(heal, "TYPE", "Divine");
cure = new Spell();
cure.setName("Cure Light Wounds");
context.getReferenceContext().importObject(cure);
context.unconditionallyProcess(cure, "CLASSES", "Cleric=1");
context.unconditionallyProcess(cure, "TYPE", "Divine");
}
use of pcgen.core.spell.Spell in project pcgen by PCGen.
the class KnownspellsTokenTest method testUnparseTypeLevel.
@Test
public void testUnparseTypeLevel() throws PersistenceLayerException {
CDOMGroupRef<Spell> cool = primaryContext.getReferenceContext().getCDOMTypeReference(Spell.class, "Cool");
primaryProf.addToListFor(ListKey.KNOWN_SPELLS, new KnownSpellIdentifier(cool, 4));
String[] sap = getToken().unparse(primaryContext, primaryProf);
expectSingle(sap, "TYPE=Cool,LEVEL=4");
}
use of pcgen.core.spell.Spell in project pcgen by PCGen.
the class KnownspellsTokenTest method testRoundRobinComplex.
@Test
public void testRoundRobinComplex() throws PersistenceLayerException {
construct(primaryContext, "TestWP1");
construct(secondaryContext, "TestWP1");
Spell a = construct(primaryContext, "TestWP2");
a.addToListFor(ListKey.TYPE, Type.getConstant("SpellType"));
Spell c = construct(secondaryContext, "TestWP2");
c.addToListFor(ListKey.TYPE, Type.getConstant("SpellType"));
Spell b = construct(primaryContext, "TestWP3");
b.addToListFor(ListKey.TYPE, Type.getConstant("ZOther"));
b.addToListFor(ListKey.TYPE, Type.getConstant("ZType"));
Spell d = construct(secondaryContext, "TestWP3");
d.addToListFor(ListKey.TYPE, Type.getConstant("ZOther"));
d.addToListFor(ListKey.TYPE, Type.getConstant("ZType"));
runRoundRobin("TYPE=SpellType,LEVEL=0|TYPE=SpellType,LEVEL=1|TYPE=ZOther.ZType,LEVEL=1");
}
Aggregations