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