use of pcgen.cdom.inst.PCClassLevel in project pcgen by PCGen.
the class HPRollToken method getRollToken.
/**
* Get the HPROLL.ROLL token
* @param pc
* @param level
* @return the HPROLL.ROLL token
*/
public static int getRollToken(PlayerCharacter pc, int level) {
CharacterDisplay display = pc.getDisplay();
int classLevel = display.getLevelInfoClassLevel(level) - 1;
int hpRoll = 0;
PCClass pcClass = pc.getClassKeyed(display.getLevelInfoClassKeyName(level));
if (pcClass != null) {
PCClassLevel pcl = display.getActiveClassLevel(pcClass, classLevel);
Integer hp = display.getHP(pcl);
hpRoll = hp == null ? 0 : hp;
}
return hpRoll;
}
use of pcgen.cdom.inst.PCClassLevel in project pcgen by PCGen.
the class ClassFacetTest method testSetClassLevel.
@Test
public void testSetClassLevel() {
PCClass t1 = new PCClass();
facet.addClass(id, t1);
PCClassLevel pcl = new PCClassLevel();
pcl.put(IntegerKey.LEVEL, 3);
PCClassLevel old = facet.getClassLevel(id, t1, 3);
try {
assertTrue(facet.setClassLevel(id, t1, pcl));
ClassLevelObjectChangeEvent event = classListener.lastLevelObjectEvent;
assertSame(id, event.getCharID());
assertEquals(t1, event.getPCClass());
assertEquals(old, event.getOldLevel());
assertEquals(pcl, event.getNewLevel());
} catch (CloneNotSupportedException e) {
fail(e.getMessage());
}
assertEquals(pcl, facet.getClassLevel(id, t1, 3));
}
use of pcgen.cdom.inst.PCClassLevel in project pcgen by PCGen.
the class ClassFacetTest method testSetClassLevelUseless.
@Test
public void testSetClassLevelUseless() {
PCClass t1 = new PCClass();
facet.addClass(id, t1);
PCClassLevel pcl = new PCClassLevel();
pcl.put(IntegerKey.LEVEL, 3);
PCClassLevel old = facet.getClassLevel(id, t1, 3);
assertEquals(0, classListener.addEventObjectCount);
try {
assertTrue(facet.setClassLevel(id, t1, pcl));
ClassLevelObjectChangeEvent event = classListener.lastLevelObjectEvent;
assertSame(id, event.getCharID());
assertEquals(t1, event.getPCClass());
assertEquals(old, event.getOldLevel());
assertEquals(pcl, event.getNewLevel());
} catch (CloneNotSupportedException e) {
fail(e.getMessage());
}
assertEquals(1, classListener.addEventObjectCount);
//Now useless but still returns true
try {
assertTrue(facet.setClassLevel(id, t1, pcl));
} catch (CloneNotSupportedException e) {
fail(e.getMessage());
}
//Guarantee no new event
assertEquals(1, classListener.addEventObjectCount);
assertEquals(pcl, facet.getClassLevel(id, t1, 3));
}
use of pcgen.cdom.inst.PCClassLevel in project pcgen by PCGen.
the class ClassFacetTest method testGetClassLevelAdded.
@Test
public void testGetClassLevelAdded() {
PCClass cl = new PCClass();
PCClassLevel ocl = cl.getOriginalClassLevel(2);
ocl.put(IntegerKey.HIT_DIE, 4);
facet.addClass(id, cl);
PCClassLevel pcl = facet.getClassLevel(id, cl, 2);
assertEquals(Integer.valueOf(2), pcl.get(IntegerKey.LEVEL));
assertEquals(Integer.valueOf(4), pcl.get(IntegerKey.HIT_DIE));
}
use of pcgen.cdom.inst.PCClassLevel in project pcgen by PCGen.
the class ClassFacetTest method testGetClassLevelDefaultAdded.
@Test
public void testGetClassLevelDefaultAdded() {
PCClass cl = new PCClass();
facet.addClass(id, cl);
PCClassLevel pcl = facet.getClassLevel(id, cl, 1);
assertEquals(Integer.valueOf(1), pcl.get(IntegerKey.LEVEL));
}
Aggregations