use of pcgen.cdom.content.LevelCommandFactory in project pcgen by PCGen.
the class CharacterDisplay method getRacialHDSize.
public int getRacialHDSize() {
int hdSize = 0;
LevelCommandFactory lcf = getRace().get(ObjectKey.MONSTER_CLASS);
if (lcf != null) {
hdSize = getLevelHitDie(lcf.getPCClass(), 1).getDie();
}
return hdSize;
}
use of pcgen.cdom.content.LevelCommandFactory in project pcgen by PCGen.
the class MonsterClassFacet method dataRemoved.
/**
* Removes monster classes from the Player Character when the CDOMObject
* which granted the monster classes is removed from the Player Character.
*
* Triggered when one of the Facets to which MonsterClassFacet listens fires
* a DataFacetChangeEvent to indicate a CDOMObject was removed from a Player
* Character.
*
* @param dfce
* The DataFacetChangeEvent containing the information about the
* change
*
* @see pcgen.cdom.facet.event.DataFacetChangeListener#dataRemoved(pcgen.cdom.facet.event.DataFacetChangeEvent)
*/
@Override
public void dataRemoved(DataFacetChangeEvent<CharID, CDOMObject> dfce) {
CDOMObject cdo = dfce.getCDOMObject();
LevelCommandFactory lcf = cdo.get(ObjectKey.MONSTER_CLASS);
if (lcf != null) {
CharID id = dfce.getCharID();
int levelCount = formulaResolvingFacet.resolve(id, lcf.getLevelCount(), "").intValue();
PlayerCharacter pc = trackingFacet.getPC(id);
pc.incrementClassLevel(-levelCount, lcf.getPCClass(), true);
}
}
use of pcgen.cdom.content.LevelCommandFactory in project pcgen by PCGen.
the class MonsterClassFacet method dataAdded.
/**
* Adds monster classes to the Player Character when a CDOMObject which
* grants monster classes is added to the Player Character.
*
* Triggered when one of the Facets to which MonsterClassFacet listens fires
* a DataFacetChangeEvent to indicate a CDOMObject was added to a Player
* Character.
*
* @param dfce
* The DataFacetChangeEvent containing the information about the
* change
*
* @see pcgen.cdom.facet.event.DataFacetChangeListener#dataAdded(pcgen.cdom.facet.event.DataFacetChangeEvent)
*/
@Override
public void dataAdded(DataFacetChangeEvent<CharID, CDOMObject> dfce) {
CharID id = dfce.getCharID();
CDOMObject cdo = dfce.getCDOMObject();
// Get existing classes
ClassInfo ci = classFacet.removeAllClasses(id);
//
for (int i = levelInfoFacet.getCount(id) - 1; i >= 0; --i) {
PCLevelInfo pli = levelInfoFacet.get(id, i);
final String classKeyName = pli.getClassKeyName();
final PCClass aClass = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(PCClass.class, classKeyName);
if (aClass.isMonster()) {
levelInfoFacet.remove(id, pli);
}
}
PlayerCharacter pc = trackingFacet.getPC(id);
final List<PCLevelInfo> existingLevelInfo = new ArrayList<>(levelInfoFacet.getSet(id));
levelInfoFacet.removeAll(id);
// Make sure monster classes are added first
if (!pc.isImporting()) {
LevelCommandFactory lcf = cdo.get(ObjectKey.MONSTER_CLASS);
if (lcf != null) {
int levelCount = formulaResolvingFacet.resolve(id, lcf.getLevelCount(), "").intValue();
pc.incrementClassLevel(levelCount, lcf.getPCClass(), true);
}
}
levelInfoFacet.addAll(id, existingLevelInfo);
//
if (!pc.isImporting() && ci != null && !ci.isEmpty()) {
int totalLevels = levelFacet.getTotalLevels(id);
for (PCClass pcClass : ci.getClassSet()) {
//
if (!pcClass.isMonster()) {
classFacet.addClass(id, pcClass);
int cLevels = ci.getLevel(pcClass);
classFacet.setLevel(id, pcClass, cLevels);
pc.setSkillPool(pcClass, 0);
int cMod = 0;
for (int j = 0; j < cLevels; ++j) {
cMod += pc.recalcSkillPointMod(pcClass, ++totalLevels);
}
pc.setSkillPool(pcClass, cMod);
}
}
}
}
use of pcgen.cdom.content.LevelCommandFactory in project pcgen by PCGen.
the class AddLevelFacet method dataRemoved.
/**
* Drives the necessary removal of the results of an ADDLEVEL: token to
* remove the added levels from a Player Character because the object
* granting the ADDLEVEL: was removed from the Player Character.
*
* Triggered when one of the Facets to which AddLevelFacet listens fires a
* DataFacetChangeEvent to indicate a CDOMObject was added to a Player
* Character.
*
* @param dfce
* The DataFacetChangeEvent containing the information about the
* change
*
* @see pcgen.cdom.facet.event.DataFacetChangeListener#dataAdded(pcgen.cdom.facet.event.DataFacetChangeEvent)
*/
@Override
public void dataRemoved(DataFacetChangeEvent<CharID, PCTemplate> dfce) {
PCTemplate template = dfce.getCDOMObject();
CharID id = dfce.getCharID();
PlayerCharacter pc = trackingFacet.getPC(id);
List<LevelCommandFactory> lcfList = template.getSafeListFor(ListKey.ADD_LEVEL);
for (ListIterator<LevelCommandFactory> it = lcfList.listIterator(lcfList.size()); it.hasPrevious(); ) {
LevelCommandFactory lcf = it.previous();
remove(lcf.getLevelCount(), lcf.getPCClass(), pc);
}
}
use of pcgen.cdom.content.LevelCommandFactory in project pcgen by PCGen.
the class PreLevelTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
PCClass raceClass = new PCClass();
raceClass.setName("Race Class");
raceClass.put(StringKey.KEY_NAME, "RaceClass");
Globals.getContext().getReferenceContext().importObject(raceClass);
race.setName("Gnoll");
race.put(ObjectKey.MONSTER_CLASS, new LevelCommandFactory(CDOMDirectSingleRef.getRef(raceClass), FormulaFactory.getFormulaFor(2)));
myClass.setName("My Class");
myClass.put(StringKey.KEY_NAME, "MY_CLASS");
myClass.put(FormulaKey.START_SKILL_POINTS, FormulaFactory.getFormulaFor(3));
Globals.getContext().getReferenceContext().importObject(myClass);
}
Aggregations