Search in sources :

Example 1 with FactSetKey

use of pcgen.cdom.enumeration.FactSetKey in project pcgen by PCGen.

the class DeityToken method getToken.

/**
	 * @see pcgen.io.exporttoken.Token#getToken(java.lang.String, pcgen.core.PlayerCharacter, pcgen.io.ExportHandler)
	 */
@Override
public String getToken(String tokenSource, PlayerCharacter pc, ExportHandler eh) {
    String retString = "";
    CharacterDisplay display = pc.getDisplay();
    Deity deity = display.getDeity();
    if (deity != null) {
        StringTokenizer aTok = new StringTokenizer(tokenSource, ".", false);
        String subTag = "OUTPUTNAME";
        if (aTok.countTokens() > 1) {
            aTok.nextToken();
            subTag = aTok.nextToken();
        }
        if ("NAME".equals(subTag)) {
            if (!display.getSuppressBioField(BiographyField.DEITY)) {
                retString = deity.getDisplayName();
            }
        } else if ("OUTPUTNAME".equals(subTag)) {
            if (!display.getSuppressBioField(BiographyField.DEITY)) {
                retString = OutputNameFormatting.getOutputName(deity);
            }
        } else if ("DOMAINLIST".equals(subTag)) {
            retString = getDomainListToken(deity);
        } else if ("FOLLOWERALIGNMENT".equals(subTag)) {
            Logging.errorPrint("Output Sheet uses DEITY.FOLLOWERALIGN: " + "Function has been removed from PCGen");
        } else if ("ALIGNMENT".equals(subTag)) {
            CDOMSingleRef<PCAlignment> al = deity.get(ObjectKey.ALIGNMENT);
            retString = al == null ? "" : al.get().getKeyName();
        } else if ("APPEARANCE".equals(subTag)) {
            FactKey<String> fk = FactKey.valueOf("Appearance");
            String str = deity.getResolved(fk);
            retString = (str == null) ? "" : str;
        } else if ("DESCRIPTION".equals(subTag)) {
            retString = pc.getDescription(deity);
        } else if ("HOLYITEM".equals(subTag)) {
            FactKey<String> fk = FactKey.valueOf("Symbol");
            String str = deity.getResolved(fk);
            retString = (str == null) ? "" : str;
        } else if ("FAVOREDWEAPON".equals(subTag)) {
            List<CDOMReference<WeaponProf>> dwp = deity.getSafeListFor(ListKey.DEITYWEAPON);
            retString = ReferenceUtilities.joinLstFormat(dwp, Constants.PIPE, true);
        } else if ("PANTHEONLIST".equals(subTag)) {
            FactSetKey<String> fk = FactSetKey.valueOf("Pantheon");
            Set<String> pset = new TreeSet<>();
            for (Indirect<String> indirect : deity.getSafeSetFor(fk)) {
                pset.add(indirect.get());
            }
            retString = StringUtil.join(pset, ", ");
        } else if ("SOURCE".equals(subTag)) {
            retString = SourceFormat.getFormattedString(deity, Globals.getSourceDisplay(), true);
        } else if ("SA".equals(subTag)) {
            retString = getSAToken(deity, display);
        } else if ("TITLE".equals(subTag)) {
            FactKey<String> fk = FactKey.valueOf("Title");
            String str = deity.getResolved(fk);
            retString = (str == null) ? "" : str;
        } else if ("WORSHIPPERS".equals(subTag)) {
            FactKey<String> fk = FactKey.valueOf("Worshippers");
            String str = deity.getResolved(fk);
            retString = (str == null) ? "" : str;
        }
    }
    return retString;
}
Also used : Deity(pcgen.core.Deity) TreeSet(java.util.TreeSet) Set(java.util.Set) CharacterDisplay(pcgen.core.display.CharacterDisplay) Indirect(pcgen.base.util.Indirect) FactKey(pcgen.cdom.enumeration.FactKey) StringTokenizer(java.util.StringTokenizer) PCAlignment(pcgen.core.PCAlignment) FactSetKey(pcgen.cdom.enumeration.FactSetKey) CDOMReference(pcgen.cdom.base.CDOMReference)

Aggregations

Set (java.util.Set)1 StringTokenizer (java.util.StringTokenizer)1 TreeSet (java.util.TreeSet)1 Indirect (pcgen.base.util.Indirect)1 CDOMReference (pcgen.cdom.base.CDOMReference)1 FactKey (pcgen.cdom.enumeration.FactKey)1 FactSetKey (pcgen.cdom.enumeration.FactSetKey)1 Deity (pcgen.core.Deity)1 PCAlignment (pcgen.core.PCAlignment)1 CharacterDisplay (pcgen.core.display.CharacterDisplay)1