Search in sources :

Example 26 with WeaponProf

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

the class PreWeaponProfTest method setUp.

/**
	 * @see pcgen.AbstractCharacterTestCase#setUp()
	 */
@Override
protected void setUp() throws Exception {
    super.setUp();
    WeaponProf Longsword = new WeaponProf();
    Longsword.setName("Longsword");
    Longsword.addToListFor(ListKey.TYPE, Type.getConstant("Martial"));
    Globals.getContext().getReferenceContext().importObject(Longsword);
    WeaponProf Longbow = new WeaponProf();
    Longbow.setName("Longbow");
    Longbow.addToListFor(ListKey.TYPE, Type.getConstant("Martial"));
    Globals.getContext().getReferenceContext().importObject(Longbow);
    WeaponProf Dagger = new WeaponProf();
    Dagger.setName("Dagger");
    Dagger.addToListFor(ListKey.TYPE, Type.SIMPLE);
    Globals.getContext().getReferenceContext().importObject(Dagger);
}
Also used : WeaponProf(pcgen.core.WeaponProf)

Example 27 with WeaponProf

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

the class WeaponbonusToken method parseTokenWithSeparator.

@Override
protected ParseResult parseTokenWithSeparator(LoadContext context, PCTemplate template, 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(template, 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(template, 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 28 with WeaponProf

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

the class WeaponProfFacetTest method getObject.

@Override
protected WeaponProf getObject() {
    WeaponProf wp = new WeaponProf();
    wp.setName("WP" + n++);
    return wp;
}
Also used : WeaponProf(pcgen.core.WeaponProf)

Example 29 with WeaponProf

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

the class DeityWeaponToken method getCollection.

@Override
public <R> Collection<R> getCollection(PlayerCharacter pc, Converter<WeaponProf, R> c) {
    Deity deity = pc.getDisplay().getDeity();
    if (deity == null) {
        return Collections.emptySet();
    }
    HashSet<R> set = new HashSet<>();
    List<CDOMReference<WeaponProf>> dwp = deity.getSafeListFor(ListKey.DEITYWEAPON);
    for (CDOMReference<WeaponProf> ref : dwp) {
        set.addAll(c.convert(ref));
    }
    return set;
}
Also used : Deity(pcgen.core.Deity) WeaponProf(pcgen.core.WeaponProf) CDOMReference(pcgen.cdom.base.CDOMReference) HashSet(java.util.HashSet)

Example 30 with WeaponProf

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

the class TypeToken method getCollection.

@Override
public <R> Collection<R> getCollection(PlayerCharacter pc, Converter<WeaponProf, R> c) {
    List<WeaponProf> profs = pc.getWeaponProfsInTarget(typeRef);
    List<R> returnList = new ArrayList<>(profs.size() + 10);
    for (WeaponProf wp : profs) {
        returnList.addAll(c.convert(CDOMDirectSingleRef.getRef(wp)));
    }
    return returnList;
}
Also used : ArrayList(java.util.ArrayList) WeaponProf(pcgen.core.WeaponProf)

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