use of pcgen.cdom.inst.PCClassLevel in project pcgen by PCGen.
the class LocalSkillCostFacetTest method testAddTwoSources.
@Test
public void testAddTwoSources() {
Skill t1 = getObject();
assertFalse(getFacet().contains(id, class1, SkillCost.CLASS, t1));
addCost(id, class1, t1, SkillCost.CLASS);
assertTrue(getFacet().contains(id, class1, SkillCost.CLASS, t1));
assertFalse(getFacet().contains(id, class1, SkillCost.CROSS_CLASS, t1));
//No cross pollution
assertFalse(getFacet().contains(altid, class1, SkillCost.CLASS, t1));
//Second add doesn't change anything
PCClassLevel pcl = new PCClassLevel();
pcl.put(ObjectKey.PARENT, class1);
DataFacetChangeEvent<CharID, CDOMObject> dfce = new DataFacetChangeEvent<>(id, pcl, new Object(), DataFacetChangeEvent.DATA_ADDED);
ListKey<CDOMReference<Skill>> lk = ListKey.LOCALCSKILL;
pcl.addToListFor(lk, CDOMDirectSingleRef.getRef(t1));
getFacet().dataAdded(dfce);
assertTrue(getFacet().contains(id, class1, SkillCost.CLASS, t1));
assertFalse(getFacet().contains(id, class1, SkillCost.CROSS_CLASS, t1));
//No cross pollution
assertFalse(getFacet().contains(altid, class1, SkillCost.CLASS, t1));
}
use of pcgen.cdom.inst.PCClassLevel in project pcgen by PCGen.
the class DomainApplication method removeDomainsForLevel.
public static void removeDomainsForLevel(PCClass cl, final int removedLevel, final PlayerCharacter aPC) {
/*
* Note this uses ALL of the domains up to and including this level,
* because there is the possibility (albeit strange) that the PC was
* qualified at a previous level change, but the PlayerCharacter is now
* not qualified for the given Domain. Even this has quirks, since it is
* only applied at the time of level increase, but I think that quirk
* should be resolved by a CDOM system around 6.0 - thpr 10/23/06
*/
for (QualifiedObject<CDOMSingleRef<Domain>> qo : cl.getSafeListFor(ListKey.DOMAIN)) {
CDOMSingleRef<Domain> ref = qo.getObject(aPC, cl);
if (ref == null) {
ref = qo.getRawObject();
aPC.removeDomain(ref.get());
}
}
for (int i = 0; i <= removedLevel; i++) {
// TODO This stinks for really high level characters - can this ever
// get null back?
PCClassLevel pcl = aPC.getActiveClassLevel(cl, i);
for (QualifiedObject<CDOMSingleRef<Domain>> qo : pcl.getSafeListFor(ListKey.DOMAIN)) {
CDOMSingleRef<Domain> ref = qo.getObject(aPC, cl);
if ((ref == null) || (i == removedLevel)) {
ref = qo.getRawObject();
aPC.removeDomain(ref.get());
}
}
}
}
use of pcgen.cdom.inst.PCClassLevel in project pcgen by PCGen.
the class SpellSupportForPCClass method updateSpellCache.
public boolean updateSpellCache(boolean force) {
if (force || !spellCacheValid) {
SpellProgressionCache cache = new SpellProgressionCache();
for (PCClassLevel cl : source.getOriginalClassLevelCollection()) {
Integer lvl = cl.get(IntegerKey.LEVEL);
List<Formula> cast = cl.getListFor(ListKey.CAST);
if (cast != null) {
cache.setCast(lvl, cast);
}
List<Formula> known = cl.getListFor(ListKey.KNOWN);
if (known != null) {
cache.setKnown(lvl, known);
}
List<Formula> spec = cl.getListFor(ListKey.SPECIALTYKNOWN);
if (spec != null) {
cache.setSpecialtyKnown(lvl, spec);
}
}
if (!cache.isEmpty()) {
spellCache = cache;
}
spellCacheValid = true;
}
return spellCache != null;
}
use of pcgen.cdom.inst.PCClassLevel in project pcgen by PCGen.
the class PCClassKeyChange method changeReferences.
public static void changeReferences(String oldClass, PCClass pcc) {
String newClass = pcc.getKeyName();
// Don't traverse the list if the names are the same
if (oldClass.equals(newClass)) {
return;
}
renameVariables(oldClass, pcc, newClass);
renameBonusTarget(pcc, oldClass, newClass);
// Repeat for Class Levels
for (PCClassLevel pcl : pcc.getOriginalClassLevelCollection()) {
renameVariables(oldClass, pcl, newClass);
renameBonusTarget(pcl, oldClass, newClass);
}
}
Aggregations