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