use of pcgen.core.Equipment in project pcgen by PCGen.
the class PreEquipBothTest method testType.
/**
* Test equipment type tests
* @throws Exception
*/
public void testType() throws Exception {
final PlayerCharacter character = getCharacter();
final Equipment longsword = new Equipment();
longsword.setName("Longsword");
character.addEquipment(longsword);
longsword.setIsEquipped(true, character);
longsword.setLocation(EquipmentLocation.EQUIPPED_BOTH);
character.doAfavorForAunitTestThatIgnoresEquippingRules();
Prerequisite prereq = new Prerequisite();
prereq.setKind("equipboth");
prereq.setKey("TYPE=Weapon");
prereq.setOperand("1");
prereq.setOperator(PrerequisiteOperator.EQ);
assertFalse("Equipment has no type", PrereqHandler.passes(prereq, character, null));
longsword.addType(Type.WEAPON);
assertTrue("Equipment is weapon", PrereqHandler.passes(prereq, character, null));
prereq.setKey("TYPE.Armor");
assertFalse("Equipment is not armor", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.core.Equipment in project pcgen by PCGen.
the class PreEquipBothTest method testWield.
/**
* Test wield category tests
* @throws Exception
*/
public void testWield() throws Exception {
final PlayerCharacter character = getCharacter();
final Race race = new Race();
race.setName("Test Race");
CDOMDirectSingleRef<SizeAdjustment> mediumRef = CDOMDirectSingleRef.getRef(medium);
CDOMDirectSingleRef<SizeAdjustment> largeRef = CDOMDirectSingleRef.getRef(large);
race.put(FormulaKey.SIZE, new FixedSizeFormula(mediumRef));
character.setRace(race);
LoadContext context = Globals.getContext();
final Equipment longsword = new Equipment();
longsword.setName("Longsword");
character.addEquipment(longsword);
longsword.setIsEquipped(true, character);
longsword.setLocation(EquipmentLocation.EQUIPPED_BOTH);
character.doAfavorForAunitTestThatIgnoresEquippingRules();
Prerequisite prereq = new Prerequisite();
prereq.setKind("equipboth");
prereq.setKey("WIELDCATEGORY=OneHanded");
prereq.setOperand("1");
prereq.setOperator(PrerequisiteOperator.EQ);
// Test 3.0 Style
longsword.put(ObjectKey.SIZE, mediumRef);
longsword.put(ObjectKey.BASESIZE, mediumRef);
assertTrue("Weapon is M therefore OneHanded", PrereqHandler.passes(prereq, character, null));
longsword.put(ObjectKey.SIZE, largeRef);
longsword.put(ObjectKey.BASESIZE, largeRef);
assertFalse("Weapon is L therefore TwoHanded", PrereqHandler.passes(prereq, character, null));
// Test 3.5 style
longsword.put(ObjectKey.SIZE, mediumRef);
longsword.put(ObjectKey.BASESIZE, mediumRef);
longsword.put(ObjectKey.WIELD, context.getReferenceContext().silentlyGetConstructedCDOMObject(WieldCategory.class, "TwoHanded"));
assertFalse("Weapon is TwoHanded", PrereqHandler.passes(prereq, character, null));
longsword.put(ObjectKey.WIELD, context.getReferenceContext().silentlyGetConstructedCDOMObject(WieldCategory.class, "OneHanded"));
assertTrue("Weapon is OneHanded", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.core.Equipment in project pcgen by PCGen.
the class PreEquipPrimaryTest method testType.
/**
* Test equipment type tests
* @throws Exception
*/
public void testType() throws Exception {
final PlayerCharacter character = getCharacter();
final Equipment longsword = new Equipment();
longsword.setName("Longsword");
character.addEquipment(longsword);
longsword.setIsEquipped(true, character);
longsword.setLocation(EquipmentLocation.EQUIPPED_PRIMARY);
character.doAfavorForAunitTestThatIgnoresEquippingRules();
Prerequisite prereq = new Prerequisite();
prereq.setKind("equipprimary");
prereq.setKey("TYPE=Slashing");
prereq.setOperand("1");
prereq.setOperator(PrerequisiteOperator.EQ);
assertFalse("Equipment has no type", PrereqHandler.passes(prereq, character, null));
longsword.addType(Type.getConstant("SLASHING"));
assertTrue("Equipment is slashing", PrereqHandler.passes(prereq, character, null));
prereq.setKey("TYPE.Armor");
assertFalse("Equipment is not armor", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.core.Equipment in project pcgen by PCGen.
the class SourcedEquipmentFacetTest 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 UserEquipmentFacetTest method getObject.
@Override
protected Equipment getObject() {
Equipment wp = new Equipment();
wp.setName("WP" + n++);
return wp;
}
Aggregations