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