use of pcgen.core.PCTemplate in project pcgen by PCGen.
the class GlobalSpellKnownTest method testConditional.
public void testConditional() {
Ability source = create(Ability.class, "Source");
context.getReferenceContext().reassociateCategory(AbilityCategory.FEAT, source);
ParseResult result = token.parseToken(context, source, "CLASS|Wizard=2|Fireball|PREVARLTEQ:3,MyCasterLevel");
if (result != ParseResult.SUCCESS) {
result.printMessages();
fail("Test Setup Failed");
}
finishLoad();
assertEquals(baseCount(), targetFacetCount());
CNAbilitySelection cas = new CNAbilitySelection(CNAbilityFactory.getCNAbility(AbilityCategory.FEAT, Nature.AUTOMATIC, source));
directAbilityFacet.add(id, cas, UserSelection.getInstance());
assertFalse(containsExpected());
PCTemplate varsource = create(PCTemplate.class, "VarSource");
varsource.put(VariableKey.getConstant("MyCasterLevel"), FormulaFactory.getFormulaFor(4.0));
templateInputFacet.directAdd(id, varsource, null);
pc.calcActiveBonuses();
assertTrue(containsExpected());
assertEquals(baseCount() + 1, targetFacetCount());
directAbilityFacet.remove(id, cas, UserSelection.getInstance());
pc.calcActiveBonuses();
assertEquals(baseCount(), targetFacetCount());
}
use of pcgen.core.PCTemplate in project pcgen by PCGen.
the class TemplateFavoredClassTest method testDirect.
@Test
public void testDirect() throws PersistenceLayerException {
PCTemplate source = create(PCTemplate.class, "Source");
ParseResult result = token.parseToken(context, source, "Favorite");
if (result != ParseResult.SUCCESS) {
result.printMessages();
fail("Test Setup Failed");
}
finishLoad();
assertEquals(baseCount(), targetFacetCount());
templateInputFacet.directAdd(id, source, getAssoc());
assertTrue(containsExpected());
assertEquals(baseCount() + 1, targetFacetCount());
templateInputFacet.remove(id, source);
assertEquals(baseCount(), targetFacetCount());
}
use of pcgen.core.PCTemplate in project pcgen by PCGen.
the class AbstractContentTokenTest method testFromTemplate.
@Test
public void testFromTemplate() throws PersistenceLayerException {
PCTemplate source = create(PCTemplate.class, "Source");
processToken(source);
assertEquals(baseCount(), targetFacetCount());
templateInputFacet.directAdd(id, source, getAssoc());
assertTrue(containsExpected());
assertEquals(baseCount() + 1, targetFacetCount());
templateInputFacet.remove(id, source);
assertEquals(baseCount(), targetFacetCount());
}
use of pcgen.core.PCTemplate in project pcgen by PCGen.
the class AddLevelFacet method dataRemoved.
/**
* Drives the necessary removal of the results of an ADDLEVEL: token to
* remove the added levels from a Player Character because the object
* granting the ADDLEVEL: was removed from the Player Character.
*
* Triggered when one of the Facets to which AddLevelFacet listens fires a
* DataFacetChangeEvent to indicate a CDOMObject was added to a Player
* Character.
*
* @param dfce
* The DataFacetChangeEvent containing the information about the
* change
*
* @see pcgen.cdom.facet.event.DataFacetChangeListener#dataAdded(pcgen.cdom.facet.event.DataFacetChangeEvent)
*/
@Override
public void dataRemoved(DataFacetChangeEvent<CharID, PCTemplate> dfce) {
PCTemplate template = dfce.getCDOMObject();
CharID id = dfce.getCharID();
PlayerCharacter pc = trackingFacet.getPC(id);
List<LevelCommandFactory> lcfList = template.getSafeListFor(ListKey.ADD_LEVEL);
for (ListIterator<LevelCommandFactory> it = lcfList.listIterator(lcfList.size()); it.hasPrevious(); ) {
LevelCommandFactory lcf = it.previous();
remove(lcf.getLevelCount(), lcf.getPCClass(), pc);
}
}
use of pcgen.core.PCTemplate in project pcgen by PCGen.
the class KitTemplate method apply.
/**
* Actually applies the templates to this PC.
*
* @param aPC The PlayerCharacter the alignment is applied to
*/
@Override
public void apply(PlayerCharacter aPC) {
HashMapToList<PCTemplate, PCTemplate> selectedMap = buildSelectedTemplateMap(aPC, true);
boolean tempShowHP = SettingsHandler.getShowHPDialogAtLevelUp();
SettingsHandler.setShowHPDialogAtLevelUp(false);
for (PCTemplate template : selectedMap.getKeySet()) {
List<PCTemplate> added = selectedMap.getListFor(template);
if (added != null) {
for (PCTemplate subtemplate : added) {
aPC.setTemplatesAdded(template, subtemplate);
}
}
aPC.addTemplate(template);
}
SettingsHandler.setShowHPDialogAtLevelUp(tempShowHP);
}
Aggregations