use of pcgen.core.Equipment in project pcgen by PCGen.
the class NaturalattacksLst method parseTokenWithSeparator.
/**
* NATURAL WEAPONS CODE <p>first natural weapon is primary, the rest are
* secondary; NATURALATTACKS:primary weapon name,weapon type,num
* attacks,damage|secondary1 weapon name,weapon type,num
* attacks,damage|secondary2 format is exactly as it would be in an
* equipment lst file Type is of the format Weapon.Natural.Melee.Bludgeoning
* number of attacks is the number of attacks with that weapon at BAB (for
* primary), or BAB - 5 (for secondary)
*/
@Override
protected ParseResult parseTokenWithSeparator(LoadContext context, CDOMObject obj, String value) {
if (obj instanceof Ungranted) {
return new ParseResult.Fail("Cannot use " + getTokenName() + " on an Ungranted object type: " + obj.getClass().getSimpleName(), context);
}
// Currently, this isn't going to work with monk attacks
// - their unarmed stuff won't be affected.
/*
* This does not immediately resolve the Size, because it is an order of
* operations issue. This token must allow the SIZE token to appear
* AFTER this token in the LST file. Thus a deferred resolution (using a
* Resolver) is required.
*/
int count = 1;
StringTokenizer attackTok = new StringTokenizer(value, Constants.PIPE);
while (attackTok.hasMoreTokens()) {
String tokString = attackTok.nextToken();
ParseResult pr = checkForIllegalSeparator(',', tokString);
if (!pr.passed()) {
return pr;
}
Equipment anEquip = createNaturalWeapon(context, obj, tokString.intern());
if (anEquip == null) {
return ParseResult.INTERNAL_ERROR;
//return new ParseResult.Fail("Natural Weapon Creation Failed for : "
// + tokString, context);
}
if (count == 1) {
anEquip.setModifiedName("Natural/Primary");
} else {
anEquip.setModifiedName("Natural/Secondary");
}
anEquip.setOutputIndex(0);
anEquip.setOutputSubindex(count);
// these values need to be locked.
anEquip.setQty(new Float(1));
anEquip.setNumberCarried(new Float(1));
context.getObjectContext().addToList(obj, ListKey.NATURAL_WEAPON, anEquip);
count++;
}
return ParseResult.SUCCESS;
}
use of pcgen.core.Equipment in project pcgen by PCGen.
the class SetSolverManagerTest method setUp.
@Before
public void setUp() throws Exception {
FunctionLibrary fl = new SimpleFunctionLibrary();
fl.addFunction(new DropIntoContext());
OperatorLibrary ol = new SimpleOperatorLibrary();
vc = new TrackingVariableCache();
vsLib = new LegalScopeLibrary();
EquipmentScope equipScope = new EquipmentScope();
equipScope.setParent(globalScope);
vsLib.registerScope(equipScope);
sl = new VariableLibrary(vsLib);
arrayManager = new ArrayFormatManager<>(stringManager, ',');
ManagerFactory managerFactory = new ManagerFactory() {
};
siFactory = new ScopeInstanceFactory(vsLib);
fm = new SimpleFormulaManager(ol, sl, siFactory, vc, new SolverFactory());
fm = fm.getWith(FormulaManager.FUNCTION, fl);
SolverFactory solverFactory = new SolverFactory();
ModifierFactory am1 = new plugin.modifier.set.SetModifierFactory<>();
PCGenModifier emptyArrayMod = am1.getModifier(0, "", managerFactory, null, globalScope, arrayManager);
solverFactory.addSolverFormat(arrayManager.getManagedClass(), emptyArrayMod);
NEPCalculation calc = new ProcessCalculation<>(new Equipment(), new BasicSet(), equipmentManager);
CalculationModifier em = new CalculationModifier<>(calc, 0);
solverFactory.addSolverFormat(Equipment.class, em);
manager = new DynamicSolverManager(fm, managerFactory, solverFactory, vc);
ModifierFactory mfn = new plugin.modifier.number.SetModifierFactory();
Modifier mod = mfn.getModifier(0, "0", managerFactory, null, globalScope, numberManager);
solverFactory.addSolverFormat(numberManager.getManagedClass(), mod);
ModifierFactory mfs = new plugin.modifier.string.SetModifierFactory();
Modifier mods = mfs.getModifier(0, "", managerFactory, null, globalScope, stringManager);
solverFactory.addSolverFormat(stringManager.getManagedClass(), mods);
}
use of pcgen.core.Equipment in project pcgen by PCGen.
the class NaturalEquipmentFacetTest method getObject.
@Override
protected Equipment getObject() {
Equipment eq = new Equipment();
eq.setName("EQ" + n++);
eq.addType(Type.NATURAL);
return eq;
}
use of pcgen.core.Equipment in project pcgen by PCGen.
the class NaturalWeaponFacetTest method getObject.
@Override
protected Equipment getObject() {
Equipment wp = new Equipment();
wp.setName("WP" + n++);
return wp;
}
use of pcgen.core.Equipment in project pcgen by PCGen.
the class ArmorProfTokenTest method loadTypeProf.
@Override
protected void loadTypeProf(String... types) {
CDOMGroupRef<Equipment> ref = primaryContext.getReferenceContext().getCDOMTypeReference(Equipment.class, types);
List<CDOMReference<ArmorProf>> armorProfs = new ArrayList<>();
List<CDOMReference<Equipment>> equipTypes = new ArrayList<>();
equipTypes.add(ref);
ArmorProfProvider pp = new ArmorProfProvider(armorProfs, equipTypes);
primaryProf.addToListFor(ListKey.AUTO_ARMORPROF, pp);
}
Aggregations