use of pcgen.core.Equipment in project pcgen by PCGen.
the class ActiveEqModFacet method dataAdded.
/**
* Adds the EqMods associated with a piece of Equipment which is equipped by
* a Player Character.
*
* Triggered when one of the Facets to which ActiveEqModFacet listens fires
* a DataFacetChangeEvent to indicate a piece of Equipment was equipped by a
* Player Character.
*
* @param dfce
* The DataFacetChangeEvent containing the information about the
* change
*
* @see pcgen.cdom.facet.event.DataFacetChangeListener#dataAdded(pcgen.cdom.facet.event.DataFacetChangeEvent)
*/
@Override
public void dataAdded(DataFacetChangeEvent<CharID, Equipment> dfce) {
/*
* In theory, this doesn't need to check for additions/removals from the
* EqMod list, because such changes can't happen to equipment that is
* currently equipped by the PC (new equipment is a clone, not the
* original item)
*/
CharID id = dfce.getCharID();
Equipment eq = dfce.getCDOMObject();
for (EquipmentModifier eqMod : eq.getEqModifierList(true)) {
add(id, eqMod, eq);
}
for (EquipmentModifier eqMod : eq.getEqModifierList(false)) {
add(id, eqMod, eq);
}
}
use of pcgen.core.Equipment in project pcgen by PCGen.
the class PreShieldProfTest method setUp.
/**
* @see pcgen.AbstractCharacterTestCase#setUp()
*/
@Override
protected void setUp() throws Exception {
super.setUp();
Equipment heavySteelShield = new Equipment();
heavySteelShield.setName("Heavy Steel Shield");
heavySteelShield.addToListFor(ListKey.TYPE, Type.getConstant("Shield"));
heavySteelShield.addToListFor(ListKey.TYPE, Type.getConstant("Heavy"));
Globals.getContext().getReferenceContext().importObject(heavySteelShield);
Equipment heavyWoodenShield = new Equipment();
heavyWoodenShield.setName("Heavy Wooden Shield");
heavyWoodenShield.addToListFor(ListKey.TYPE, Type.getConstant("Shield"));
heavyWoodenShield.addToListFor(ListKey.TYPE, Type.getConstant("Heavy"));
Globals.getContext().getReferenceContext().importObject(heavyWoodenShield);
Equipment lightWoodenShield = new Equipment();
lightWoodenShield.setName("Light Steel Shield");
lightWoodenShield.addToListFor(ListKey.TYPE, Type.getConstant("Shield"));
lightWoodenShield.addToListFor(ListKey.TYPE, Type.getConstant("Light"));
Globals.getContext().getReferenceContext().importObject(lightWoodenShield);
Equipment fullPlateEq = new Equipment();
fullPlateEq.setName("Full Plate");
fullPlateEq.addToListFor(ListKey.TYPE, Type.getConstant("Shield"));
fullPlateEq.addToListFor(ListKey.TYPE, Type.getConstant("Heavy"));
Globals.getContext().getReferenceContext().importObject(fullPlateEq);
ShieldProf fullPlate = new ShieldProf();
fullPlate.setName("Full Plate");
fullPlate.addToListFor(ListKey.TYPE, Type.getConstant("Heavy"));
Globals.getContext().getReferenceContext().importObject(fullPlate);
ShieldProf lightWood = new ShieldProf();
lightWood.setName("Light Wooden Shield");
lightWood.addToListFor(ListKey.TYPE, Type.getConstant("Light"));
Globals.getContext().getReferenceContext().importObject(lightWood);
ShieldProf heavyWood = new ShieldProf();
heavyWood.setName("Heavy Wooden Shield");
heavyWood.addToListFor(ListKey.TYPE, Type.getConstant("Heavy"));
Globals.getContext().getReferenceContext().importObject(heavyWood);
ShieldProf heavySteel = new ShieldProf();
heavySteel.setName("Heavy Steel Shield");
heavySteel.addToListFor(ListKey.TYPE, Type.getConstant("Heavy"));
Globals.getContext().getReferenceContext().importObject(heavySteel);
}
use of pcgen.core.Equipment in project pcgen by PCGen.
the class PreEquipSecondaryTest method testNotEquipped.
/**
* Verify that negated PREEQUIPSECONDARY tests work.
*/
public void testNotEquipped() throws Exception {
final PlayerCharacter character = getCharacter();
final Equipment longsword = new Equipment();
longsword.setName("Longsword");
final Equipment dagger = new Equipment();
dagger.setName("Dagger");
character.addEquipment(longsword);
longsword.setIsEquipped(true, character);
longsword.setLocation(EquipmentLocation.EQUIPPED_SECONDARY);
character.doAfavorForAunitTestThatIgnoresEquippingRules();
final Prerequisite prereqDaggerNotSec = PreParserFactory.getInstance().parse("!PREEQUIPSECONDARY:1,Dagger");
assertTrue("Dagger not equipped", PrereqHandler.passes(prereqDaggerNotSec, character, null));
character.addEquipment(dagger);
dagger.setIsEquipped(true, character);
dagger.setLocation(EquipmentLocation.EQUIPPED_PRIMARY);
assertTrue("Dagger not equipped", PrereqHandler.passes(prereqDaggerNotSec, character, null));
final Prerequisite prereqLongswordNotSec = PreParserFactory.getInstance().parse("!PREEQUIPSECONDARY:1,Longsword");
assertFalse("Longsword equipped", PrereqHandler.passes(prereqLongswordNotSec, character, null));
}
use of pcgen.core.Equipment in project pcgen by PCGen.
the class PreEquipTest method testPassesPrerequisitePlayerCharacter.
/*
* Class under test for int passes(Prerequisite, PlayerCharacter)
*/
public void testPassesPrerequisitePlayerCharacter() {
final PlayerCharacter character = getCharacter();
final Equipment longsword = new Equipment();
longsword.setName("Longsword");
character.addEquipment(longsword);
longsword.setIsEquipped(true, character);
character.doAfavorForAunitTestThatIgnoresEquippingRules();
final Prerequisite prereq = new Prerequisite();
prereq.setKind("equip");
prereq.setKey("LONGSWORD");
prereq.setOperand("1");
prereq.setOperator(PrerequisiteOperator.EQ);
final boolean passes = PrereqHandler.passes(prereq, character, null);
assertTrue(passes);
longsword.setName("Longsword (Masterwork)");
assertFalse("Should be an exact match only", PrereqHandler.passes(prereq, character, null));
prereq.setKey("LONGSWORD%");
assertTrue("Should be allow wildcard match", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.core.Equipment in project pcgen by PCGen.
the class PreEquipTwoWeaponTest method testPassesPrerequisitePlayerCharacter.
/*
* Class under test for int passes(Prerequisite, PlayerCharacter)
*/
public void testPassesPrerequisitePlayerCharacter() {
final PlayerCharacter character = getCharacter();
final Equipment longsword = new Equipment();
longsword.setName("Longsword");
character.addEquipment(longsword);
longsword.setIsEquipped(true, character);
longsword.setLocation(EquipmentLocation.EQUIPPED_TWO_HANDS);
character.doAfavorForAunitTestThatIgnoresEquippingRules();
final Prerequisite prereq = new Prerequisite();
prereq.setKind("equiptwoweapon");
prereq.setKey("LONGSWORD");
prereq.setOperand("1");
prereq.setOperator(PrerequisiteOperator.EQ);
final boolean passes = PrereqHandler.passes(prereq, character, null);
assertTrue(passes);
longsword.setName("Longsword (Large/Masterwork)");
assertFalse("Should be an exact match only", PrereqHandler.passes(prereq, character, null));
prereq.setKey("LONGSWORD (LARGE%");
assertTrue("Should allow wildcard match", PrereqHandler.passes(prereq, character, null));
}
Aggregations