Search in sources :

Example 21 with HitDie

use of pcgen.cdom.content.HitDie in project pcgen by PCGen.

the class Gui2InfoFactory method getHTMLInfo.

/**
	 * @see pcgen.core.facade.InfoFactory#getHTMLInfo(pcgen.core.facade.ClassFacade, pcgen.core.facade.ClassFacade)
	 */
@Override
public String getHTMLInfo(ClassFacade classFacade, ClassFacade parentClassFacade) {
    if (!(classFacade instanceof PCClass)) {
        return EMPTY_STRING;
    }
    PCClass aClass = (PCClass) classFacade;
    PCClass parentClass = aClass;
    String aString;
    boolean isSubClass = aClass instanceof SubClass;
    if (isSubClass && parentClassFacade != null) {
        parentClass = (PCClass) parentClassFacade;
    }
    final HtmlInfoBuilder b = new HtmlInfoBuilder(OutputNameFormatting.piString(aClass, false));
    b.appendLineBreak();
    // Subclass cost - at the top to make choices easier
    if (isSubClass && aClass.getSafe(IntegerKey.COST) != 0) {
        //$NON-NLS-1$
        b.appendI18nElement("in_clInfoCost", String.valueOf(aClass.getSafe(IntegerKey.COST)));
        b.appendLineBreak();
    }
    // Type
    aString = aClass.getType();
    if (isSubClass && (aString.isEmpty())) {
        aString = parentClass.getType();
    }
    //$NON-NLS-1$
    b.appendI18nElement("in_clInfoType", aString);
    // Hit Die
    HitDie hitDie = aClass.getSafe(ObjectKey.LEVEL_HITDIE);
    if (isSubClass && HitDie.ZERO.equals(hitDie)) {
        hitDie = parentClass.getSafe(ObjectKey.LEVEL_HITDIE);
    }
    if (!HitDie.ZERO.equals(hitDie)) {
        b.appendSpacer();
        //$NON-NLS-1$  //$NON-NLS-2$
        b.appendI18nElement("in_clInfoHD", "d" + hitDie.getDie());
    }
    appendFacts(b, aClass);
    if (SettingsHandler.getGame().getTabShown(Tab.SPELLS)) {
        FactKey<String> fk = FactKey.valueOf("SpellType");
        aString = aClass.getResolved(fk);
        if (isSubClass && aString == null) {
            aString = parentClass.getSpellType();
        }
        b.appendSpacer();
        //$NON-NLS-1$
        b.appendI18nElement("in_clInfoSpellType", aString);
        aString = aClass.getSpellBaseStat();
        /*
			 * CONSIDER This test here is the ONLY place where the "magical"
			 * value of null is tested for in getSpellBaseStat(). This is
			 * currently set by SubClass and SubstititionClass, so it IS
			 * used, but the question is: Is there a better method for
			 * identifying this special deferral to the "parentClass" other
			 * than null SpellBaseStat? - thpr 11/9/06
			 */
        if (isSubClass && ((aString == null) || (aString.isEmpty()))) {
            aString = parentClass.getSpellBaseStat();
        }
        b.appendSpacer();
        //$NON-NLS-1$
        b.appendI18nElement("in_clInfoBaseStat", aString);
    }
    // Prereqs
    aString = PrerequisiteUtilities.preReqHTMLStringsForList(pc, null, aClass.getPrerequisiteList(), false);
    if (isSubClass && (aString.isEmpty())) {
        aString = PrerequisiteUtilities.preReqHTMLStringsForList(pc, null, parentClass.getPrerequisiteList(), false);
    }
    if (!aString.isEmpty()) {
        b.appendLineBreak();
        //$NON-NLS-1$
        b.appendI18nElement("in_requirements", aString);
    }
    //Description
    String desc = pc.getDescription(aClass);
    if (!desc.isEmpty()) {
        b.appendLineBreak();
        //$NON-NLS-1$
        b.appendI18nFormattedElement(//$NON-NLS-1$
        "in_InfoDescription", DescriptionFormatting.piWrapDesc(aClass, desc, false));
    }
    // Sub class extra info
    if (isSubClass) {
        int specialtySpells = aClass.getSafe(IntegerKey.KNOWN_SPELLS_FROM_SPECIALTY);
        b.appendLineBreak();
        //$NON-NLS-1$
        b.appendI18nElement("in_clSpecialtySpells", Delta.toString(specialtySpells));
        b.appendSpacer();
        //$NON-NLS-1$
        b.appendI18nElement("in_clSpecialty", ((SubClass) aClass).getChoice());
    }
    // Source
    aString = aClass.getSource();
    if (isSubClass && (aString.isEmpty())) {
        aString = parentClass.getSource();
    }
    if (!aString.isEmpty()) {
        b.appendLineBreak();
        //$NON-NLS-1$
        b.appendI18nElement("in_source", aString);
    }
    return b.toString();
}
Also used : SubClass(pcgen.core.SubClass) HitDie(pcgen.cdom.content.HitDie) HtmlInfoBuilder(pcgen.gui2.util.HtmlInfoBuilder) PCClass(pcgen.core.PCClass)

