Search in sources :

Example 21 with PCClass

use of pcgen.core.PCClass in project pcgen by PCGen.

the class PCClassLevelDomainTest method testSimple.

@Test
public void testSimple() throws PersistenceLayerException {
    PCClass source = create(PCClass.class, "Source");
    PCClassLevel pcl = source.getOriginalClassLevel(2);
    Domain granted = create(Domain.class, "Granted");
    ParseResult result = token.parseToken(context, pcl, "Granted");
    if (result != ParseResult.SUCCESS) {
        result.printMessages();
        fail("Test Setup Failed");
    }
    finishLoad();
    assertEquals(0, domainFacet.getCount(id));
    classFacet.addClass(id, source);
    PCClass pcc = pc.getClassKeyed(source.getKeyName());
    classFacet.setLevel(id, pcc, 1);
    //TODO get rid of this using facets :)
    DomainApplication.addDomainsUpToLevel(source, 1, pc);
    assertEquals(0, domainFacet.getCount(id));
    classFacet.setLevel(id, pcc, 2);
    DomainApplication.addDomainsUpToLevel(source, 2, pc);
    assertTrue(domainFacet.contains(id, granted));
    assertEquals(1, domainFacet.getCount(id));
    DomainApplication.removeDomainsForLevel(source, 2, pc);
    DomainApplication.removeDomainsForLevel(source, 1, pc);
    pc.validateCharacterDomains();
    classFacet.removeClass(id, source);
    assertEquals(0, domainFacet.getCount(id));
}
Also used : ParseResult(pcgen.rules.persistence.token.ParseResult) PCClass(pcgen.core.PCClass) Domain(pcgen.core.Domain) PCClassLevel(pcgen.cdom.inst.PCClassLevel) Test(org.junit.Test) AbstractTokenModelTest(tokenmodel.testsupport.AbstractTokenModelTest)

Example 22 with PCClass

use of pcgen.core.PCClass in project pcgen by PCGen.

the class PCClassLangbonusTest method testSimple.

@Test
public void testSimple() throws PersistenceLayerException {
    PCClass source = create(PCClass.class, "Source");
    Language granted = create(Language.class, "Granted");
    ParseResult result = token.parseToken(context, source, "Granted");
    if (result != ParseResult.SUCCESS) {
        result.printMessages();
        fail("Test Setup Failed");
    }
    finishLoad();
    assertEquals(0, startingLanguageFacet.getCount(id));
    classFacet.addClass(id, source);
    assertTrue(startingLanguageFacet.contains(id, granted));
    assertEquals(1, startingLanguageFacet.getCount(id));
    classFacet.removeClass(id, source);
    assertEquals(0, startingLanguageFacet.getCount(id));
}
Also used : Language(pcgen.core.Language) ParseResult(pcgen.rules.persistence.token.ParseResult) PCClass(pcgen.core.PCClass) Test(org.junit.Test) AbstractTokenModelTest(tokenmodel.testsupport.AbstractTokenModelTest)

Example 23 with PCClass

use of pcgen.core.PCClass in project pcgen by PCGen.

the class SpellSupportFacadeImpl method buildAvailableNodes.

/**
	 * Construct the list of available spells for the character. 
	 */
private void buildAvailableNodes() {
    availableSpellNodes.clearContents();
    // Scan character classes for spell classes
    List<PCClass> classList = getCharactersSpellcastingClasses();
    // Look at each spell on each spellcasting class
    for (PCClass pcClass : classList) {
        DoubleKeyMapToList<SpellFacade, String, SpellNode> existingSpells = buildExistingSpellMap(availableSpellNodes, pcClass);
        for (Spell spell : pc.getAllSpellsInLists(charDisplay.getSpellLists(pcClass))) {
            // Create SpellNodeImpl for each spell
            CharacterSpell charSpell = new CharacterSpell(pcClass, spell);
            SpellFacadeImplem spellImplem = new SpellFacadeImplem(pc, spell, charSpell, null);
            HashMapToList<CDOMList<Spell>, Integer> levelInfo = pc.getSpellLevelInfo(spell);
            for (CDOMList<Spell> spellList : charDisplay.getSpellLists(pcClass)) {
                List<Integer> levels = levelInfo.getListFor(spellList);
                if (levels != null) {
                    for (Integer level : levels) {
                        SpellNodeImpl node = new SpellNodeImpl(spellImplem, pcClass, String.valueOf(level), null);
                        if (!existingSpells.containsInList(spellImplem, node.getSpellLevel(), node)) {
                            // Add to list
                            availableSpellNodes.addElement(node);
                        }
                    }
                }
            }
        }
    }
}
Also used : PCClass(pcgen.core.PCClass) SpellSupportForPCClass(pcgen.core.SpellSupportForPCClass) Spell(pcgen.core.spell.Spell) CharacterSpell(pcgen.core.character.CharacterSpell) CharacterSpell(pcgen.core.character.CharacterSpell) CDOMList(pcgen.cdom.base.CDOMList) SpellFacade(pcgen.facade.core.SpellFacade)

