use of pcgen.core.PCClass 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.PCClass in project pcgen by PCGen.
the class SkillpointsToken method getUsedSkillPoints.
/**
* Get the used skill points for the PC
* @param pc
* @return the used skill points for the PC
*/
public static int getUsedSkillPoints(PlayerCharacter pc) {
float usedPoints = 0;
for (Skill aSkill : pc.getDisplay().getSkillSet()) {
for (PCClass pcc : pc.getSkillRankClasses(aSkill)) {
Double rank = pc.getSkillRankForClass(aSkill, pcc);
if (rank == null) {
rank = 0.0d;
}
SkillCost skillCost = pc.getSkillCostForClass(aSkill, pcc);
usedPoints += (rank * skillCost.getCost());
}
}
return (int) usedPoints;
}
use of pcgen.core.PCClass in project pcgen by PCGen.
the class SkillpointsToken method getUnusedSkillPoints.
/**
* Get unused skill points for the PC
* @param pc
* @return unused skill points for the PC
*/
public static int getUnusedSkillPoints(PlayerCharacter pc, int classNum) {
float usedPoints = 0;
if (classNum < 0 || classNum >= pc.getDisplay().getClassCount()) {
return 0;
}
PCClass pcClass = pc.getDisplay().getClassList().get(classNum);
if (pcClass.getSkillPool(pc) > 0) {
usedPoints += pcClass.getSkillPool(pc);
}
return (int) usedPoints;
}
use of pcgen.core.PCClass in project pcgen by PCGen.
the class SpellSupportFacadeImpl method buildKnownPreparedNodes.
/**
* Construct the list of spells the character knows, has prepared or has in
* a spell book.
*/
private void buildKnownPreparedNodes() {
allKnownSpellNodes.clearContents();
knownSpellNodes.clearContents();
bookSpellNodes.clearContents();
preparedSpellNodes.clearContents();
// Ensure spell information is up to date
pc.getSpellList();
// Scan character classes for spell classes
List<PCClass> classList = getCharactersSpellcastingClasses();
List<PObject> pobjList = new ArrayList<>(classList);
// Include spells from race etc
pobjList.add(charDisplay.getRace());
// Look at each spell on each spellcasting class
for (PObject pcClass : pobjList) {
buildKnownPreparedSpellsForCDOMObject(pcClass);
}
spellBooks.clear();
spellBookNames.clearContents();
for (SpellBook spellBook : charDisplay.getSpellBooks()) {
if (spellBook.getType() == SpellBook.TYPE_PREPARED_LIST) {
DummySpellNodeImpl spellListNode = new DummySpellNodeImpl(getRootNode(spellBook.getName()));
preparedSpellLists.add(spellListNode);
addDummyNodeIfSpellListEmpty(spellBook.getName());
} else if (spellBook.getType() == SpellBook.TYPE_SPELL_BOOK) {
DummySpellNodeImpl spellListNode = new DummySpellNodeImpl(getRootNode(spellBook.getName()));
spellBooks.add(spellListNode);
addDummyNodeIfSpellBookEmpty(spellBook.getName());
spellBookNames.addElement(spellBook.getName());
}
}
}
use of pcgen.core.PCClass in project pcgen by PCGen.
the class SpellBuilderFacadeImpl method addSpellInfoToList.
private void addSpellInfoToList(final Spell aSpell, List<PCClass> classes, List<Domain> domains, String spellType) {
Set<String> unfoundItems = new HashSet<>();
final HashMapToList<CDOMList<Spell>, Integer> levelInfo = character.getSpellLevelInfo(aSpell);
if ((levelInfo == null) || (levelInfo.isEmpty())) {
return;
}
for (CDOMList<Spell> spellList : levelInfo.getKeySet()) {
if (spellList instanceof ClassSpellList) {
String key = spellList.getKeyName();
final PCClass aClass = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(PCClass.class, key);
if (aClass != null) {
if (!("".equals(spellType)) && (!spellType.contains(aClass.getSpellType()))) {
continue;
}
if (!classes.contains(aClass)) {
classes.add(aClass);
}
} else {
key = 'C' + key;
if (!unfoundItems.contains(key)) {
unfoundItems.add(key);
Logging.errorPrint("Class " + key.substring(1) + " not found. Was used in spell " + aSpell);
}
}
} else if (spellList instanceof DomainSpellList) {
if (!("".equals(spellType)) && (!spellType.contains("Divine"))) {
continue;
}
String key = spellList.getKeyName();
final Domain aDomain = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(Domain.class, key);
if (aDomain != null) {
if (!domains.contains(aDomain)) {
domains.add(aDomain);
}
} else {
key = 'D' + key;
if (!unfoundItems.contains(key)) {
unfoundItems.add(key);
Logging.errorPrint("Domain " + key.substring(1) + " not found. Was used in spell " + aSpell);
}
}
} else {
Logging.errorPrint("Unknown spell source: " + spellList);
}
}
}
Aggregations