Search in sources :

Example 36 with Deity

use of pcgen.core.Deity in project pcgen by PCGen.

the class DeityWeaponProfFacet method dataAdded.

/**
	 * Adds WeaponProfs granted to the Player Character due to the Deity
	 * selection of the Player Character.
	 * 
	 * Triggered when one of the Facets to which DeityWeaponProfFacet listens
	 * fires a DataFacetChangeEvent to indicate a Deity was added to a Player
	 * Character.
	 * 
	 * @param dfce
	 *            The DataFacetChangeEvent containing the information about the
	 *            change
	 * 
	 * @see pcgen.cdom.facet.event.DataFacetChangeListener#dataAdded(pcgen.cdom.facet.event.DataFacetChangeEvent)
	 */
@Override
public void dataAdded(DataFacetChangeEvent<CharID, Deity> dfce) {
    Deity deity = dfce.getCDOMObject();
    List<CDOMReference<WeaponProf>> weaponList = deity.getListFor(ListKey.DEITYWEAPON);
    if (weaponList != null) {
        for (CDOMReference<WeaponProf> ref : weaponList) {
            for (WeaponProf wp : ref.getContainedObjects()) {
                /*
					 * CONSIDER This is an open question, IMHO - why is natural
					 * excluded here? This is magic to me - thpr Oct 14, 2008
					 */
                if (!wp.isType("Natural")) {
                    add(dfce.getCharID(), wp, dfce.getCDOMObject());
                }
            }
        }
    }
}
Also used : Deity(pcgen.core.Deity) WeaponProf(pcgen.core.WeaponProf) CDOMReference(pcgen.cdom.base.CDOMReference)

Example 37 with Deity

use of pcgen.core.Deity in project pcgen by PCGen.

the class ClassData method getDomainWeights.

public WeightedCollection<Domain> getDomainWeights(final String aDeityKey) {
    if (theDomainWeights == null) {
        theDomainWeights = new HashMap<>();
    }
    WeightedCollection<Domain> domains = theDomainWeights.get(aDeityKey);
    if (domains == null) {
        domains = new WeightedCollection<>();
        Deity deity = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(Deity.class, aDeityKey);
        for (CDOMReference<Domain> deityDomains : deity.getSafeListMods(Deity.DOMAINLIST)) {
            domains.addAll(deityDomains.getContainedObjects(), deity.getListAssociations(Deity.DOMAINLIST, deityDomains).size());
        }
    }
    return domains;
}
Also used : Deity(pcgen.core.Deity) Domain(pcgen.core.Domain)

Example 38 with Deity

use of pcgen.core.Deity in project pcgen by PCGen.

the class Gui2InfoFactory method getHTMLInfo.

/**
	 * @see pcgen.core.facade.InfoFactory#getHTMLInfo(pcgen.core.facade.DeityFacade)
	 */
@Override
public String getHTMLInfo(DeityFacade deityFacade) {
    if (!(deityFacade instanceof Deity)) {
        return EMPTY_STRING;
    }
    Deity aDeity = (Deity) deityFacade;
    final HtmlInfoBuilder infoText = new HtmlInfoBuilder();
    if (aDeity != null) {
        infoText.appendTitleElement(OutputNameFormatting.piString(aDeity, false));
        infoText.appendLineBreak();
        infoText.appendI18nFormattedElement("in_InfoDescription", //$NON-NLS-1$
        DescriptionFormatting.piWrapDesc(aDeity, pc.getDescription(aDeity), false));
        appendFacts(infoText, aDeity);
        String aString = getPantheons(aDeity);
        if (aString != null) {
            infoText.appendSpacer();
            infoText.appendI18nElement("in_pantheon", //$NON-NLS-1$
            aString);
        }
        infoText.appendSpacer();
        infoText.appendI18nElement("in_domains", //$NON-NLS-1$
        getDomains(aDeity));
        List<CDOMReference<WeaponProf>> dwp = aDeity.getListFor(ListKey.DEITYWEAPON);
        if (dwp != null) {
            infoText.appendSpacer();
            infoText.appendI18nFormattedElement(//$NON-NLS-1$
            "in_deityFavWeap", ReferenceUtilities.joinLstFormat(dwp, "|"));
        }
        aString = PrerequisiteUtilities.preReqHTMLStringsForList(pc, null, aDeity.getPrerequisiteList(), false);
        if (!aString.isEmpty()) {
            infoText.appendSpacer();
            //$NON-NLS-1$
            infoText.appendI18nFormattedElement(//$NON-NLS-1$
            "in_InfoRequirements", aString);
        }
        aString = aDeity.getSource();
        if (!aString.isEmpty()) {
            infoText.appendSpacer();
            //$NON-NLS-1$
            infoText.appendI18nFormattedElement(//$NON-NLS-1$
            "in_InfoSource", aString);
        }
    }
    return infoText.toString();
}
Also used : Deity(pcgen.core.Deity) HtmlInfoBuilder(pcgen.gui2.util.HtmlInfoBuilder) CDOMReference(pcgen.cdom.base.CDOMReference)

Example 39 with Deity

use of pcgen.core.Deity in project pcgen by PCGen.

the class Gui2InfoFactory method getFavoredWeapons.

/**
	 * Get a display string of the deity's favored weapons.
	 * @param deityFacade The deity to be output.
	 * @return The comma separated list of weapons.
	 */
@Override
public String getFavoredWeapons(DeityFacade deityFacade) {
    if (deityFacade == null || !(deityFacade instanceof Deity)) {
        return EMPTY_STRING;
    }
    Deity deity = (Deity) deityFacade;
    List<CDOMReference<WeaponProf>> wpnList = deity.getSafeListFor(ListKey.DEITYWEAPON);
    return ReferenceUtilities.joinLstFormat(wpnList, ",");
}
Also used : Deity(pcgen.core.Deity) CDOMReference(pcgen.cdom.base.CDOMReference)

Aggregations

Deity (pcgen.core.Deity)39 CDOMReference (pcgen.cdom.base.CDOMReference)8 Domain (pcgen.core.Domain)8 Test (org.junit.Test)5 WeaponProf (pcgen.core.WeaponProf)5 HashSet (java.util.HashSet)3 TreeSet (java.util.TreeSet)3 StringManager (pcgen.base.format.StringManager)3 PCAlignment (pcgen.core.PCAlignment)3 BigDecimal (java.math.BigDecimal)2 ArrayList (java.util.ArrayList)2 StringTokenizer (java.util.StringTokenizer)2 AssociatedPrereqObject (pcgen.cdom.base.AssociatedPrereqObject)2 SimpleAssociatedObject (pcgen.cdom.base.SimpleAssociatedObject)2 LinkedHashSet (java.util.LinkedHashSet)1 Set (java.util.Set)1 NumberManager (pcgen.base.format.NumberManager)1 Indirect (pcgen.base.util.Indirect)1 WeightedCollection (pcgen.base.util.WeightedCollection)1 WrappedMapSet (pcgen.base.util.WrappedMapSet)1