Search in sources :

Example 51 with PCClass

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();
}
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 52 with PCClass

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;
}
Also used : Skill(pcgen.core.Skill) SkillCost(pcgen.cdom.enumeration.SkillCost) PCClass(pcgen.core.PCClass)

Example 53 with PCClass

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;
}
Also used : PCClass(pcgen.core.PCClass)

Example 54 with PCClass

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());
        }
    }
}
Also used : SpellBook(pcgen.core.character.SpellBook) PObject(pcgen.core.PObject) ArrayList(java.util.ArrayList) PCClass(pcgen.core.PCClass) SpellSupportForPCClass(pcgen.core.SpellSupportForPCClass)

Example 55 with PCClass

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);
        }
    }
}
Also used : DomainSpellList(pcgen.cdom.list.DomainSpellList) ClassSpellList(pcgen.cdom.list.ClassSpellList) CDOMList(pcgen.cdom.base.CDOMList) PCClass(pcgen.core.PCClass) Domain(pcgen.core.Domain) AvailableSpell(pcgen.cdom.helper.AvailableSpell) Spell(pcgen.core.spell.Spell) HashSet(java.util.HashSet)

Aggregations

PCClass (pcgen.core.PCClass)359 Test (org.junit.Test)96 PlayerCharacter (pcgen.core.PlayerCharacter)61 Skill (pcgen.core.Skill)55 ArrayList (java.util.ArrayList)35 Domain (pcgen.core.Domain)30 LoadContext (pcgen.rules.context.LoadContext)28 PCClassLevel (pcgen.cdom.inst.PCClassLevel)26 CDOMObject (pcgen.cdom.base.CDOMObject)23 CharacterSpell (pcgen.core.character.CharacterSpell)20 Spell (pcgen.core.spell.Spell)20 StringTokenizer (java.util.StringTokenizer)19 CharID (pcgen.cdom.enumeration.CharID)19 ClassSource (pcgen.cdom.helper.ClassSource)19 PreClassTester (plugin.pretokens.test.PreClassTester)16 SkillCost (pcgen.cdom.enumeration.SkillCost)15 ParseResult (pcgen.rules.persistence.token.ParseResult)15 Ability (pcgen.core.Ability)14 Race (pcgen.core.Race)14 BonusObj (pcgen.core.bonus.BonusObj)14