Search in sources :

Example 1 with Deity

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

the class Gui2InfoFactory method getDomains.

@Override
public String getDomains(DeityFacade deityFacade) {
    if (deityFacade == null || !(deityFacade instanceof Deity)) {
        return EMPTY_STRING;
    }
    Deity deity = (Deity) deityFacade;
    Set<String> set = new TreeSet<>();
    for (CDOMReference<Domain> ref : deity.getSafeListMods(Deity.DOMAINLIST)) {
        for (Domain d : ref.getContainedObjects()) {
            set.add(OutputNameFormatting.piString(d, false));
        }
    }
    final StringBuilder piString = new StringBuilder(100);
    //piString.append("<html>"); //$NON-NLS-1$
    //$NON-NLS-1$
    piString.append(StringUtil.joinToStringBuilder(set, ", "));
    //piString.append("</html>"); //$NON-NLS-1$
    return piString.toString();
}
Also used : Deity(pcgen.core.Deity) TreeSet(java.util.TreeSet) Domain(pcgen.core.Domain)

Example 2 with Deity

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

the class StringKeyActorTest method testStringKeyActor.

public void testStringKeyActor() {
    Deity d = new Deity();
    d.setName("Bob");
    String expectedResult = "Magical";
    df.set(id, d);
    d.put(StringKey.DAMAGE, expectedResult);
    StringKeyActor ska = new StringKeyActor(StringKey.DAMAGE);
    CDOMObjectWrapper.load(dsid, d.getClass(), "damage", ska);
    processThroughFreeMarker("${deity.damage}", expectedResult);
}
Also used : Deity(pcgen.core.Deity)

Example 3 with Deity

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

the class FactKeyActorTest method testFactKeyActor.

public void testFactKeyActor() {
    Deity d = new Deity();
    d.setName("Bob");
    Integer expectedResult = 475;
    df.set(id, d);
    NumberManager mgr = new NumberManager();
    FactKey<Number> fk = FactKey.getConstant("cost", mgr);
    d.put(fk, new BasicIndirect<>(mgr, expectedResult));
    FactKeyActor<?> ika = new FactKeyActor<>(fk);
    CDOMWrapperInfoFacet wiFacet = FacetLibrary.getFacet(CDOMWrapperInfoFacet.class);
    wiFacet.set(dsid, d.getClass(), "cost", ika);
    processThroughFreeMarker("${deity.cost}", expectedResult.toString());
}
Also used : Deity(pcgen.core.Deity) CDOMWrapperInfoFacet(pcgen.cdom.facet.CDOMWrapperInfoFacet) NumberManager(pcgen.base.format.NumberManager)

Example 4 with Deity

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

the class CharacterFacadeImpl method buildAvailableDomainsList.

/**
	 * This method returns all available domains, without filtering.
	 */
private void buildAvailableDomainsList() {
    List<DomainFacadeImpl> availDomainList = new ArrayList<>();
    List<DomainFacadeImpl> selDomainList = new ArrayList<>();
    Deity pcDeity = charDisplay.getDeity();
    if (pcDeity != null) {
        for (CDOMReference<Domain> domainRef : pcDeity.getSafeListMods(Deity.DOMAINLIST)) {
            Collection<AssociatedPrereqObject> assoc = pcDeity.getListAssociations(Deity.DOMAINLIST, domainRef);
            for (AssociatedPrereqObject apo : assoc) {
                for (Domain d : domainRef.getContainedObjects()) {
                    if (!isDomainInList(availDomainList, d)) {
                        availDomainList.add(new DomainFacadeImpl(d, apo.getPrerequisiteList()));
                    }
                }
            }
        }
    }
    // Loop through the available prestige domains
    for (PCClass aClass : charDisplay.getClassList()) {
        /*
			 * Need to do for the class, for compatibility, since level 0 is
			 * loaded into the class itself
			 */
        processDomainList(aClass, availDomainList);
        processAddDomains(aClass, availDomainList);
        for (int lvl = 0; lvl <= charDisplay.getLevel(aClass); lvl++) {
            PCClassLevel cl = charDisplay.getActiveClassLevel(aClass, lvl);
            processAddDomains(cl, availDomainList);
            processDomainList(cl, availDomainList);
        }
    }
    // Loop through the character's selected domains
    for (Domain d : charDisplay.getDomainSet()) {
        DomainFacadeImpl domainFI = new DomainFacadeImpl(d);
        boolean found = false;
        for (DomainFacadeImpl row : availDomainList) {
            if (d.equals(row.getRawObject())) {
                domainFI = row;
                found = true;
                break;
            }
        }
        if (!found) {
            availDomainList.add(domainFI);
        }
        if (!isDomainInList(selDomainList, d)) {
            selDomainList.add(domainFI);
        }
    }
    availDomains.updateContents(availDomainList);
    domains.updateContents(selDomainList);
    maxDomains.set(theCharacter.getMaxCharacterDomains());
    remainingDomains.set(theCharacter.getMaxCharacterDomains() - charDisplay.getDomainCount());
    updateDomainTodo();
}
Also used : Deity(pcgen.core.Deity) ArrayList(java.util.ArrayList) Domain(pcgen.core.Domain) PCClass(pcgen.core.PCClass) AssociatedPrereqObject(pcgen.cdom.base.AssociatedPrereqObject) PCClassLevel(pcgen.cdom.inst.PCClassLevel)

Example 5 with Deity

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

the class AbstractAddListTokenTest method testFromDeity.

@Test
public void testFromDeity() throws PersistenceLayerException {
    Deity source = create(Deity.class, "Source");
    T granted = createGrantedObject();
    processToken(source);
    assertEquals(0, getCount());
    deityFacet.set(id, source);
    assertTrue(containsExpected(granted));
    assertEquals(1, getCount());
    deityFacet.remove(id);
    assertEquals(0, getCount());
    assertTrue(cleanedSideEffects());
}
Also used : Deity(pcgen.core.Deity) Test(org.junit.Test)

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