use of pcgen.core.Race 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.Race in project pcgen by PCGen.
the class RaceTypeFacetTest method testGetFromRace.
@Test
public void testGetFromRace() {
Race r = new Race();
r.put(ObjectKey.RACETYPE, TEST_RACE_TYPE);
rfacet.set(id, r);
assertSame(TEST_RACE_TYPE, facet.getRaceType(id));
rfacet.remove(id);
assertNull(facet.getRaceType(id));
}
use of pcgen.core.Race in project pcgen by PCGen.
the class RacialSubTypesFacetTest method testGetFromTemplateOverridesRaceandCMod.
@Test
public void testGetFromTemplateOverridesRaceandCMod() {
Race r = new Race();
r.addToListFor(ListKey.RACESUBTYPE, TEST_RACE_TYPE);
rfacet.set(id, r);
assertList(facet.getRacialSubTypes(id), TEST_RACE_TYPE);
PCTemplate t = new PCTemplate();
t.setName("PCT");
t.addToListFor(ListKey.RACESUBTYPE, RACE_TYPE_TOO);
tfacet.add(id, t, this);
assertList(facet.getRacialSubTypes(id), TEST_RACE_TYPE, RACE_TYPE_TOO);
PCTemplate t2 = new PCTemplate();
t2.setName("Other");
t2.addToListFor(ListKey.RACESUBTYPE, LAST_RACE_TYPE);
tfacet.add(id, t2, this);
assertList(facet.getRacialSubTypes(id), TEST_RACE_TYPE, RACE_TYPE_TOO, LAST_RACE_TYPE);
tfacet.remove(id, t2, this);
assertList(facet.getRacialSubTypes(id), TEST_RACE_TYPE, RACE_TYPE_TOO);
tfacet.remove(id, t, this);
assertList(facet.getRacialSubTypes(id), TEST_RACE_TYPE);
}
use of pcgen.core.Race in project pcgen by PCGen.
the class LegsFacetTest method testWithNothingInRaceDefault2.
@Test
public void testWithNothingInRaceDefault2() {
rfacet.set(id, new Race());
assertEquals(2, facet.getLegs(id));
}
use of pcgen.core.Race in project pcgen by PCGen.
the class LegsFacetTest method testGetFromTemplate.
@Test
public void testGetFromTemplate() {
rfacet.set(id, new Race());
PCTemplate t = new PCTemplate();
t.put(IntegerKey.LEGS, 5);
tfacet.add(id, t, this);
assertEquals(5, facet.getLegs(id));
tfacet.remove(id, t, this);
assertEquals(2, facet.getLegs(id));
}
Aggregations