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));
}
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"));
}
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();
}
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!
}
}
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));
}
Aggregations