Search in sources :

Example 21 with HtmlInfoBuilder

use of pcgen.gui2.util.HtmlInfoBuilder in project pcgen by PCGen.

the class Gui2InfoFactory method getHTMLInfo.

/**
	 * @see pcgen.core.facade.InfoFactory#getHTMLInfo(pcgen.core.facade.AbilityFacade)
	 */
@Override
public String getHTMLInfo(AbilityFacade abilityFacade) {
    if (!(abilityFacade instanceof Ability)) {
        return EMPTY_STRING;
    }
    Ability ability = (Ability) abilityFacade;
    final HtmlInfoBuilder infoText = new HtmlInfoBuilder();
    infoText.appendTitleElement(OutputNameFormatting.piString(ability, false));
    infoText.appendLineBreak();
    //$NON-NLS-1$
    infoText.appendI18nFormattedElement(//$NON-NLS-1$
    "Ability.Info.Type", //$NON-NLS-1$
    StringUtil.join(ability.getTrueTypeList(true), ". "));
    BigDecimal costStr = ability.getSafe(ObjectKey.SELECTION_COST);
    if (//$NON-NLS-1$
    !costStr.equals(BigDecimal.ONE)) {
        //$NON-NLS-1$
        infoText.appendI18nFormattedElement(//$NON-NLS-1$
        "Ability.Info.Cost", COST_FMT.format(costStr));
    }
    if (ability.getSafe(ObjectKey.MULTIPLE_ALLOWED)) {
        infoText.appendSpacer();
        //$NON-NLS-1$
        infoText.append(LanguageBundle.getString("Ability.Info.Multiple"));
    }
    if (ability.getSafe(ObjectKey.STACKS)) {
        infoText.appendSpacer();
        //$NON-NLS-1$
        infoText.append(LanguageBundle.getString("Ability.Info.Stacks"));
    }
    appendFacts(infoText, ability);
    final String cString = PrerequisiteUtilities.preReqHTMLStringsForList(pc, null, ability.getPrerequisiteList(), false);
    if (!cString.isEmpty()) {
        //$NON-NLS-1$
        infoText.appendI18nFormattedElement(//$NON-NLS-1$
        "in_InfoRequirements", cString);
    }
    infoText.appendLineBreak();
    //$NON-NLS-1$
    infoText.appendI18nFormattedElement(//$NON-NLS-1$
    "in_InfoDescription", getDescription(abilityFacade));
    List<CNAbility> wrappedAbility = getWrappedAbility(ability);
    if (ability.getSafeSizeOfMapFor(MapKey.ASPECT) > 0) {
        Set<AspectName> aspectKeys = ability.getKeysFor(MapKey.ASPECT);
        StringBuilder buff = new StringBuilder(100);
        for (AspectName key : aspectKeys) {
            if (buff.length() > 0) {
                buff.append(", ");
            }
            //Assert here that the actual text displayed is not critical
            buff.append(Aspect.printAspect(pc, key, wrappedAbility));
        }
        infoText.appendLineBreak();
        //$NON-NLS-1$
        infoText.appendI18nFormattedElement(//$NON-NLS-1$
        "Ability.Info.Aspects", buff.toString());
    }
    final String bene = BenefitFormatting.getBenefits(pc, wrappedAbility);
    if (bene != null && !bene.isEmpty()) {
        infoText.appendLineBreak();
        //$NON-NLS-1$
        infoText.appendI18nFormattedElement(//$NON-NLS-1$
        "Ability.Info.Benefit", BenefitFormatting.getBenefits(pc, wrappedAbility));
    }
    infoText.appendLineBreak();
    //$NON-NLS-1$
    infoText.appendI18nFormattedElement(//$NON-NLS-1$
    "in_InfoSource", ability.getSource());
    return infoText.toString();
}
Also used : CNAbility(pcgen.cdom.content.CNAbility) Ability(pcgen.core.Ability) CNAbility(pcgen.cdom.content.CNAbility) AspectName(pcgen.cdom.enumeration.AspectName) HtmlInfoBuilder(pcgen.gui2.util.HtmlInfoBuilder) BigDecimal(java.math.BigDecimal)

Example 22 with HtmlInfoBuilder

use of pcgen.gui2.util.HtmlInfoBuilder in project pcgen by PCGen.

the class Gui2InfoFactory method getHTMLInfo.

