Search in sources :

Example 66 with Equipment

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;
}
Also used : StringTokenizer(java.util.StringTokenizer) ParseResult(pcgen.rules.persistence.token.ParseResult) Equipment(pcgen.core.Equipment) Ungranted(pcgen.cdom.base.Ungranted)

Example 67 with Equipment

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);
}
Also used : CalculationModifier(pcgen.base.calculation.CalculationModifier) ProcessCalculation(pcgen.cdom.content.ProcessCalculation) FunctionLibrary(pcgen.base.formula.base.FunctionLibrary) SimpleFunctionLibrary(pcgen.base.formula.inst.SimpleFunctionLibrary) NEPCalculation(pcgen.base.calculation.NEPCalculation) DropIntoContext(plugin.function.DropIntoContext) SimpleFormulaManager(pcgen.base.formula.inst.SimpleFormulaManager) ModifierFactory(pcgen.rules.persistence.token.ModifierFactory) EquipmentScope(pcgen.cdom.formula.scope.EquipmentScope) TrackingVariableCache(pcgen.base.solver.testsupport.TrackingVariableCache) OperatorLibrary(pcgen.base.formula.base.OperatorLibrary) SimpleOperatorLibrary(pcgen.base.formula.inst.SimpleOperatorLibrary) LegalScopeLibrary(pcgen.base.formula.base.LegalScopeLibrary) CalculationModifier(pcgen.base.calculation.CalculationModifier) PCGenModifier(pcgen.base.calculation.PCGenModifier) SimpleOperatorLibrary(pcgen.base.formula.inst.SimpleOperatorLibrary) SimpleFunctionLibrary(pcgen.base.formula.inst.SimpleFunctionLibrary) VariableLibrary(pcgen.base.formula.base.VariableLibrary) ManagerFactory(pcgen.base.formula.base.ManagerFactory) Equipment(pcgen.core.Equipment) ScopeInstanceFactory(pcgen.base.formula.inst.ScopeInstanceFactory) PCGenModifier(pcgen.base.calculation.PCGenModifier) Before(org.junit.Before)

Example 68 with Equipment

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;
}
Also used : Equipment(pcgen.core.Equipment)

Example 69 with Equipment

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;
}
Also used : Equipment(pcgen.core.Equipment)

Example 70 with Equipment

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);
}
Also used : ArmorProfProvider(pcgen.cdom.helper.ArmorProfProvider) Equipment(pcgen.core.Equipment) ArrayList(java.util.ArrayList) CDOMReference(pcgen.cdom.base.CDOMReference)

Aggregations

Equipment (pcgen.core.Equipment)166 PlayerCharacter (pcgen.core.PlayerCharacter)41 ArrayList (java.util.ArrayList)28 StringTokenizer (java.util.StringTokenizer)25 EquipSet (pcgen.core.character.EquipSet)22 CDOMObject (pcgen.cdom.base.CDOMObject)20 LoadContext (pcgen.rules.context.LoadContext)15 SizeAdjustment (pcgen.core.SizeAdjustment)11 EquipmentHead (pcgen.cdom.inst.EquipmentHead)10 WeaponProf (pcgen.core.WeaponProf)10 CharID (pcgen.cdom.enumeration.CharID)9 WieldCategory (pcgen.core.character.WieldCategory)9 CDOMReference (pcgen.cdom.base.CDOMReference)8 ArmorProf (pcgen.core.ArmorProf)8 EquipmentModifier (pcgen.core.EquipmentModifier)8 Race (pcgen.core.Race)8 ShieldProf (pcgen.core.ShieldProf)8 BonusObj (pcgen.core.bonus.BonusObj)8 Test (org.junit.Test)7 ScopeInstance (pcgen.base.formula.base.ScopeInstance)7