use of pcgen.core.Domain in project pcgen by PCGen.
the class PCGVer2Creator method appendDeityLine.
/*
* ###############################################################
* Character Deity/Domain methods
* ###############################################################
*/
private void appendDeityLine(StringBuilder buffer) {
if (charDisplay.getDeity() != null) {
final Deity aDeity = charDisplay.getDeity();
buffer.append(IOConstants.TAG_DEITY).append(':');
buffer.append(EntityEncoder.encode(aDeity.getKeyName()));
/*
* currently unused information
*
* author: Thomas Behr 09-09-02
*/
buffer.append('|');
buffer.append(IOConstants.TAG_DEITYDOMAINS).append(':');
buffer.append('[');
String del = Constants.EMPTY_STRING;
for (CDOMReference<Domain> ref : aDeity.getSafeListMods(Deity.DOMAINLIST)) {
for (Domain d : ref.getContainedObjects()) {
buffer.append(del);
buffer.append(IOConstants.TAG_DOMAIN).append(':');
buffer.append(EntityEncoder.encode(d.getKeyName()));
//$NON-NLS-1$
del = "|";
}
}
buffer.append(']');
buffer.append('|');
buffer.append(IOConstants.TAG_ALIGNALLOW).append(':');
//TODO Need to clean this up?
for (final Description desc : aDeity.getSafeListFor(ListKey.DESCRIPTION)) {
buffer.append('|');
buffer.append(IOConstants.TAG_DESC).append(':');
buffer.append(desc.getPCCText());
}
buffer.append('|');
buffer.append(IOConstants.TAG_DEITYFAVWEAP).append(':');
buffer.append('[');
List<CDOMReference<WeaponProf>> dwp = aDeity.getListFor(ListKey.DEITYWEAPON);
if (dwp != null) {
del = Constants.EMPTY_STRING;
for (CDOMReference<WeaponProf> ref : dwp) {
buffer.append(del);
buffer.append(IOConstants.TAG_WEAPON).append(':');
buffer.append(EntityEncoder.encode(ref.getLSTformat(false)));
//$NON-NLS-1$
del = "|";
}
}
buffer.append(']');
buffer.append('|');
buffer.append(IOConstants.TAG_DEITYALIGN).append(':');
CDOMSingleRef<PCAlignment> al = aDeity.get(ObjectKey.ALIGNMENT);
if (al != null) {
buffer.append(al.getLSTformat(false));
}
buffer.append(IOConstants.LINE_SEP);
}
}
use of pcgen.core.Domain 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;
}
use of pcgen.core.Domain in project pcgen by PCGen.
the class Gui2InfoFactory method getHTMLInfo.
/**
* @see pcgen.core.facade.InfoFactory#getHTMLInfo(pcgen.core.facade.DomainFacade)
*/
@Override
public String getHTMLInfo(DomainFacade domainFacade) {
if (!(domainFacade instanceof DomainFacadeImpl)) {
return EMPTY_STRING;
}
DomainFacadeImpl domainFI = (DomainFacadeImpl) domainFacade;
Domain aDomain = domainFI.getRawObject();
final HtmlInfoBuilder infoText = new HtmlInfoBuilder();
if (aDomain != null) {
infoText.appendTitleElement(OutputNameFormatting.piString(aDomain, false));
appendFacts(infoText, aDomain);
String aString = pc.getDescription(aDomain);
if (!aString.isEmpty()) {
infoText.appendLineBreak();
//$NON-NLS-1$
infoText.appendI18nFormattedElement(//$NON-NLS-1$
"in_domainGrant", aString);
}
aString = PrerequisiteUtilities.preReqHTMLStringsForList(pc, null, aDomain.getPrerequisiteList(), false);
if (!aString.isEmpty()) {
//$NON-NLS-1$
infoText.appendI18nFormattedElement(//$NON-NLS-1$
"in_InfoRequirements", aString);
}
aString = PrerequisiteUtilities.preReqHTMLStringsForList(pc, aDomain, domainFI.getPrerequisiteList(), false);
if (!aString.isEmpty()) {
infoText.appendLineBreak();
infoText.appendI18nFormattedElement(//$NON-NLS-1$
"in_domainRequirements", aString);
}
aString = SourceFormat.getFormattedString(aDomain, Globals.getSourceDisplay(), true);
if (!aString.isEmpty()) {
//$NON-NLS-1$
infoText.appendI18nFormattedElement(//$NON-NLS-1$
"in_InfoSource", aString);
}
}
return infoText.toString();
}
use of pcgen.core.Domain in project pcgen by PCGen.
the class SpellBuilderFacadeImpl method getSpellTypeList.
private List<String> getSpellTypeList() {
List<String> spellTypes = new ArrayList<>();
InfoFacade castingClass = pcClass.get();
if (castingClass instanceof PCClass) {
spellTypes.add(((PCClass) castingClass).getSpellType());
} else if (castingClass instanceof Domain) {
spellTypes.add("Divine");
} else {
Logging.errorPrint("Found Casting Class that was not a Class or Domain: " + castingClass.getClass());
}
return spellTypes;
}
use of pcgen.core.Domain in project pcgen by PCGen.
the class SpellBuilderFacadeImpl method buildLists.
/**
* Use the parsed rules to build up the lists that will not change,
* such as class/domain list and metamagic feats.
*/
private void buildLists() {
List<PCClass> classes = new ArrayList<>();
List<Domain> domains = new ArrayList<>();
if (classList != null) {
for (String classKey : classList) {
PObject obj = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(PCClass.class, classKey);
if (obj == null) {
obj = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(Domain.class, classKey);
if (obj != null) {
domains.add((Domain) obj);
}
} else {
classes.add((PCClass) obj);
}
}
} else {
for (Spell spell : Globals.getContext().getReferenceContext().getConstructedCDOMObjects(Spell.class)) {
if (isSpellOfSubType(spell)) {
addSpellInfoToList(spell, classes, domains, reqSpellType);
}
}
for (PCClass aClass : Globals.getContext().getReferenceContext().getConstructedCDOMObjects(PCClass.class)) {
if (!aClass.getSpellType().equals(Constants.NONE)) {
// Only adds if the class can cast
if (character.getSpellSupport(aClass).canCastSpells(character)) {
continue;
}
if (!("".equals(reqSpellType)) && (!reqSpellType.contains(aClass.getSpellType()))) {
continue;
}
if (!classes.contains(aClass)) {
classes.add(aClass);
}
}
}
}
if (spellBooks != null) {
for (int i = classes.size() - 1; i >= 0; --i) {
PCClass obj = classes.get(i);
if (// can't have books
!spellBooks) {
if (obj.getSafe(ObjectKey.SPELLBOOK)) {
classes.remove(i);
}
} else // must have books
{
if (!(obj instanceof PCClass) || !obj.getSafe(ObjectKey.SPELLBOOK)) {
classes.remove(i);
}
}
}
if (spellBooks) {
domains.clear();
}
}
List<InfoFacade> allObjects = new ArrayList<>();
Globals.sortPObjectListByName(classes);
allObjects.addAll(classes);
Globals.sortPObjectListByName(domains);
allObjects.addAll(domains);
availClasses.setContents(allObjects);
// Spell levels
List<Integer> spellLevelValues = new ArrayList<>();
if ((levelList != null) && (!levelList.isEmpty())) {
for (int i = minSpellLevel; i < levelList.size(); ++i) {
spellLevelValues.add(Integer.valueOf(levelList.get(i)));
}
} else {
for (int i = minSpellLevel; i <= maxSpellLevel; i++) {
spellLevelValues.add(i);
}
}
availSpellLevels.setContents(spellLevelValues);
// Caster levels
updateAvailCasterLevels(1, 20);
//Metamagic
if (metaAllowed) {
List<Ability> metamagicFeats = new ArrayList<>();
for (Ability anAbility : Globals.getContext().getReferenceContext().getManufacturer(Ability.class, AbilityCategory.FEAT).getAllObjects()) {
if (anAbility.isType("Metamagic")) {
metamagicFeats.add(anAbility);
}
}
Globals.sortPObjectListByName(metamagicFeats);
availMetamagicFeats.setContents(metamagicFeats);
}
}
Aggregations