Search in sources :

Example 21 with PCClassLevel

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;
}
Also used : CharacterDisplay(pcgen.core.display.CharacterDisplay) PCClass(pcgen.core.PCClass) PCClassLevel(pcgen.cdom.inst.PCClassLevel)

Example 22 with PCClassLevel

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));
}
Also used : ClassLevelObjectChangeEvent(pcgen.cdom.facet.model.ClassFacet.ClassLevelObjectChangeEvent) PCClass(pcgen.core.PCClass) PCClassLevel(pcgen.cdom.inst.PCClassLevel) Test(org.junit.Test)

Example 23 with PCClassLevel

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));
}
Also used : ClassLevelObjectChangeEvent(pcgen.cdom.facet.model.ClassFacet.ClassLevelObjectChangeEvent) PCClass(pcgen.core.PCClass) PCClassLevel(pcgen.cdom.inst.PCClassLevel) Test(org.junit.Test)

Example 24 with PCClassLevel

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));
}
Also used : PCClass(pcgen.core.PCClass) PCClassLevel(pcgen.cdom.inst.PCClassLevel) Test(org.junit.Test)

Example 25 with PCClassLevel

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));
}
Also used : PCClass(pcgen.core.PCClass) 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