use of pcgen.core.PlayerCharacter 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.PlayerCharacter 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));
}
use of pcgen.core.PlayerCharacter in project pcgen by PCGen.
the class PreEquipTwoWeaponTest 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_TWO_HANDS);
character.doAfavorForAunitTestThatIgnoresEquippingRules();
Prerequisite prereq = new Prerequisite();
prereq.setKind("equiptwoweapon");
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.PlayerCharacter in project pcgen by PCGen.
the class PreEquipTwoWeaponTest 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_TWO_HANDS);
character.doAfavorForAunitTestThatIgnoresEquippingRules();
Prerequisite prereq = new Prerequisite();
prereq.setKind("equiptwoweapon");
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.PlayerCharacter in project pcgen by PCGen.
the class PreFactSetTest method testFact.
/**
* Test the PREFACT code
* @throws Exception
*/
public void testFact() throws Exception {
final PlayerCharacter character = getCharacter();
Deity deity = new Deity();
BuildUtilities.addToFactSet(deity, "PANTHEON", "Greek");
BuildUtilities.addToFactSet(deity, "PANTHEON", "War");
deity.setName("Ares");
character.setDeity(deity);
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PREFACTSET:1,DEITY,PANTHEON=Roman");
assertFalse("Character's deity should not match requirement", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREFACTSET:1,DEITY,PANTHEON=War");
assertTrue("Character's deity should match pantheon", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREFACTSET:1,DEITY,PANTHEON=Greek");
assertTrue("Character's deity should match pantheon", PrereqHandler.passes(prereq, character, null));
}
Aggregations