Example 24 with PCClass

use of pcgen.core.PCClass in project pcgen by PCGen.

the class SpellSupportFacadeImpl method buildKnownPreparedSpellsForCDOMObject.

private void buildKnownPreparedSpellsForCDOMObject(CDOMObject pObject) {
    Collection<? extends CharacterSpell> sp = charDisplay.getCharacterSpells(pObject);
    List<CharacterSpell> cSpells = new ArrayList<>(sp);
    // Add in the spells granted by objects
    pc.addBonusKnownSpellsToList(pObject, cSpells);
    PCClass pcClass = (PCClass) (pObject instanceof PCClass ? pObject : null);
    for (CharacterSpell charSpell : cSpells) {
        for (SpellInfo spellInfo : charSpell.getInfoList()) {
            // Create SpellNodeImpl for each spell
            String book = spellInfo.getBook();
            boolean isKnown = Globals.getDefaultSpellBook().equals(book);
            SpellFacadeImplem spellImplem = new SpellFacadeImplem(pc, charSpell.getSpell(), charSpell, spellInfo);
            SpellNodeImpl node;
            if (pcClass != null) {
                node = new SpellNodeImpl(spellImplem, pcClass, String.valueOf(spellInfo.getActualLevel()), getRootNode(book));
            } else {
                node = new SpellNodeImpl(spellImplem, String.valueOf(spellInfo.getActualLevel()), getRootNode(book));
            }
            if (spellInfo.getTimes() > 1) {
                node.addCount(spellInfo.getTimes() - 1);
            }
            boolean isSpellBook = charDisplay.getSpellBookByName(book).getType() == SpellBook.TYPE_SPELL_BOOK;
            // Add to list
            if (isKnown) {
                allKnownSpellNodes.addElement(node);
                knownSpellNodes.addElement(node);
            } else if (isSpellBook) {
                bookSpellNodes.addElement(node);
            } else if (pObject instanceof Race) {
                allKnownSpellNodes.addElement(node);
            } else {
                preparedSpellNodes.addElement(node);
            }
        }
    }
}
Also used : Race(pcgen.core.Race) ArrayList(java.util.ArrayList) CharacterSpell(pcgen.core.character.CharacterSpell) PCClass(pcgen.core.PCClass) SpellSupportForPCClass(pcgen.core.SpellSupportForPCClass) SpellInfo(pcgen.core.character.SpellInfo)

Example 25 with PCClass

use of pcgen.core.PCClass in project pcgen by PCGen.

the class ChallengeRatingFacet method calcClassesCR.

/**
	 * Returns the ChallengeRating provided solely by PCClass objects granted to
	 * the Player Character identified by the given CharID.
	 * 
	 * @param id
	 *            The CharID representing the Player Character
	 * @return the Challenge Rating provided by the PCClass objects granted to
	 *         the Player Character identified by the given CharID
	 */
private int calcClassesCR(CharID id) {
    int cr = 0;
    int crMod = 0;
    int crModPriority = 0;
    for (PCClass pcClass : classFacet.getSet(id)) {
        cr += calcClassCR(id, pcClass);
        int crmp = getClassCRModPriority(pcClass);
        if (crmp != 0 && (crmp < crModPriority || crModPriority == 0)) {
            Integer raceMod = getClassRaceCRMod(id, pcClass);
            if (raceMod != null) {
                crMod = raceMod;
            } else {
                crMod = getClassCRMod(id, pcClass);
            }
            crModPriority = crmp;
        }
    }
    cr += crMod;
    return cr;
}
Also used : PCClass(pcgen.core.PCClass)

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