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();
}
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 :)
}
}
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");
}
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 :)
}
}
Aggregations