use of pcgen.cdom.inst.PCClassLevel in project pcgen by PCGen.
the class PlayerCharacter method getCDOMObjectList.
public List<? extends CDOMObject> getCDOMObjectList() {
List<CDOMObject> list = new ArrayList<>(expandedCampaignFacet.getSet(id));
// Loaded campaigns
// Alignment
PCAlignment align = alignmentFacet.get(id);
if (align != null) {
list.add(align);
}
// BioSet
list.add(bioSetFacet.get(id));
list.addAll(checkFacet.getSet(id));
// Class
list.addAll(classFacet.getSet(id));
// CompanionMod
list.addAll(companionModFacet.getSet(id));
// Deity
Deity deity = deityFacet.get(id);
if (deity != null) {
list.add(deity);
}
// Domain
list.addAll(domainFacet.getSet(id));
// Equipment
for (Equipment eq : activeEquipmentFacet.getSet(id)) {
list.add(eq);
for (EquipmentModifier eqMod : eq.getEqModifierList(true)) {
list.add(eqMod);
}
for (EquipmentModifier eqMod : eq.getEqModifierList(false)) {
list.add(eqMod);
}
}
// Feats and abilities (virtual feats, auto feats)
for (AbilityCategory cat : SettingsHandler.getGame().getAllAbilityCategories()) {
list.addAll(getAggregateAbilityListNoDuplicates(cat));
}
// Race
Race race = raceFacet.get(id);
if (race != null) {
list.add(race);
}
// SizeAdjustment
SizeAdjustment sa = sizeFacet.get(id);
if (sa != null) {
list.add(sa);
}
// Skill
list.addAll(skillFacet.getSet(id));
// Stat (PCStat)
list.addAll(statFacet.getSet(id));
// Template (PCTemplate)
list.addAll(templateFacet.getSet(id));
for (PCClass cl : getClassSet()) {
for (int i = 1; i <= getLevel(cl); i++) {
PCClassLevel classLevel = getActiveClassLevel(cl, i);
list.add(classLevel);
}
}
return list;
}
use of pcgen.cdom.inst.PCClassLevel in project pcgen by PCGen.
the class PlayerCharacter method makeIntoExClass.
public void makeIntoExClass(final PCClass fromClass) {
CDOMSingleRef<PCClass> exc = fromClass.get(ObjectKey.EX_CLASS);
try {
PCClass cl = exc.get();
PCClass toClass = getClassKeyed(cl.getKeyName());
boolean bClassNew;
int toLevel;
if (toClass == null) {
//Still required :(
toClass = cl.clone();
bClassNew = true;
toLevel = 0;
} else {
bClassNew = false;
toLevel = getLevel(toClass);
}
//Capture necessary information
final int fromLevel = getLevel(fromClass);
Integer[] hpArray = new Integer[fromLevel];
for (int i = 0; i < fromLevel; i++) {
PCClassLevel frompcl = getActiveClassLevel(fromClass, i);
Integer hp = getHP(frompcl);
if (hp == null) {
System.err.println("Did not find HP for " + fromClass + " " + (i + 1) + " " + frompcl);
}
hpArray[i] = hp;
}
for (int i = 0; i < fromLevel; i++) {
fromClass.doMinusLevelMods(this, fromLevel - i);
}
fromClass.setLevel(0, this);
//Do the class swap
if (bClassNew) {
classFacet.replaceClass(id, fromClass, toClass);
} else {
classFacet.removeClass(id, fromClass);
}
toClass.setLevel(toLevel + fromLevel, this);
//Restore capture info to new class
for (int i = 0; i < fromLevel; i++) {
PCClassLevel topcl = getActiveClassLevel(toClass, i);
setHP(topcl, hpArray[i]);
}
//
for (int idx = getLevelInfoSize() - 1; idx >= 0; --idx) {
final PCLevelInfo li = levelInfoFacet.get(id, idx);
if (li.getClassKeyName().equals(fromClass.getKeyName())) {
li.setClassKeyName(toClass.getKeyName());
}
}
//
for (Skill skill : getSkillSet()) {
SkillRankControl.replaceClassRank(this, skill, fromClass, cl);
}
setSkillPool(toClass, fromClass.getSkillPool(this));
} catch (NumberFormatException nfe) {
ShowMessageDelegate.showMessageDialog(nfe.getMessage(), Constants.APPLICATION_NAME, MessageType.INFORMATION);
}
}
use of pcgen.cdom.inst.PCClassLevel in project pcgen by PCGen.
the class PlayerCharacter method giveClassesAway.
public void giveClassesAway(final PCClass toClass, final PCClass fromClass, int iCount) {
if ((toClass == null) || (fromClass == null)) {
return;
}
// Will take destination class over maximum?
if (toClass.hasMaxLevel() && (getLevel(toClass) + iCount) > toClass.getSafe(IntegerKey.LEVEL_LIMIT)) {
iCount = toClass.getSafe(IntegerKey.LEVEL_LIMIT) - getLevel(toClass);
}
// Enough levels to move?
if ((getLevel(fromClass) <= iCount) || (iCount < 1)) {
return;
}
final int fromLevel = getLevel(fromClass);
final int iFromLevel = fromLevel - iCount;
final int toLevel = getLevel(toClass);
//Capture necessary information
Integer[] hpArray = new Integer[iCount + toLevel];
for (int i = 0; i < iCount; i++) {
PCClassLevel frompcl = getActiveClassLevel(fromClass, i + iFromLevel);
hpArray[i] = getHP(frompcl);
}
for (int i = 0; i < toLevel; i++) {
PCClassLevel topcl = getActiveClassLevel(toClass, i);
hpArray[i + iCount] = getHP(topcl);
}
for (int i = 0; i < iCount; i++) {
fromClass.doMinusLevelMods(this, fromLevel - i);
}
//Do the class level swap
fromClass.setLevel(iFromLevel, this);
toClass.setLevel(toLevel + iCount, this);
//Restore capture info to new class
for (int i = 0; i < iCount + toLevel; i++) {
PCClassLevel topcl = getActiveClassLevel(toClass, i);
setHP(topcl, hpArray[i]);
}
// first, change the toClass current PCLevelInfo level
for (PCLevelInfo pcl : getLevelInfo()) {
if (pcl.getClassKeyName().equals(toClass.getKeyName())) {
final int iTo = (pcl.getClassLevel() + getLevel(toClass)) - toLevel;
pcl.setClassLevel(iTo);
}
}
// change old class PCLevelInfo to the new class
for (PCLevelInfo pcl : getLevelInfo()) {
if (pcl.getClassKeyName().equals(fromClass.getKeyName()) && (pcl.getClassLevel() > iFromLevel)) {
final int iFrom = pcl.getClassLevel() - iFromLevel;
pcl.setClassKeyName(toClass.getKeyName());
pcl.setClassLevel(iFrom);
}
}
/*
* // get skills associated with old class and link to new class for
* (Iterator e = getSkillList().iterator(); e.hasNext();) { Skill aSkill =
* (Skill) e.next(); aSkill.replaceClassRank(fromClass.getName(),
* toClass.getName()); } toClass.setSkillPool(fromClass.getSkillPool());
*/
}
use of pcgen.cdom.inst.PCClassLevel in project pcgen by PCGen.
the class PlayerCharacter method checkSkillModChange.
public void checkSkillModChange() {
List<PCClass> newClasses = getClassList();
Collection<PCLevelInfo> levelInfo = getLevelInfo();
int levelIndex = 1;
for (PCLevelInfo lvlInfo : levelInfo) {
Map<String, PCClass> classMap = new HashMap<>();
for (PCClass pcClass : newClasses) {
classMap.put(pcClass.getKeyName(), pcClass);
}
final String classKeyName = lvlInfo.getClassKeyName();
PCClass currClass = classMap.get(classKeyName);
if (currClass == null) {
Logging.errorPrint("No PCClass found for '" + classKeyName + "' in character's class list: " + newClasses);
return;
}
PCClassLevel classLevel = getActiveClassLevel(currClass, lvlInfo.getClassLevel());
checkSkillModChangeForLevel(currClass, lvlInfo, classLevel, levelIndex++);
}
}
use of pcgen.cdom.inst.PCClassLevel in project pcgen by PCGen.
the class PCClass method getOriginalClassLevel.
public PCClassLevel getOriginalClassLevel(int lvl) {
if (!levelMap.containsKey(lvl)) {
PCClassLevel classLevel = new PCClassLevel();
classLevel.put(IntegerKey.LEVEL, lvl);
classLevel.setName(getDisplayName() + "(" + lvl + ")");
classLevel.put(StringKey.QUALIFIED_KEY, getQualifiedKey());
classLevel.put(ObjectKey.SOURCE_CAMPAIGN, get(ObjectKey.SOURCE_CAMPAIGN));
classLevel.put(StringKey.SOURCE_PAGE, get(StringKey.SOURCE_PAGE));
classLevel.put(StringKey.SOURCE_LONG, get(StringKey.SOURCE_LONG));
classLevel.put(StringKey.SOURCE_SHORT, get(StringKey.SOURCE_SHORT));
classLevel.put(StringKey.SOURCE_WEB, get(StringKey.SOURCE_WEB));
classLevel.put(ObjectKey.SOURCE_DATE, get(ObjectKey.SOURCE_DATE));
classLevel.put(ObjectKey.TOKEN_PARENT, this);
levelMap.put(lvl, classLevel);
}
return levelMap.get(lvl);
}
Aggregations