use of pcgen.cdom.inst.PCClassLevel in project pcgen by PCGen.
the class PlayerCharacterTest method testMakeIntoExClass.
public void testMakeIntoExClass() {
// Prepare class and ex-class
LoadContext context = Globals.getContext();
PCClass paladin = new PCClass();
paladin.setName("Paladin");
context.getReferenceContext().importObject(paladin);
PCClass exPaladin = new PCClass();
exPaladin.setName("exPaladin");
context.getReferenceContext().importObject(exPaladin);
paladin.put(ObjectKey.EX_CLASS, context.getReferenceContext().getCDOMReference(PCClass.class, exPaladin.getKeyName()));
readyToRun();
PlayerCharacter pc = getCharacter();
// Add a level of the class
pc.incrementClassLevel(2, paladin, true, false);
PCClass pcPalClass = pc.getClassKeyed(paladin.getKeyName());
pc.setHP(pc.getActiveClassLevel(pcPalClass, 0), 10);
pc.setHP(pc.getActiveClassLevel(pcPalClass, 1), 6);
// Make it into an ex-class
pc.makeIntoExClass(pcPalClass);
assertNull("Paladin class should not be held", pc.getClassKeyed(paladin.getKeyName()));
PCClass pcExPalClass = pc.getClassKeyed(exPaladin.getKeyName());
assertNotNull("Ex-Paladin class should be held", pcExPalClass);
PCClassLevel pcLvl1 = pc.getActiveClassLevel(pcExPalClass, 0);
assertNotNull("Level 1 should be Ex-Paladin", pcLvl1);
assertEquals("Should still be level 2 character", 2, pc.getTotalLevels());
assertEquals("Hp at first level incorrect", 10, (int) pc.getHP(pcLvl1));
}
use of pcgen.cdom.inst.PCClassLevel in project pcgen by PCGen.
the class ClassFacetTest method testSetClassLevelBadLevel.
@Test
public void testSetClassLevelBadLevel() {
PCClass cl = new PCClass();
facet.addClass(id, cl);
//pcl.put(IntegerKey.LEVEL, 4);
try {
PCClassLevel pcl = new PCClassLevel();
PCClass t1 = new PCClass();
facet.setClassLevel(id, t1, pcl);
fail();
} catch (IllegalArgumentException | NullPointerException e) {
//yep!
} catch (CloneNotSupportedException e) {
fail(e.getMessage());
}
}
use of pcgen.cdom.inst.PCClassLevel in project pcgen by PCGen.
the class ClassFacetTest method testSetClassLevelNull.
@Test
public void testSetClassLevelNull() {
PCClass cl = new PCClass();
facet.addClass(id, cl);
try {
PCClassLevel pcl = new PCClassLevel();
assertFalse(facet.setClassLevel(id, null, pcl));
fail();
} catch (IllegalArgumentException e) {
// Yep!
} catch (CloneNotSupportedException e) {
fail(e.getMessage());
}
}
use of pcgen.cdom.inst.PCClassLevel in project pcgen by PCGen.
the class ClassFacetTest method testSetClassLevelNotAdded.
@Test
public void testSetClassLevelNotAdded() {
try {
PCClassLevel pcl = new PCClassLevel();
PCClass t1 = new PCClass();
assertFalse(facet.setClassLevel(id, t1, pcl));
} catch (CloneNotSupportedException e) {
fail(e.getMessage());
}
assertNull(facet.removeAllClasses(id));
}
use of pcgen.cdom.inst.PCClassLevel in project pcgen by PCGen.
the class ClassFacetTest method testSetClassLevelOtherAdded.
@Test
public void testSetClassLevelOtherAdded() {
PCClass cl = new PCClass();
cl.setName("MyClass");
facet.addClass(id, cl);
PCClass t1 = new PCClass();
t1.setName("OtherClass");
PCClassLevel pcl = new PCClassLevel();
pcl.put(IntegerKey.LEVEL, 4);
try {
assertFalse(facet.setClassLevel(id, t1, pcl));
} catch (IllegalArgumentException e) {
//Yep okay too!
} catch (CloneNotSupportedException e) {
fail(e.getMessage());
}
}
Aggregations