@Override
public String getHTMLInfo(SpellFacade spell) {
    if (spell == null || !(spell instanceof SpellFacadeImplem)) {
        return EMPTY_STRING;
    }
    SpellFacadeImplem sfi = (SpellFacadeImplem) spell;
    CharacterSpell cs = sfi.getCharSpell();
    SpellInfo si = sfi.getSpellInfo();
    Spell aSpell = cs.getSpell();
    if (aSpell == null) {
        return EMPTY_STRING;
    }
    final HtmlInfoBuilder b = new HtmlInfoBuilder(OutputNameFormatting.piString(aSpell, false));
    if (si != null) {
        // would add [featList]
        final String addString = si.toString();
        if (!addString.isEmpty()) {
            //$NON-NLS-1$
            b.append(" ").append(addString);
        }
        b.appendLineBreak();
        //$NON-NLS-1$
        b.appendI18nElement("InfoSpells.level.title", Integer.toString(si.getOriginalLevel()));
    }
    b.appendLineBreak();
    String classlevels = aSpell.getListAsString(ListKey.SPELL_CLASSLEVEL);
    if (StringUtils.isNotEmpty(classlevels)) {
        b.appendI18nElement("in_clClass", classlevels);
        b.appendLineBreak();
    }
    String domainlevels = aSpell.getListAsString(ListKey.SPELL_DOMAINLEVEL);
    if (StringUtils.isNotEmpty(domainlevels)) {
        b.appendI18nElement("in_domains", domainlevels);
        b.appendLineBreak();
    }
    b.appendI18nElement("in_spellSchool", aSpell.getListAsString(ListKey.SPELL_SCHOOL));
    String subSchool = aSpell.getListAsString(ListKey.SPELL_SUBSCHOOL);
    if (StringUtils.isNotEmpty(subSchool)) {
        b.append(" (").append(subSchool).append(")");
    }
    String spellDescriptor = aSpell.getListAsString(ListKey.SPELL_DESCRIPTOR);
    if (StringUtils.isNotEmpty(spellDescriptor)) {
        b.append(" [").append(spellDescriptor).append("]");
    }
    b.appendLineBreak();
    appendFacts(b, aSpell);
    b.appendLineBreak();
    b.appendI18nElement("in_spellComponents", aSpell.getListAsString(ListKey.COMPONENTS));
    b.appendLineBreak();
    b.appendI18nElement("in_spellCastTime", aSpell.getListAsString(ListKey.CASTTIME));
    b.appendLineBreak();
    b.appendI18nElement("in_spellDuration", pc.parseSpellString(cs, aSpell.getListAsString(ListKey.DURATION)));
    b.appendLineBreak();
    b.appendI18nElement("in_spellRange", pc.getSpellRange(cs, si));
    b.appendSpacer();
    b.appendI18nElement("in_spellTarget", pc.parseSpellString(cs, aSpell.getSafe(StringKey.TARGET_AREA)));
    b.appendLineBreak();
    b.appendI18nElement("in_spellSavingThrow", aSpell.getListAsString(ListKey.SAVE_INFO));
    b.appendSpacer();
    b.appendI18nElement("in_spellSpellResist", aSpell.getListAsString(ListKey.SPELL_RESISTANCE));
    b.appendLineBreak();
    b.appendLineBreak();
    b.appendI18nElement("in_descrip", //$NON-NLS-1$
    pc.parseSpellString(//$NON-NLS-1$
    cs, pc.getDescription(aSpell)));
    final String cString = PrerequisiteUtilities.preReqHTMLStringsForList(pc, null, aSpell.getPrerequisiteList(), false);
    if (!cString.isEmpty()) {
        b.appendLineBreak();
        //$NON-NLS-1$
        b.appendI18nElement("in_requirements", cString);
    }
    b.appendLineBreak();
    String spellSource = SourceFormat.getFormattedString(aSpell, Globals.getSourceDisplay(), true);
    if (!spellSource.isEmpty()) {
        b.appendLineBreak();
        //$NON-NLS-1$
        b.appendI18nElement("in_source", spellSource);
    }
    return b.toString();
}
Also used : CharacterSpell(pcgen.core.character.CharacterSpell) HtmlInfoBuilder(pcgen.gui2.util.HtmlInfoBuilder) Spell(pcgen.core.spell.Spell) CharacterSpell(pcgen.core.character.CharacterSpell) SpellInfo(pcgen.core.character.SpellInfo)

Aggregations

HtmlInfoBuilder (pcgen.gui2.util.HtmlInfoBuilder)22 BigDecimal (java.math.BigDecimal)3 ArrayList (java.util.ArrayList)3 Equipment (pcgen.core.Equipment)3 PCClass (pcgen.core.PCClass)3 CharacterSpell (pcgen.core.character.CharacterSpell)3 TreeMap (java.util.TreeMap)2 TreeSet (java.util.TreeSet)2 CDOMObject (pcgen.cdom.base.CDOMObject)2 CNAbility (pcgen.cdom.content.CNAbility)2 RaceType (pcgen.cdom.enumeration.RaceType)2 Ability (pcgen.core.Ability)2 Campaign (pcgen.core.Campaign)2 Domain (pcgen.core.Domain)2 SpellInfo (pcgen.core.character.SpellInfo)2 Spell (pcgen.core.spell.Spell)2 CampaignFacade (pcgen.facade.core.CampaignFacade)2 File (java.io.File)1 List (java.util.List)1 Map (java.util.Map)1