use of pcgen.core.PCTemplate in project pcgen by PCGen.
the class RegionFacetTest method testMatchesRegion.
@Test
public void testMatchesRegion() {
assertTrue(facet.matchesRegion(id, null));
PCTemplate pct = new PCTemplate();
pct.setName("PCT");
pct.put(ObjectKey.REGION, Region.getConstant("InitRegion"));
pct.put(ObjectKey.SUBREGION, SubRegion.getConstant("InitSubRegion"));
tfacet.add(id, pct, this);
assertTrue(facet.matchesRegion(id, Region.getConstant("InitRegion")));
assertFalse(facet.matchesRegion(id, Region.getConstant("TestRegionToo")));
PCTemplate pct2 = new PCTemplate();
pct2.setName("Other");
pct2.put(ObjectKey.REGION, Region.getConstant("TestRegionToo"));
pct2.put(ObjectKey.SUBREGION, SubRegion.getConstant("TestSubRegionToo"));
tfacet.add(id, pct2, this);
assertTrue(facet.matchesRegion(id, Region.getConstant("TestRegionToo")));
assertFalse(facet.matchesRegion(id, Region.getConstant("InitRegion")));
tfacet.remove(id, pct2, this);
assertTrue(facet.matchesRegion(id, Region.getConstant("InitRegion")));
assertFalse(facet.matchesRegion(id, Region.getConstant("TestRegionToo")));
facet.setRegion(id, Region.getConstant(TEST_REGION_NAME));
assertTrue(facet.matchesRegion(id, Region.getConstant(TEST_REGION_NAME)));
assertFalse(facet.matchesRegion(id, Region.getConstant("TestRegionToo")));
}
use of pcgen.core.PCTemplate in project pcgen by PCGen.
the class RegionFacetTest method testSubRegionSet.
@Test
public void testSubRegionSet() {
PCTemplate pct = new PCTemplate();
pct.put(ObjectKey.SUBREGION, SubRegion.getConstant(TEST_SUB_REGION_NAME));
tfacet.add(id, pct, this);
assertEquals(Constants.NONE, facet.getRegion(id));
assertEquals(Constants.NONE, facet.getCharacterRegion(id));
assertEquals(TEST_SUB_REGION_NAME, facet.getSubRegion(id));
assertEquals(Constants.NONE, facet.getCharacterSubRegion(id));
assertEquals(Constants.NONE + " (" + TEST_SUB_REGION_NAME + ")", facet.getFullRegion(id));
tfacet.remove(id, pct, this);
assertEquals(Constants.NONE, facet.getRegion(id));
assertEquals(Constants.NONE, facet.getCharacterRegion(id));
assertEquals(Constants.NONE, facet.getSubRegion(id));
assertEquals(Constants.NONE, facet.getCharacterSubRegion(id));
assertEquals(Constants.NONE, facet.getFullRegion(id));
}
use of pcgen.core.PCTemplate in project pcgen by PCGen.
the class RacialSubTypesFacetTest method testGetRemoved.
@Test
public void testGetRemoved() {
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.addToListFor(ListKey.REMOVED_RACESUBTYPE, TEST_RACE_TYPE);
tfacet.add(id, t, this);
assertSubTypesEmpty();
tfacet.remove(id, t, this);
assertList(facet.getRacialSubTypes(id), TEST_RACE_TYPE);
}
use of pcgen.core.PCTemplate in project pcgen by PCGen.
the class ReachFacetTest method testGetFromTemplateSecondOverrides.
@Test
public void testGetFromTemplateSecondOverrides() {
Race r = new Race();
r.put(IntegerKey.REACH, 5);
rfacet.set(id, r);
PCTemplate t = new PCTemplate();
t.setName("PCT");
t.put(IntegerKey.REACH, 8);
tfacet.add(id, t, this);
PCTemplate t2 = new PCTemplate();
t2.setName("Other");
t2.put(IntegerKey.REACH, 7);
tfacet.add(id, t2, this);
assertEquals(7, facet.getReach(id));
tfacet.remove(id, t2, this);
assertEquals(8, facet.getReach(id));
tfacet.remove(id, t, this);
assertEquals(5, facet.getReach(id));
}
use of pcgen.core.PCTemplate in project pcgen by PCGen.
the class ReachFacetTest method testGetFromTemplateHigherOverridesDefault.
@Test
public void testGetFromTemplateHigherOverridesDefault() {
rfacet.set(id, new Race());
PCTemplate t = new PCTemplate();
t.put(IntegerKey.REACH, 7);
tfacet.add(id, t, this);
assertEquals(7, facet.getReach(id));
tfacet.remove(id, t, this);
assertEquals(5, facet.getReach(id));
}
Aggregations