Example 22 with HitDie

use of pcgen.cdom.content.HitDie in project pcgen by PCGen.

the class HitDieTokenTest method testUnparseNegativeLevel.

@Test
public void testUnparseNegativeLevel() throws PersistenceLayerException {
    try {
        primaryProf.put(ObjectKey.HITDIE, new HitDieLock(new HitDie(-1)));
        assertBadUnparse();
    } catch (IllegalArgumentException e) {
    // Good here too :)
    }
}
Also used : HitDieLock(pcgen.cdom.processor.HitDieLock) HitDie(pcgen.cdom.content.HitDie) Test(org.junit.Test)

Example 23 with HitDie

use of pcgen.cdom.content.HitDie in project pcgen by PCGen.

the class HitDieTokenTest method testUnparseLegal.

@Test
public void testUnparseLegal() throws PersistenceLayerException {
    primaryProf.put(ObjectKey.HITDIE, new HitDieLock(new HitDie(1)));
    expectSingle(getToken().unparse(primaryContext, primaryProf), "1");
}
Also used : HitDieLock(pcgen.cdom.processor.HitDieLock) HitDie(pcgen.cdom.content.HitDie) Test(org.junit.Test)

Example 24 with HitDie

use of pcgen.cdom.content.HitDie in project pcgen by PCGen.

the class HitDieTokenTest method testUnparseZeroSteps.

@Test
public void testUnparseZeroSteps() throws PersistenceLayerException {
    try {
        primaryProf.put(ObjectKey.HITDIE, new HitDieStep(0, new HitDie(12)));
        assertBadUnparse();
    } catch (IllegalArgumentException e) {
    // Good here too :)
    }
}
Also used : HitDieStep(pcgen.cdom.processor.HitDieStep) HitDie(pcgen.cdom.content.HitDie) Test(org.junit.Test)

Aggregations

HitDie (pcgen.cdom.content.HitDie)24 Test (org.junit.Test)14 HitDieLock (pcgen.cdom.processor.HitDieLock)9 HitDieStep (pcgen.cdom.processor.HitDieStep)6 PCClass (pcgen.core.PCClass)4 ParseResult (pcgen.rules.persistence.token.ParseResult)4 AddingFormula (pcgen.base.formula.AddingFormula)3 DividingFormula (pcgen.base.formula.DividingFormula)3 MultiplyingFormula (pcgen.base.formula.MultiplyingFormula)3 SubtractingFormula (pcgen.base.formula.SubtractingFormula)3 HitDieFormula (pcgen.cdom.processor.HitDieFormula)3 PCClassLevel (pcgen.cdom.inst.PCClassLevel)2 PlayerCharacter (pcgen.core.PlayerCharacter)2 ComplexParseResult (pcgen.rules.persistence.token.ComplexParseResult)2 CDOMObject (pcgen.cdom.base.CDOMObject)1 CharID (pcgen.cdom.enumeration.CharID)1 PCTemplate (pcgen.core.PCTemplate)1 SubClass (pcgen.core.SubClass)1 PCLevelInfo (pcgen.core.pclevelinfo.PCLevelInfo)1 HtmlInfoBuilder (pcgen.gui2.util.HtmlInfoBuilder)1