Search in sources :

Example 1 with Race

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

the class LevelFacet method getLevelAdjustment.

/**
	 * Returns the level adjustment for the Player Character identified by the
	 * given CharID.
	 * 
	 * @param id
	 *            The CharID of the Player Character for which the level
	 *            adjustment will be returned
	 * @return The level adjustment for the Player Character identified by the
	 *         given CharID
	 */
public int getLevelAdjustment(CharID id) {
    Race race = raceFacet.get(id);
    int levelAdj = 0;
    if (race != null) {
        Formula raceLA = race.getSafe(FormulaKey.LEVEL_ADJUSTMENT);
        levelAdj += formulaResolvingFacet.resolve(id, raceLA, "").intValue();
    }
    for (PCTemplate template : templateFacet.getSet(id)) {
        Formula templateLA = template.getSafe(FormulaKey.LEVEL_ADJUSTMENT);
        levelAdj += formulaResolvingFacet.resolve(id, templateLA, "").intValue();
    }
    return levelAdj;
}
Also used : Formula(pcgen.base.formula.Formula) Race(pcgen.core.Race) PCTemplate(pcgen.core.PCTemplate)

Example 2 with Race

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

the class RaceMonsterClassTest method testSimple.

@Test
public void testSimple() throws PersistenceLayerException {
    TokenRegistration.register(plugin.bonustokens.Feat.class);
    Race source = create(Race.class, "Source");
    create(PCClass.class, "Granted").put(ObjectKey.IS_MONSTER, Boolean.TRUE);
    ParseResult result = token.parseToken(context, source, "Granted:3");
    if (result != ParseResult.SUCCESS) {
        result.printMessages();
        fail("Test Setup Failed");
    }
    finishLoad();
    assertEquals(0, classFacet.getCount(id));
    raceFacet.directSet(id, source, getAssoc());
    assertEquals(1, classFacet.getCount(id));
    assertNotNull(pc.getClassKeyed("Granted"));
    raceFacet.remove(id);
    assertEquals(0, classFacet.getCount(id));
}
Also used : ParseResult(pcgen.rules.persistence.token.ParseResult) Race(pcgen.core.Race) PCClass(pcgen.core.PCClass) Test(org.junit.Test) AbstractTokenModelTest(tokenmodel.testsupport.AbstractTokenModelTest)

Example 3 with Race

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

the class AutoLangListTest method testFromRace.

@Test
public void testFromRace() throws PersistenceLayerException {
    Race source = create(Race.class, "Source");
    Language granted = createGrantedObject();
    processToken(source);
    assertEquals(0, getCount());
    raceFacet.directSet(id, source, getAssoc());
    assertTrue(containsExpected(granted));
    assertEquals(1, getCount());
    raceFacet.remove(id);
    assertEquals(0, getCount());
    assertTrue(cleanedSideEffects());
}
Also used : Language(pcgen.core.Language) Race(pcgen.core.Race) Test(org.junit.Test) AbstractTokenModelTest(tokenmodel.testsupport.AbstractTokenModelTest)

Example 4 with Race

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

the class AbstractAddListTokenTest method testFromRace.

//Language not *supposed* to do things like this
@Test
public void testFromRace() throws PersistenceLayerException {
    Race source = create(Race.class, "Source");
    T granted = createGrantedObject();
    processToken(source);
    assertEquals(0, getCount());
    raceFacet.directSet(id, source, getAssoc());
    assertTrue(containsExpected(granted));
    assertEquals(1, getCount());
    raceFacet.remove(id);
    assertEquals(0, getCount());
    assertTrue(cleanedSideEffects());
}
Also used : Race(pcgen.core.Race) Test(org.junit.Test)

Example 5 with Race

use of pcgen.core.Race 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)

Aggregations

Race (pcgen.core.Race)167 Test (org.junit.Test)78 PCTemplate (pcgen.core.PCTemplate)66 PlayerCharacter (pcgen.core.PlayerCharacter)28 CDOMObject (pcgen.cdom.base.CDOMObject)16 LoadContext (pcgen.rules.context.LoadContext)16 PCClass (pcgen.core.PCClass)15 ArrayList (java.util.ArrayList)10 SizeAdjustment (pcgen.core.SizeAdjustment)10 ParseResult (pcgen.rules.persistence.token.ParseResult)10 AbstractTokenModelTest (tokenmodel.testsupport.AbstractTokenModelTest)10 PCStat (pcgen.core.PCStat)9 FixedSizeFormula (pcgen.cdom.formula.FixedSizeFormula)8 Equipment (pcgen.core.Equipment)8 BonusObj (pcgen.core.bonus.BonusObj)7 Formula (pcgen.base.formula.Formula)6 WieldCategory (pcgen.core.character.WieldCategory)6 GameMode (pcgen.core.GameMode)5 Skill (pcgen.core.Skill)5 CompanionList (pcgen.cdom.list.CompanionList)4