use of pcgen.core.PCTemplate in project pcgen by PCGen.
the class StatIntegrationTest method testUnlockNotOverrideNonAbilityLockComplex.
@Test
public void testUnlockNotOverrideNonAbilityLockComplex() {
testNonAbilityUnset();
Race r = new Race();
causeLockNonAbility(r, stat1);
rfacet.set(id, r);
assertTrue(nonAbilityFacet.isNonAbility(id, stat1));
PCTemplate t1 = new PCTemplate();
causeUnlock(t1, stat1);
tfacet.add(id, t1, tsource);
assertTrue(nonAbilityFacet.isNonAbility(id, stat1));
}
use of pcgen.core.PCTemplate in project pcgen by PCGen.
the class GlobalCSkillTest method testList.
@Test
public void testList() throws PersistenceLayerException {
PCTemplate source = create(PCTemplate.class, "Source");
ParseResult result = token.parseToken(context, source, "LIST");
if (result != ParseResult.SUCCESS) {
result.printMessages();
fail("Test Setup Failed");
}
result = CHOOSE_SKILL_TOKEN.parseToken(context, source, "Granted");
if (result != ParseResult.SUCCESS) {
result.printMessages();
fail("Test Setup Failed");
}
PCClass wizard = create(PCClass.class, "Wizard");
finishLoad();
pc.incrementClassLevel(1, wizard);
assertFalse(globalAddedSkillCostFacet.contains(id, SkillCost.CLASS, granted));
assertEquals(SkillCost.CROSS_CLASS, pc.getSkillCostForClass(granted, wizard));
templateInputFacet.directAdd(id, source, granted);
pc.calcActiveBonuses();
assertEquals(SkillCost.CLASS, pc.getSkillCostForClass(granted, wizard));
assertTrue(globalAddedSkillCostFacet.contains(id, SkillCost.CLASS, granted));
templateInputFacet.remove(id, source);
pc.calcActiveBonuses();
assertFalse(globalAddedSkillCostFacet.contains(id, SkillCost.CLASS, granted));
}
use of pcgen.core.PCTemplate in project pcgen by PCGen.
the class GlobalCcSkillTest method testList.
@Test
public void testList() throws PersistenceLayerException {
PCTemplate source = create(PCTemplate.class, "Source");
ParseResult result = token.parseToken(context, source, "LIST");
if (result != ParseResult.SUCCESS) {
result.printMessages();
fail("Test Setup Failed");
}
result = CHOOSE_SKILL_TOKEN.parseToken(context, source, "Granted");
if (result != ParseResult.SUCCESS) {
result.printMessages();
fail("Test Setup Failed");
}
PCClass wizard = create(PCClass.class, "Wizard");
new ExclusiveToken().parseToken(context, granted, "Yes");
finishLoad();
pc.incrementClassLevel(1, wizard);
assertFalse(globalAddedSkillCostFacet.contains(id, SkillCost.CROSS_CLASS, granted));
assertEquals(SkillCost.EXCLUSIVE, pc.getSkillCostForClass(granted, wizard));
templateInputFacet.directAdd(id, source, granted);
pc.calcActiveBonuses();
assertEquals(SkillCost.CROSS_CLASS, pc.getSkillCostForClass(granted, wizard));
assertTrue(globalAddedSkillCostFacet.contains(id, SkillCost.CROSS_CLASS, granted));
templateInputFacet.remove(id, source);
pc.calcActiveBonuses();
assertFalse(globalAddedSkillCostFacet.contains(id, SkillCost.CROSS_CLASS, granted));
}
use of pcgen.core.PCTemplate in project pcgen by PCGen.
the class TemplateFeatFacet method dataRemoved.
/**
* Removes all of the feats granted by FEAT: on the PCTemplate removed
*
* Triggered when one of the Facets to which ConditionalTemplateFacet
* listens fires a DataFacetChangeEvent to indicate a PCTemplate was removed
* from a Player Character.
*
* @param dfce
* The DataFacetChangeEvent containing the information about the
* change
*
* @see pcgen.cdom.facet.event.DataFacetChangeListener#dataRemoved(pcgen.cdom.facet.event.DataFacetChangeEvent)
*/
@Override
public void dataRemoved(DataFacetChangeEvent<CharID, PCTemplate> dfce) {
CharID id = dfce.getCharID();
PCTemplate source = dfce.getCDOMObject();
PersistentTransitionChoice<CNAbilitySelection> choice = source.get(ObjectKey.TEMPLATE_FEAT);
if (choice != null) {
PlayerCharacter pc = trackingFacet.getPC(id);
choice.remove(source, pc);
}
removeAll(id, source);
}
use of pcgen.core.PCTemplate in project pcgen by PCGen.
the class TemplateFeatFacet method dataAdded.
/**
* Adds all of the feats to the Player Character triggered by the FEAT token'
* on the given PCTemplate
*
* Triggered when one of the Facets to which ConditionalTemplateFacet
* listens fires a DataFacetChangeEvent to indicate a PCTemplate 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 dataAdded(DataFacetChangeEvent<CharID, PCTemplate> dfce) {
CharID id = dfce.getCharID();
PCTemplate source = dfce.getCDOMObject();
if (!containsFrom(id, source)) {
PersistentTransitionChoice<CNAbilitySelection> choice = source.get(ObjectKey.TEMPLATE_FEAT);
if (choice != null) {
PlayerCharacter pc = trackingFacet.getPC(id);
Collection<? extends CNAbilitySelection> result = choice.driveChoice(pc);
choice.act(result, source, pc);
for (CNAbilitySelection cas : result) {
add(id, cas, source);
}
}
}
}
Aggregations