Search in sources :

Example 1 with PCTemplate

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));
}
Also used : Race(pcgen.core.Race) PCTemplate(pcgen.core.PCTemplate) Test(org.junit.Test)

Example 2 with PCTemplate

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));
}
Also used : ParseResult(pcgen.rules.persistence.token.ParseResult) PCTemplate(pcgen.core.PCTemplate) PCClass(pcgen.core.PCClass) Test(org.junit.Test) AbstractContentTokenTest(tokencontent.testsupport.AbstractContentTokenTest)

Example 3 with PCTemplate

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));
}
Also used : ParseResult(pcgen.rules.persistence.token.ParseResult) PCTemplate(pcgen.core.PCTemplate) PCClass(pcgen.core.PCClass) ExclusiveToken(plugin.lsttokens.skill.ExclusiveToken) Test(org.junit.Test) AbstractContentTokenTest(tokencontent.testsupport.AbstractContentTokenTest)

Example 4 with PCTemplate

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);
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) CNAbilitySelection(pcgen.cdom.helper.CNAbilitySelection) PCTemplate(pcgen.core.PCTemplate) CharID(pcgen.cdom.enumeration.CharID)

Example 5 with PCTemplate

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);
            }
        }
    }
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) CNAbilitySelection(pcgen.cdom.helper.CNAbilitySelection) PCTemplate(pcgen.core.PCTemplate) CharID(pcgen.cdom.enumeration.CharID)

Aggregations

PCTemplate (pcgen.core.PCTemplate)215 Test (org.junit.Test)105 Race (pcgen.core.Race)66 PlayerCharacter (pcgen.core.PlayerCharacter)38 CDOMObject (pcgen.cdom.base.CDOMObject)31 ArrayList (java.util.ArrayList)19 CharID (pcgen.cdom.enumeration.CharID)18 ParseResult (pcgen.rules.persistence.token.ParseResult)14 SimpleAssociatedObject (pcgen.cdom.base.SimpleAssociatedObject)13 Vision (pcgen.core.Vision)12 LoadContext (pcgen.rules.context.LoadContext)12 PCClass (pcgen.core.PCClass)11 StringTokenizer (java.util.StringTokenizer)10 VariableKey (pcgen.cdom.enumeration.VariableKey)8 DataFacetChangeEvent (pcgen.cdom.facet.event.DataFacetChangeEvent)8 Ability (pcgen.core.Ability)8 Formula (pcgen.base.formula.Formula)6 Equipment (pcgen.core.Equipment)6 PCStat (pcgen.core.PCStat)6 AbstractTokenModelTest (tokenmodel.testsupport.AbstractTokenModelTest)6