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;
}
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));
}
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());
}
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());
}
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);
}
}
}
}
Aggregations