Search in sources :

Example 66 with PCClassLevel

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));
}
Also used : DataFacetChangeEvent(pcgen.cdom.facet.event.DataFacetChangeEvent) Skill(pcgen.core.Skill) CDOMObject(pcgen.cdom.base.CDOMObject) CDOMObject(pcgen.cdom.base.CDOMObject) CharID(pcgen.cdom.enumeration.CharID) CDOMReference(pcgen.cdom.base.CDOMReference) PCClassLevel(pcgen.cdom.inst.PCClassLevel) Test(org.junit.Test)

Example 67 with PCClassLevel

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());
            }
        }
    }
}
Also used : Domain(pcgen.core.Domain) CDOMSingleRef(pcgen.cdom.reference.CDOMSingleRef) PCClassLevel(pcgen.cdom.inst.PCClassLevel)

Example 68 with PCClassLevel

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;
}
Also used : Formula(pcgen.base.formula.Formula) PCClassLevel(pcgen.cdom.inst.PCClassLevel)

Example 69 with PCClassLevel

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);
    }
}
Also used : PCClassLevel(pcgen.cdom.inst.PCClassLevel)

Aggregations

PCClassLevel (pcgen.cdom.inst.PCClassLevel)69 PCClass (pcgen.core.PCClass)26 Test (org.junit.Test)25 PCLevelInfo (pcgen.core.pclevelinfo.PCLevelInfo)9 CDOMObject (pcgen.cdom.base.CDOMObject)8 ArrayList (java.util.ArrayList)5 CharID (pcgen.cdom.enumeration.CharID)5 ParseResult (pcgen.rules.persistence.token.ParseResult)5 CDOMReference (pcgen.cdom.base.CDOMReference)4 SpecialAbility (pcgen.core.SpecialAbility)4 LoadContext (pcgen.rules.context.LoadContext)4 AbstractTokenModelTest (tokenmodel.testsupport.AbstractTokenModelTest)4 StringTokenizer (java.util.StringTokenizer)3 DataFacetChangeEvent (pcgen.cdom.facet.event.DataFacetChangeEvent)3 Domain (pcgen.core.Domain)3 Skill (pcgen.core.Skill)3 TestContext (plugin.lsttokens.editcontext.testsupport.TestContext)3 BigDecimal (java.math.BigDecimal)2 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2