use of pcgen.core.Domain in project pcgen by PCGen.
the class CharacterFacadeImpl method isQualifiedFor.
/**
* @see pcgen.core.facade.CharacterFacade#isQualifiedFor(pcgen.core.facade.DomainFacade)
*/
@Override
public boolean isQualifiedFor(DomainFacade domainFacade) {
if (!(domainFacade instanceof DomainFacadeImpl)) {
return false;
}
DomainFacadeImpl domainFI = (DomainFacadeImpl) domainFacade;
Domain domain = domainFI.getRawObject();
if (!PrereqHandler.passesAll(domainFI.getPrerequisiteList(), theCharacter, domain) || !theCharacter.isQualified(domain)) {
return false;
}
return true;
}
use of pcgen.core.Domain 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.Domain in project pcgen by PCGen.
the class LocalSkillCostFacet method dataAdded.
/**
* Adds the SkillCost objects granted by CDOMObjects, as applied directly to
* a PCClass, when a CDOMObject is added to a Player Character.
*
* Triggered when one of the Facets to which LocalSkillCostFacet listens
* fires a DataFacetChangeEvent to indicate a CDOMObject 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, CDOMObject> dfce) {
CDOMObject cdo = dfce.getCDOMObject();
CharID id = dfce.getCharID();
PCClass owner;
if (cdo instanceof Domain) {
owner = domainFacet.getSource(id, (Domain) cdo).getPcclass();
} else if (cdo instanceof PCClassLevel) {
owner = (PCClass) cdo.get(ObjectKey.PARENT);
} else if (cdo instanceof PCClass) {
owner = (PCClass) cdo;
} else {
Logging.errorPrint(getClass().getSimpleName() + " was given " + cdo + " which is not an expected object type");
return;
}
for (CDOMReference<Skill> ref : cdo.getSafeListFor(ListKey.LOCALCSKILL)) {
for (Skill sk : ref.getContainedObjects()) {
add(id, owner, SkillCost.CLASS, sk, cdo);
}
}
for (CDOMReference<Skill> ref : cdo.getSafeListFor(ListKey.LOCALCCSKILL)) {
for (Skill sk : ref.getContainedObjects()) {
add(id, owner, SkillCost.CROSS_CLASS, sk, cdo);
}
}
}
use of pcgen.core.Domain in project pcgen by PCGen.
the class SpellLevel method isLevel.
/**
* isLevel(int aLevel)
*
* @param aLevel
* level of the spell
* @param aPC
* @return true if the spell is of the given level in any spell list
*/
public static boolean isLevel(Spell sp, int aLevel, PlayerCharacter aPC) {
Integer levelKey = aLevel;
MasterListInterface masterLists = SettingsHandler.getGame().getMasterLists();
for (PCClass pcc : aPC.getClassSet()) {
ClassSpellList csl = pcc.get(ObjectKey.CLASS_SPELLLIST);
Collection<AssociatedPrereqObject> assoc = masterLists.getAssociations(csl, sp);
if (assoc != null) {
for (AssociatedPrereqObject apo : assoc) {
if (PrereqHandler.passesAll(apo.getPrerequisiteList(), aPC, sp)) {
if (levelKey.equals(apo.getAssociation(AssociationKey.SPELL_LEVEL))) {
return true;
}
}
}
}
}
for (Domain domain : aPC.getDomainSet()) {
DomainSpellList dsl = domain.get(ObjectKey.DOMAIN_SPELLLIST);
Collection<AssociatedPrereqObject> assoc = masterLists.getAssociations(dsl, sp);
if (assoc != null) {
for (AssociatedPrereqObject apo : assoc) {
if (PrereqHandler.passesAll(apo.getPrerequisiteList(), aPC, sp)) {
if (levelKey.equals(apo.getAssociation(AssociationKey.SPELL_LEVEL))) {
return true;
}
}
}
}
}
return false;
}
use of pcgen.core.Domain in project pcgen by PCGen.
the class DomainSpellsFacet method dataAdded.
/**
* Adds Domain Spells allowed / granted to the Player Character due to the
* Domain selections of the Player Character.
*
* Triggered when one of the Facets to which DomainSpellsFacet listens fires
* a DataFacetChangeEvent to indicate a Domain 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, Domain> dfce) {
Domain domain = dfce.getCDOMObject();
CharID id = dfce.getCharID();
ClassSource source = domainFacet.getSource(id, domain);
if (source != null) {
String classKey = source.getPcclass().getKeyName();
PCClass domainClass = getClassKeyed(id, classKey);
if (domainClass != null) {
PlayerCharacter pc = trackingFacet.getPC(id);
final int maxLevel = pc.getSpellSupport(domainClass).getMaxCastLevel();
DomainApplication.addSpellsToClassForLevels(pc, domain, domainClass, 0, maxLevel);
}
}
}
Aggregations