Search in sources :

Example 91 with Equipment

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

the class WeaponoToken method getToken.

/**
	 * Get the value of the supplied output token.
	 *
	 * @param tokenSource The full source of the token
	 * @param pc The character to retrieve the value for.
	 * @param eh The ExportHandler that is managing the export
	 * 						(may be null for a once off conversion).
	 * @return The value of the token.
	 * @see pcgen.io.exporttoken.Token#getToken(java.lang.String, pcgen.core.PlayerCharacter, pcgen.io.ExportHandler)
	 */
@Override
public String getToken(String tokenSource, PlayerCharacter pc, ExportHandler eh) {
    StringTokenizer aTok = new StringTokenizer(tokenSource, ".", false);
    //Weapono Token
    aTok.nextToken();
    final String ind = aTok.nextToken();
    final int index = Integer.parseInt(ind);
    Equipment eq = getWeaponEquipment(pc.getDisplay(), index);
    if (eq != null) {
        return getWeaponToken(pc, eq, aTok, tokenSource);
    } else if (eh != null && eh.getExistsOnly()) {
        eh.setNoMoreItems(true);
        if (eh.getCheckBefore()) {
            eh.setCanWrite(false);
        }
    }
    return "";
}
Also used : StringTokenizer(java.util.StringTokenizer) Equipment(pcgen.core.Equipment)

Example 92 with Equipment

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

the class WeaponpToken method getToken.

/**
	 * Get the value of the token.
	 *
	 * @param tokenSource The full source of the token
	 * @param pc The character to retrieve the value for.
	 * @param eh The ExportHandler that is managing the export.
	 * @return The value of the token.
	 * @see pcgen.io.exporttoken.Token#getToken(java.lang.String, pcgen.core.PlayerCharacter, pcgen.io.ExportHandler)
	 */
@Override
public String getToken(String tokenSource, PlayerCharacter pc, ExportHandler eh) {
    StringTokenizer aTok = new StringTokenizer(tokenSource, ".", false);
    //Weaponp Token
    aTok.nextToken();
    if (pc.getDisplay().hasPrimaryWeapons()) {
        Equipment eq = pc.getDisplay().getPrimaryWeapons().iterator().next();
        return getWeaponToken(pc, eq, aTok, tokenSource);
    } else if (eh != null && eh.getExistsOnly()) {
        eh.setNoMoreItems(true);
        if (eh.getCheckBefore()) {
            eh.setCanWrite(false);
        }
    }
    return "";
}
Also used : StringTokenizer(java.util.StringTokenizer) Equipment(pcgen.core.Equipment)

Example 93 with Equipment

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

the class SetSolverManagerTest method testProcessDynamicSet.

@Test
public void testProcessDynamicSet() {
    LegalScope equipScope = vsLib.getScope("EQUIPMENT");
    sl.assertLegalVariableID("LocalVar", equipScope, numberManager);
    sl.assertLegalVariableID("ResultVar", globalScope, numberManager);
    sl.assertLegalVariableID("EquipVar", globalScope, equipmentManager);
    Equipment equip = new Equipment();
    equip.setName("EquipKey");
    Equipment equipalt = new Equipment();
    equipalt.setName("EquipAlt");
    ScopeInstance scopeInste = siFactory.get("EQUIPMENT", equip);
    VariableID varIDe = sl.getVariableID(scopeInste, "LocalVar");
    manager.createChannel(varIDe);
    vc.put(varIDe, 2);
    ScopeInstance scopeInsta = siFactory.get("EQUIPMENT", equipalt);
    VariableID varIDa = sl.getVariableID(scopeInsta, "LocalVar");
    manager.createChannel(varIDa);
    vc.put(varIDa, 3);
    ScopeInstance globalInst = siFactory.getGlobalInstance("Global");
    VariableID varIDq = sl.getVariableID(globalInst, "EquipVar");
    manager.createChannel(varIDq);
    VariableID varIDr = sl.getVariableID(globalInst, "ResultVar");
    manager.createChannel(varIDr);
    ModifierFactory am1 = new plugin.modifier.number.SetModifierFactory();
    ModifierFactory amString = new plugin.modifier.string.SetModifierFactory();
    PCGenModifier mod2 = am1.getModifier(2000, "2", new ManagerFactory() {
    }, fm, globalScope, numberManager);
    PCGenModifier mod3 = am1.getModifier(2000, "3", new ManagerFactory() {
    }, fm, globalScope, numberManager);
    PCGenModifier mod4 = am1.getModifier(3000, "4", new ManagerFactory() {
    }, fm, globalScope, numberManager);
    String formula = "dropIntoContext(\"EQUIPMENT\",EquipVar,LocalVar)";
    PCGenModifier modf = am1.getModifier(2000, formula, new ManagerFactory() {
    }, fm, globalScope, numberManager);
    NEPCalculation calc1 = new ProcessCalculation<>(equip, new BasicSet(), equipmentManager);
    CalculationModifier mod_e1 = new CalculationModifier<>(calc1, 2000);
    NEPCalculation calc2 = new ProcessCalculation<>(equipalt, new BasicSet(), equipmentManager);
    CalculationModifier mod_e2 = new CalculationModifier<>(calc2, 3000);
    manager.addModifier(varIDe, mod2, scopeInste);
    manager.addModifier(varIDa, mod3, scopeInsta);
    assertEquals(2, vc.get(varIDe));
    assertEquals(3, vc.get(varIDa));
    assertEquals(0, vc.get(varIDr));
    manager.addModifier(varIDq, mod_e1, globalInst);
    manager.addModifier(varIDr, modf, globalInst);
    assertEquals(2, vc.get(varIDr));
    manager.addModifier(varIDq, mod_e2, globalInst);
    assertEquals(3, vc.get(varIDr));
    manager.addModifier(varIDa, mod4, scopeInsta);
    assertEquals(4, vc.get(varIDr));
}
Also used : ScopeInstance(pcgen.base.formula.base.ScopeInstance) CalculationModifier(pcgen.base.calculation.CalculationModifier) ProcessCalculation(pcgen.cdom.content.ProcessCalculation) NEPCalculation(pcgen.base.calculation.NEPCalculation) ModifierFactory(pcgen.rules.persistence.token.ModifierFactory) ManagerFactory(pcgen.base.formula.base.ManagerFactory) Equipment(pcgen.core.Equipment) SimpleLegalScope(pcgen.base.formula.inst.SimpleLegalScope) LegalScope(pcgen.base.formula.base.LegalScope) VariableID(pcgen.base.formula.base.VariableID) PCGenModifier(pcgen.base.calculation.PCGenModifier) Test(org.junit.Test)

Example 94 with Equipment

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

the class EquipmentFacetTest method getObject.

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

Example 95 with Equipment

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

the class NaturalWeaponFacetTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    CDOMObject cdo1 = new PCTemplate();
    cdo1.setName("Template1");
    CDOMObject cdo2 = new Race();
    cdo2.setName("Race1");
    Equipment st1 = new Equipment();
    st1.setName("Prof1");
    Equipment st2 = new Equipment();
    st1.setName("Prof2");
    cdo1.addToListFor(ListKey.NATURAL_WEAPON, st1);
    cdo2.addToListFor(ListKey.NATURAL_WEAPON, st2);
    source = new CDOMObject[] { cdo1, cdo2 };
    target = new Equipment[] { st1, st2 };
}
Also used : Equipment(pcgen.core.Equipment) CDOMObject(pcgen.cdom.base.CDOMObject) Race(pcgen.core.Race) PCTemplate(pcgen.core.PCTemplate)

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