Search in sources :

Example 1 with WeaponProfProvider

use of pcgen.cdom.helper.WeaponProfProvider in project pcgen by PCGen.

the class PCClass method inheritAttributesFrom.

/*
	 * REFACTOR Some derivative of this method will be in PCClass only as part
	 * of the factory creation of a PCClassLevel... or perhaps in PCClassLevel
	 * so it can steal some information from other PCClassLevels of that
	 * PCClass. Either way, this will be far from its current form in the final
	 * solution.
	 */
/*
	 * CONSIDER Why does this not inherit classSkillChoices?
	 */
public void inheritAttributesFrom(final PCClass otherClass) {
    Boolean hbss = otherClass.get(ObjectKey.HAS_BONUS_SPELL_STAT);
    if (hbss != null) {
        put(ObjectKey.HAS_BONUS_SPELL_STAT, hbss);
        CDOMSingleRef<PCStat> bss = otherClass.get(ObjectKey.BONUS_SPELL_STAT);
        if (bss != null) {
            put(ObjectKey.BONUS_SPELL_STAT, bss);
        }
    }
    Boolean usbs = otherClass.get(ObjectKey.USE_SPELL_SPELL_STAT);
    if (usbs != null) {
        put(ObjectKey.USE_SPELL_SPELL_STAT, usbs);
    }
    Boolean cwss = otherClass.get(ObjectKey.CASTER_WITHOUT_SPELL_STAT);
    if (cwss != null) {
        put(ObjectKey.CASTER_WITHOUT_SPELL_STAT, cwss);
    }
    CDOMSingleRef<PCStat> ss = otherClass.get(ObjectKey.SPELL_STAT);
    if (ss != null) {
        put(ObjectKey.SPELL_STAT, ss);
    }
    TransitionChoice<CDOMListObject<Spell>> slc = otherClass.get(ObjectKey.SPELLLIST_CHOICE);
    if (slc != null) {
        put(ObjectKey.SPELLLIST_CHOICE, slc);
    }
    List<QualifiedObject<CDOMReference<Equipment>>> e = otherClass.getListFor(ListKey.EQUIPMENT);
    if (e != null) {
        addAllToListFor(ListKey.EQUIPMENT, e);
    }
    List<WeaponProfProvider> wp = otherClass.getListFor(ListKey.WEAPONPROF);
    if (wp != null) {
        addAllToListFor(ListKey.WEAPONPROF, wp);
    }
    QualifiedObject<Boolean> otherWP = otherClass.get(ObjectKey.HAS_DEITY_WEAPONPROF);
    if (otherWP != null) {
        put(ObjectKey.HAS_DEITY_WEAPONPROF, otherWP);
    }
    List<ArmorProfProvider> ap = otherClass.getListFor(ListKey.AUTO_ARMORPROF);
    if (ap != null) {
        addAllToListFor(ListKey.AUTO_ARMORPROF, ap);
    }
    List<ShieldProfProvider> sp = otherClass.getListFor(ListKey.AUTO_SHIELDPROF);
    if (sp != null) {
        addAllToListFor(ListKey.AUTO_SHIELDPROF, sp);
    }
    List<BonusObj> bonusList = otherClass.getListFor(ListKey.BONUS);
    if (bonusList != null) {
        addAllToListFor(ListKey.BONUS, bonusList);
    }
    try {
        ownBonuses(this);
    } catch (CloneNotSupportedException ce) {
        // TODO Auto-generated catch block
        ce.printStackTrace();
    }
    for (VariableKey vk : otherClass.getVariableKeys()) {
        put(vk, otherClass.get(vk));
    }
    if (otherClass.containsListFor(ListKey.CSKILL)) {
        removeListFor(ListKey.CSKILL);
        addAllToListFor(ListKey.CSKILL, otherClass.getListFor(ListKey.CSKILL));
    }
    if (otherClass.containsListFor(ListKey.LOCALCCSKILL)) {
        removeListFor(ListKey.LOCALCCSKILL);
        addAllToListFor(ListKey.LOCALCCSKILL, otherClass.getListFor(ListKey.LOCALCCSKILL));
    }
    removeListFor(ListKey.KIT_CHOICE);
    addAllToListFor(ListKey.KIT_CHOICE, otherClass.getSafeListFor(ListKey.KIT_CHOICE));
    remove(ObjectKey.REGION_CHOICE);
    if (otherClass.containsKey(ObjectKey.REGION_CHOICE)) {
        put(ObjectKey.REGION_CHOICE, otherClass.get(ObjectKey.REGION_CHOICE));
    }
    removeListFor(ListKey.SAB);
    addAllToListFor(ListKey.SAB, otherClass.getSafeListFor(ListKey.SAB));
    /*
		 * TODO Does this need to have things from the Class Level objects?
		 * I don't think so based on deferred processing of levels...
		 */
    addAllToListFor(ListKey.DAMAGE_REDUCTION, otherClass.getListFor(ListKey.DAMAGE_REDUCTION));
    for (CDOMReference<Vision> ref : otherClass.getSafeListMods(Vision.VISIONLIST)) {
        for (AssociatedPrereqObject apo : otherClass.getListAssociations(Vision.VISIONLIST, ref)) {
            putToList(Vision.VISIONLIST, ref, apo);
        }
    }
    /*
		 * TODO This is a clone problem, but works for now - thpr 10/3/08
		 */
    if (otherClass instanceof SubClass) {
        levelMap.clear();
        copyLevelsFrom(otherClass);
    }
    addAllToListFor(ListKey.NATURAL_WEAPON, otherClass.getListFor(ListKey.NATURAL_WEAPON));
    put(ObjectKey.LEVEL_HITDIE, otherClass.get(ObjectKey.LEVEL_HITDIE));
}
Also used : BonusObj(pcgen.core.bonus.BonusObj) CDOMListObject(pcgen.cdom.base.CDOMListObject) WeaponProfProvider(pcgen.cdom.helper.WeaponProfProvider) ArmorProfProvider(pcgen.cdom.helper.ArmorProfProvider) VariableKey(pcgen.cdom.enumeration.VariableKey) ShieldProfProvider(pcgen.cdom.helper.ShieldProfProvider) AssociatedPrereqObject(pcgen.cdom.base.AssociatedPrereqObject)

