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