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);
}
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;
}
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;
}
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;
}
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;
}
Aggregations