Search in sources :

Example 16 with WeaponProf

use of pcgen.core.WeaponProf in project pcgen by PCGen.

the class WeaponbonusToken method parseTokenWithSeparator.

@Override
protected ParseResult parseTokenWithSeparator(LoadContext context, PCClass pcc, String value) {
    StringTokenizer tok = new StringTokenizer(value, Constants.PIPE);
    boolean foundAny = false;
    boolean foundOther = false;
    while (tok.hasMoreTokens()) {
        String tokText = tok.nextToken();
        if (Constants.LST_ALL.equals(tokText)) {
            foundAny = true;
            CDOMReference<WeaponProf> ref = context.getReferenceContext().getCDOMAllReference(WEAPONPROF_CLASS);
            context.getObjectContext().addToList(pcc, ListKey.WEAPONBONUS, ref);
        } else {
            foundOther = true;
            CDOMReference<WeaponProf> ref = TokenUtilities.getTypeOrPrimitive(context, WEAPONPROF_CLASS, tokText);
            if (ref == null) {
                return new ParseResult.Fail("  Error was encountered while parsing " + getTokenName(), context);
            }
            context.getObjectContext().addToList(pcc, ListKey.WEAPONBONUS, ref);
        }
    }
    if (foundAny && foundOther) {
        return new ParseResult.Fail("Non-sensical " + getTokenName() + ": Contains ANY and a specific reference: " + value, context);
    }
    return ParseResult.SUCCESS;
}
Also used : StringTokenizer(java.util.StringTokenizer) WeaponProf(pcgen.core.WeaponProf)

Example 17 with WeaponProf

use of pcgen.core.WeaponProf in project pcgen by PCGen.

the class WeaponbonusToken method parseTokenWithSeparator.

@Override
protected ParseResult parseTokenWithSeparator(LoadContext context, Race race, String value) {
    StringTokenizer tok = new StringTokenizer(value, Constants.PIPE);
    boolean foundAny = false;
    boolean foundOther = false;
    while (tok.hasMoreTokens()) {
        String tokText = tok.nextToken();
        if (Constants.LST_ALL.equals(tokText)) {
            foundAny = true;
            CDOMReference<WeaponProf> ref = context.getReferenceContext().getCDOMAllReference(WEAPONPROF_CLASS);
            context.getObjectContext().addToList(race, ListKey.WEAPONBONUS, ref);
        } else {
            foundOther = true;
            CDOMReference<WeaponProf> ref = TokenUtilities.getTypeOrPrimitive(context, WEAPONPROF_CLASS, tokText);
            if (ref == null) {
                return new ParseResult.Fail("  Error was encountered while parsing " + getTokenName(), context);
            }
            context.getObjectContext().addToList(race, ListKey.WEAPONBONUS, ref);
        }
    }
    if (foundAny && foundOther) {
        return new ParseResult.Fail("Non-sensical " + getTokenName() + ": Contains ANY and a specific reference: " + value, context);
    }
    return ParseResult.SUCCESS;
}
Also used : StringTokenizer(java.util.StringTokenizer) WeaponProf(pcgen.core.WeaponProf)

Example 18 with WeaponProf

use of pcgen.core.WeaponProf in project pcgen by PCGen.

the class NaturalWeaponProfFacetTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    CDOMObject cdo1 = new PCTemplate();
    cdo1.setName("Template1");
    CDOMObject cdo2 = new Race();
    cdo2.setName("Race1");
    WeaponProf st1 = new WeaponProf();
    st1.setName("Prof1");
    WeaponProf st2 = new WeaponProf();
    st1.setName("Prof2");
    cdo1.addToListFor(ListKey.IMPLIED_WEAPONPROF, CDOMDirectSingleRef.getRef(st1));
    cdo2.addToListFor(ListKey.IMPLIED_WEAPONPROF, CDOMDirectSingleRef.getRef(st2));
    source = new CDOMObject[] { cdo1, cdo2 };
    target = new WeaponProf[] { st1, st2 };
}
Also used : CDOMObject(pcgen.cdom.base.CDOMObject) Race(pcgen.core.Race) WeaponProf(pcgen.core.WeaponProf) PCTemplate(pcgen.core.PCTemplate)

Example 19 with WeaponProf

use of pcgen.core.WeaponProf in project pcgen by PCGen.

the class EquipmentQualifierTokenTest method initializeObjects.

