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);
}
}
}
}
use of pcgen.core.Race in project pcgen by PCGen.
the class Gui2InfoFactory method getStatAdjustments.
/**
* @see pcgen.core.facade.InfoFactory#getStatAdjustments(pcgen.core.facade.RaceFacade)
*/
@Override
public String getStatAdjustments(RaceFacade raceFacade) {
if (!(raceFacade instanceof Race)) {
return EMPTY_STRING;
}
Race race = (Race) raceFacade;
final StringBuilder retString = new StringBuilder(100);
for (PCStat stat : charDisplay.getStatSet()) {
if (charDisplay.isNonAbility(stat)) {
if (retString.length() > 0) {
retString.append(' ');
}
retString.append(stat.getKeyName() + ":Nonability");
} else {
if (BonusCalc.getStatMod(race, stat, pc) != 0) {
if (retString.length() > 0) {
retString.append(' ');
}
retString.append(stat.getKeyName() + ":" + BonusCalc.getStatMod(race, stat, pc));
}
}
}
return retString.toString();
}
use of pcgen.core.Race in project pcgen by PCGen.
the class ActiveSpellsFacet method process.
/**
* Currently used as a global reset for the spell list, since
* ActiveSpellsFacet does not currently listen to all scenarios which can
* alter Spells granted to a Player Character.
*
* Use of this method outside this facet is discouraged, as the long term
* goal is to get all of the processing for Spells into this Facet.
* Therefore, use of this global reset indicates incomplete implementation
* of Spells processing in this facet, and should be an indication that
* additional work is required in order to enhance the capability of this
* facet to appropriately update the Spells for a Player Character.
*
* @param id
* The CharID identifying the Player Character that requires a
* reset on the list of spells granted to the Player Character.
*/
public void process(CharID id) {
Race race = raceFacet.get(id);
removeAll(id, race);
PlayerCharacter pc = trackingFacet.getPC(id);
for (SpellLikeAbility sla : spellsFacet.getQualifiedSet(id)) {
Formula times = sla.getCastTimes();
int resolvedTimes = formulaResolvingFacet.resolve(id, times, sla.getQualifiedKey()).intValue();
String book = sla.getSpellBook();
final CharacterSpell cs = new CharacterSpell(race, sla.getSpell());
cs.setFixedCasterLevel(sla.getFixedCasterLevel());
SpellInfo si = cs.addInfo(0, resolvedTimes, book);
si.setTimeUnit(sla.getCastTimeUnit());
si.setFixedDC(sla.getDC());
pc.addSpellBook(new SpellBook(book, SpellBook.TYPE_INNATE_SPELLS));
add(id, cs, race);
}
}
Aggregations