Search in sources :

Example 16 with PCClassLevel

use of pcgen.cdom.inst.PCClassLevel in project pcgen by PCGen.

the class PreHPTest method testHP.

/**
	 * Test the PREHP code
	 * @throws Exception
	 */
public void testHP() throws Exception {
    final PlayerCharacter character = getCharacter();
    LoadContext context = Globals.getContext();
    character.incrementClassLevel(1, myClass, true);
    myClass = character.getClassList().get(0);
    PCClassLevel pcl = character.getActiveClassLevel(myClass, 1);
    character.setHP(pcl, 4);
    character.calcActiveBonuses();
    Prerequisite prereq;
    final PreParserFactory factory = PreParserFactory.getInstance();
    prereq = factory.parse("PREHP:4");
    assertTrue("Character should have 4 hp", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREHP:5");
    assertFalse("Character should have less than 5 hp", PrereqHandler.passes(prereq, character, null));
    final BonusObj hpBonus = Bonus.newBonus(context, "HP|CURRENTMAX|1");
    myClass.addToListFor(ListKey.BONUS, hpBonus);
    character.calcActiveBonuses();
    assertTrue("Character should have 5 hp", PrereqHandler.passes(prereq, character, null));
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) PreParserFactory(pcgen.persistence.lst.prereq.PreParserFactory) BonusObj(pcgen.core.bonus.BonusObj) LoadContext(pcgen.rules.context.LoadContext) PCClassLevel(pcgen.cdom.inst.PCClassLevel)

Example 17 with PCClassLevel

use of pcgen.cdom.inst.PCClassLevel in project pcgen by PCGen.

the class AddTokenTest method testValidClearLevel.

@Test
public void testValidClearLevel() throws PersistenceLayerException {
    primaryProf = new PCClassLevel();
    primaryProf.put(IntegerKey.LEVEL, 1);
    secondaryProf = new PCClassLevel();
    secondaryProf.put(IntegerKey.LEVEL, 1);
    assertTrue(parse(".CLEAR.LEVEL1"));
}
Also used : PCClassLevel(pcgen.cdom.inst.PCClassLevel) Test(org.junit.Test)

Example 18 with PCClassLevel

use of pcgen.cdom.inst.PCClassLevel in project pcgen by PCGen.

the class AddTokenTest method testInvalidLevelClearWrongLevel.

@Test
public void testInvalidLevelClearWrongLevel() throws PersistenceLayerException {
    primaryProf = new PCClassLevel();
    primaryProf.put(IntegerKey.LEVEL, 1);
    secondaryProf = new PCClassLevel();
    secondaryProf.put(IntegerKey.LEVEL, 1);
    assertFalse(parse(".CLEAR.LEVEL2"));
    assertNoSideEffects();
}
Also used : PCClassLevel(pcgen.cdom.inst.PCClassLevel) Test(org.junit.Test)

Example 19 with PCClassLevel

use of pcgen.cdom.inst.PCClassLevel in project pcgen by PCGen.

the class LocalSkillCostFacetTest method testAddBadSource.

@Test
public void testAddBadSource() {
    Skill t1 = getObject();
    PCClassLevel pcl = new PCClassLevel();
    DataFacetChangeEvent<CharID, CDOMObject> dfce = new DataFacetChangeEvent<>(id, pcl, new Object(), DataFacetChangeEvent.DATA_ADDED);
    ListKey<CDOMReference<Skill>> lk = ListKey.LOCALCSKILL;
    pcl.addToListFor(lk, CDOMDirectSingleRef.getRef(t1));
    try {
        getFacet().dataAdded(dfce);
        fail();
    } catch (IllegalArgumentException e) {
    // Yep!
    }
}
Also used : DataFacetChangeEvent(pcgen.cdom.facet.event.DataFacetChangeEvent) Skill(pcgen.core.Skill) CDOMObject(pcgen.cdom.base.CDOMObject) CDOMObject(pcgen.cdom.base.CDOMObject) CharID(pcgen.cdom.enumeration.CharID) CDOMReference(pcgen.cdom.base.CDOMReference) PCClassLevel(pcgen.cdom.inst.PCClassLevel) Test(org.junit.Test)

Example 20 with PCClassLevel

use of pcgen.cdom.inst.PCClassLevel in project pcgen by PCGen.

the class LocalSkillCostFacetTest method testRemoveSecondSource.

@Test
public void testRemoveSecondSource() {
    Skill t1 = getObject();
    assertFalse(getFacet().contains(id, class1, SkillCost.CLASS, t1));
    addCost(id, class1, t1, SkillCost.CLASS);
    PCClassLevel pcl = new PCClassLevel();
    pcl.put(ObjectKey.PARENT, class1);
    DataFacetChangeEvent<CharID, CDOMObject> dfce = new DataFacetChangeEvent<>(id, pcl, new Object(), DataFacetChangeEvent.DATA_ADDED);
    ListKey<CDOMReference<Skill>> lk = ListKey.LOCALCSKILL;
    pcl.addToListFor(lk, CDOMDirectSingleRef.getRef(t1));
    getFacet().dataAdded(dfce);
    assertTrue(getFacet().contains(id, class1, SkillCost.CLASS, t1));
    removeCosts(id, pcl);
    assertTrue(getFacet().contains(id, class1, SkillCost.CLASS, t1));
}
Also used : DataFacetChangeEvent(pcgen.cdom.facet.event.DataFacetChangeEvent) Skill(pcgen.core.Skill) CDOMObject(pcgen.cdom.base.CDOMObject) CDOMObject(pcgen.cdom.base.CDOMObject) CharID(pcgen.cdom.enumeration.CharID) CDOMReference(pcgen.cdom.base.CDOMReference) PCClassLevel(pcgen.cdom.inst.PCClassLevel) Test(org.junit.Test)

Aggregations

PCClassLevel (pcgen.cdom.inst.PCClassLevel)69 PCClass (pcgen.core.PCClass)26 Test (org.junit.Test)25 PCLevelInfo (pcgen.core.pclevelinfo.PCLevelInfo)9 CDOMObject (pcgen.cdom.base.CDOMObject)8 ArrayList (java.util.ArrayList)5 CharID (pcgen.cdom.enumeration.CharID)5 ParseResult (pcgen.rules.persistence.token.ParseResult)5 CDOMReference (pcgen.cdom.base.CDOMReference)4 SpecialAbility (pcgen.core.SpecialAbility)4 LoadContext (pcgen.rules.context.LoadContext)4 AbstractTokenModelTest (tokenmodel.testsupport.AbstractTokenModelTest)4 StringTokenizer (java.util.StringTokenizer)3 DataFacetChangeEvent (pcgen.cdom.facet.event.DataFacetChangeEvent)3 Domain (pcgen.core.Domain)3 Skill (pcgen.core.Skill)3 TestContext (plugin.lsttokens.editcontext.testsupport.TestContext)3 BigDecimal (java.math.BigDecimal)2 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2