private void initializeObjects() {
    wp1 = new WeaponProf();
    wp1.setName("Eq1");
    primaryContext.getReferenceContext().importObject(wp1);
    eq1 = new Equipment();
    eq1.setName("Eq1");
    primaryContext.getReferenceContext().importObject(eq1);
    primaryContext.unconditionallyProcess(eq1, "TYPE", "WEAPON");
    primaryContext.unconditionallyProcess(eq1, "PROFICIENCY", "WEAPON|Eq1");
    sp1 = new ShieldProf();
    sp1.setName("Eq2");
    primaryContext.getReferenceContext().importObject(sp1);
    eq2 = new Equipment();
    eq2.setName("Eq2");
    primaryContext.getReferenceContext().importObject(eq2);
    primaryContext.unconditionallyProcess(eq2, "TYPE", "SHIELD");
    primaryContext.unconditionallyProcess(eq2, "PROFICIENCY", "SHIELD|Eq2");
    ap1 = new ArmorProf();
    ap1.setName("Eq3");
    primaryContext.getReferenceContext().importObject(ap1);
    eq3 = new Equipment();
    eq3.setName("Eq3");
    primaryContext.getReferenceContext().importObject(eq3);
    primaryContext.unconditionallyProcess(eq3, "TYPE", "ARMOR.Masterful");
    primaryContext.unconditionallyProcess(eq3, "PROFICIENCY", "ARMOR|Eq3");
    sp2 = new ShieldProf();
    sp2.setName("Wp2");
    primaryContext.getReferenceContext().importObject(sp2);
    eq4 = new Equipment();
    eq4.setName("Eq4");
    primaryContext.getReferenceContext().importObject(eq4);
    primaryContext.unconditionallyProcess(eq4, "TYPE", "SHIELD.Masterful");
    primaryContext.unconditionallyProcess(eq4, "PROFICIENCY", "SHIELD|Wp2");
}
Also used : ShieldProf(pcgen.core.ShieldProf) Equipment(pcgen.core.Equipment) WeaponProf(pcgen.core.WeaponProf) ArmorProf(pcgen.core.ArmorProf)

Example 20 with WeaponProf

use of pcgen.core.WeaponProf in project pcgen by PCGen.

the class EquipmentQualifierTokenTest method initializeObjects.

private void initializeObjects() {
    wp1 = new WeaponProf();
    wp1.setName("Eq1");
    primaryContext.getReferenceContext().importObject(wp1);
    eq1 = new Equipment();
    eq1.setName("Eq1");
    primaryContext.getReferenceContext().importObject(eq1);
    primaryContext.unconditionallyProcess(eq1, "TYPE", "WEAPON");
    primaryContext.unconditionallyProcess(eq1, "PROFICIENCY", "WEAPON|Eq1");
    sp1 = new ShieldProf();
    sp1.setName("Eq2");
    primaryContext.getReferenceContext().importObject(sp1);
    eq2 = new Equipment();
    eq2.setName("Eq2");
    primaryContext.getReferenceContext().importObject(eq2);
    primaryContext.unconditionallyProcess(eq2, "TYPE", "SHIELD.Masterful");
    primaryContext.unconditionallyProcess(eq2, "PROFICIENCY", "SHIELD|Eq2");
    ap1 = new ArmorProf();
    ap1.setName("Eq3");
    primaryContext.getReferenceContext().importObject(ap1);
    eq3 = new Equipment();
    eq3.setName("Eq3");
    primaryContext.getReferenceContext().importObject(eq3);
    primaryContext.unconditionallyProcess(eq3, "TYPE", "ARMOR");
    primaryContext.unconditionallyProcess(eq3, "PROFICIENCY", "ARMOR|Eq3");
    ap2 = new ArmorProf();
    ap2.setName("Ap2");
    primaryContext.getReferenceContext().importObject(ap2);
    eq4 = new Equipment();
    eq4.setName("Eq4");
    primaryContext.getReferenceContext().importObject(eq4);
    primaryContext.unconditionallyProcess(eq4, "TYPE", "ARMOR.Masterful");
    primaryContext.unconditionallyProcess(eq4, "PROFICIENCY", "ARMOR|Ap2");
}
Also used : ShieldProf(pcgen.core.ShieldProf) Equipment(pcgen.core.Equipment) WeaponProf(pcgen.core.WeaponProf) ArmorProf(pcgen.core.ArmorProf)

Aggregations

WeaponProf (pcgen.core.WeaponProf)56 StringTokenizer (java.util.StringTokenizer)10 Test (org.junit.Test)10 Equipment (pcgen.core.Equipment)10 CDOMReference (pcgen.cdom.base.CDOMReference)6 ArrayList (java.util.ArrayList)5 CDOMObject (pcgen.cdom.base.CDOMObject)5 Deity (pcgen.core.Deity)5 ArmorProf (pcgen.core.ArmorProf)4 PCTemplate (pcgen.core.PCTemplate)4 ShieldProf (pcgen.core.ShieldProf)4 HashSet (java.util.HashSet)3 ChangeProf (pcgen.cdom.content.ChangeProf)3 WeaponProfProvider (pcgen.cdom.helper.WeaponProfProvider)3 CDOMSingleRef (pcgen.cdom.reference.CDOMSingleRef)3 PCClass (pcgen.core.PCClass)3 Race (pcgen.core.Race)3 Type (pcgen.cdom.enumeration.Type)2 EquipmentHead (pcgen.cdom.inst.EquipmentHead)2 CDOMGroupRef (pcgen.cdom.reference.CDOMGroupRef)2