Example 2 with WeaponProfProvider

use of pcgen.cdom.helper.WeaponProfProvider in project pcgen by PCGen.

the class WeaponProfTokenTest method loadAllReference.

@Override
protected void loadAllReference() {
    WeaponProfProvider wpp = new WeaponProfProvider();
    wpp.addWeaponProfAll(primaryContext.getReferenceContext().getCDOMAllReference(WeaponProf.class));
    primaryProf.addToListFor(ListKey.WEAPONPROF, wpp);
}
Also used : WeaponProf(pcgen.core.WeaponProf) WeaponProfProvider(pcgen.cdom.helper.WeaponProfProvider)

Example 3 with WeaponProfProvider

use of pcgen.cdom.helper.WeaponProfProvider in project pcgen by PCGen.

the class WeaponProfTokenTest method testUnparseSingleEmpty.

@Test
public void testUnparseSingleEmpty() throws PersistenceLayerException {
    WeaponProfProvider wpp = new WeaponProfProvider();
    primaryProf.addToListFor(ListKey.WEAPONPROF, wpp);
    assertBadUnparse();
}
Also used : WeaponProfProvider(pcgen.cdom.helper.WeaponProfProvider) Test(org.junit.Test)

Example 4 with WeaponProfProvider

use of pcgen.cdom.helper.WeaponProfProvider in project pcgen by PCGen.

the class WeaponProfTokenTest method testUnparseIndivAll.

@Test
public void testUnparseIndivAll() throws PersistenceLayerException {
    WeaponProfProvider wpp = new WeaponProfProvider();
    wpp.addWeaponProfAll(primaryContext.getReferenceContext().getCDOMAllReference(WeaponProf.class));
    WeaponProf wp1 = construct(primaryContext, "TestWP1");
    CDOMSingleRef<WeaponProf> ref = CDOMDirectSingleRef.getRef(wp1);
    wpp.addWeaponProf(ref);
    primaryProf.addToListFor(ListKey.WEAPONPROF, wpp);
    assertBadUnparse();
}
Also used : WeaponProf(pcgen.core.WeaponProf) WeaponProfProvider(pcgen.cdom.helper.WeaponProfProvider) Test(org.junit.Test)

Example 5 with WeaponProfProvider

use of pcgen.cdom.helper.WeaponProfProvider in project pcgen by PCGen.

the class WeaponProfTokenTest method loadProf.

@Override
protected void loadProf(CDOMSingleRef<WeaponProf> ref) {
    WeaponProfProvider wpp = new WeaponProfProvider();
    wpp.addWeaponProf(ref);
    primaryProf.addToListFor(ListKey.WEAPONPROF, wpp);
}
Also used : WeaponProfProvider(pcgen.cdom.helper.WeaponProfProvider)

Aggregations

WeaponProfProvider (pcgen.cdom.helper.WeaponProfProvider)10 WeaponProf (pcgen.core.WeaponProf)4 Test (org.junit.Test)3 Prerequisite (pcgen.core.prereq.Prerequisite)2 ArrayList (java.util.ArrayList)1 StringTokenizer (java.util.StringTokenizer)1 AssociatedPrereqObject (pcgen.cdom.base.AssociatedPrereqObject)1 CDOMListObject (pcgen.cdom.base.CDOMListObject)1 CDOMObject (pcgen.cdom.base.CDOMObject)1 ChooseSelectionActor (pcgen.cdom.base.ChooseSelectionActor)1 ConditionalSelectionActor (pcgen.cdom.content.ConditionalSelectionActor)1 VariableKey (pcgen.cdom.enumeration.VariableKey)1 ArmorProfProvider (pcgen.cdom.helper.ArmorProfProvider)1 ShieldProfProvider (pcgen.cdom.helper.ShieldProfProvider)1 CDOMGroupRef (pcgen.cdom.reference.CDOMGroupRef)1 CDOMSingleRef (pcgen.cdom.reference.CDOMSingleRef)1 QualifiedObject (pcgen.core.QualifiedObject)1 BonusObj (pcgen.core.bonus.BonusObj)1 PersistenceLayerException (pcgen.persistence.PersistenceLayerException)1 ParseResult (pcgen.rules.persistence.token.ParseResult)1