Search in sources :

Example 41 with PCClassLevel

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

the class ClassFacetTest method testCopyContents.

@Test
public void testCopyContents() {
    PCClass cl = new PCClass();
    PCClassLevel ocl = cl.getOriginalClassLevel(2);
    ocl.put(IntegerKey.HIT_DIE, 4);
    facet.addClass(id, cl);
    facet.setLevel(id, cl, 3);
    facet.copyContents(id, altid);
    PCClassLevel pcl = facet.getClassLevel(altid, cl, 2);
    assertEquals(Integer.valueOf(2), pcl.get(IntegerKey.LEVEL));
    assertEquals(Integer.valueOf(4), pcl.get(IntegerKey.HIT_DIE));
    assertEquals(3, facet.getLevel(altid, cl));
}
Also used : PCClass(pcgen.core.PCClass) PCClassLevel(pcgen.cdom.inst.PCClassLevel) Test(org.junit.Test)

Example 42 with PCClassLevel

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

the class PCClassLevelCCSkillTest method testDirect.

@Test
public void testDirect() throws PersistenceLayerException {
    PCClassLevel pcl = dragon.getOriginalClassLevel(1);
    ParseResult result = token.parseToken(context, pcl, "MySkill");
    if (result != ParseResult.SUCCESS) {
        result.printMessages();
        fail("Test Setup Failed");
    }
    new ExclusiveToken().parseToken(context, sk, "Yes");
    finishLoad();
    assertEquals(SkillCost.EXCLUSIVE, pc.getSkillCostForClass(sk, dragon));
    classFacet.addClass(id, dragon);
    classFacet.setLevel(id, dragon, 1);
    assertTrue(lscFacet.contains(id, dragon, SkillCost.CROSS_CLASS, sk));
    pc.setDirty(true);
    assertEquals(SkillCost.CROSS_CLASS, pc.getSkillCostForClass(sk, dragon));
    classFacet.setLevel(id, dragon, 0);
    assertFalse(lscFacet.contains(id, dragon, SkillCost.CROSS_CLASS, sk));
}
Also used : ParseResult(pcgen.rules.persistence.token.ParseResult) ExclusiveToken(plugin.lsttokens.skill.ExclusiveToken) PCClassLevel(pcgen.cdom.inst.PCClassLevel) Test(org.junit.Test) AbstractTokenModelTest(tokenmodel.testsupport.AbstractTokenModelTest)

Example 43 with PCClassLevel

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

the class PCClassLevelCSkillTest method testDirect.

@Test
public void testDirect() throws PersistenceLayerException {
    PCClassLevel pcl = dragon.getOriginalClassLevel(1);
    ParseResult result = token.parseToken(context, pcl, "MySkill");
    if (result != ParseResult.SUCCESS) {
        result.printMessages();
        fail("Test Setup Failed");
    }
    finishLoad();
    assertEquals(SkillCost.CROSS_CLASS, pc.getSkillCostForClass(sk, dragon));
    classFacet.addClass(id, dragon);
    classFacet.setLevel(id, dragon, 1);
    assertTrue(lscFacet.contains(id, dragon, SkillCost.CLASS, sk));
    pc.setDirty(true);
    assertEquals(SkillCost.CLASS, pc.getSkillCostForClass(sk, dragon));
    classFacet.setLevel(id, dragon, 0);
    assertFalse(lscFacet.contains(id, dragon, SkillCost.CLASS, sk));
}
Also used : ParseResult(pcgen.rules.persistence.token.ParseResult) PCClassLevel(pcgen.cdom.inst.PCClassLevel) Test(org.junit.Test) AbstractTokenModelTest(tokenmodel.testsupport.AbstractTokenModelTest)

Example 44 with PCClassLevel

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

the class LevelToken method getLevelHP.

/**
	 * Get the HP for the level
	 * @param pc
	 * @param pcl
	 * @return the HP for the level
	 */
public static String getLevelHP(PlayerCharacter pc, PCLevelInfo pcl) {
    String classKeyName = pcl.getClassKeyName();
    PCClass aClass = pc.getClassKeyed(classKeyName);
    if (aClass == null) {
        aClass = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(PCClass.class, classKeyName);
        if (aClass != null) {
            CDOMSingleRef<PCClass> exc = aClass.get(ObjectKey.EX_CLASS);
            aClass = pc.getClassKeyed(exc.get().getKeyName());
        }
    }
    if (aClass != null) {
        PCClassLevel classLevel = pc.getDisplay().getActiveClassLevel(aClass, pcl.getClassLevel() - 1);
        Integer hp = pc.getDisplay().getHP(classLevel);
        return hp == null ? "0" : hp.toString();
    }
    return "";
}
Also used : PCClass(pcgen.core.PCClass) PCClassLevel(pcgen.cdom.inst.PCClassLevel)

Example 45 with PCClassLevel

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

the class AddTokenTest method testInvalidLevelClearLevelNaN.

@Test
public void testInvalidLevelClearLevelNaN() throws PersistenceLayerException {
    primaryProf = new PCClassLevel();
    primaryProf.put(IntegerKey.LEVEL, 1);
    secondaryProf = new PCClassLevel();
    secondaryProf.put(IntegerKey.LEVEL, 1);
    assertFalse(parse(".CLEAR.LEVELx"));
    assertNoSideEffects();
}
Also used : 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