Search in sources :

Example 81 with PCTemplate

use of pcgen.core.PCTemplate in project pcgen by PCGen.

the class RegionFacetTest method testExplicitOverrideTemplates.

@Test
public void testExplicitOverrideTemplates() {
    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);
    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);
    assertEquals("TestRegionToo", facet.getRegion(id));
    assertEquals(Constants.NONE, facet.getCharacterRegion(id));
    assertEquals("TestSubRegionToo", facet.getSubRegion(id));
    assertEquals(Constants.NONE, facet.getCharacterSubRegion(id));
    assertEquals("TestRegionToo (TestSubRegionToo)", facet.getFullRegion(id));
    facet.setRegion(id, Region.getConstant(TEST_REGION_NAME));
    facet.setSubRegion(id, SubRegion.getConstant(TEST_SUB_REGION_NAME));
    assertEquals(TEST_REGION_NAME, facet.getRegion(id));
    assertEquals(TEST_REGION_NAME, facet.getCharacterRegion(id));
    assertEquals(TEST_SUB_REGION_NAME, facet.getSubRegion(id));
    assertEquals(TEST_SUB_REGION_NAME, facet.getCharacterSubRegion(id));
    assertEquals(TEST_FULL_REGION_NAME, facet.getFullRegion(id));
    tfacet.remove(id, pct2, this);
    assertEquals(TEST_REGION_NAME, facet.getRegion(id));
    assertEquals(TEST_REGION_NAME, facet.getCharacterRegion(id));
    assertEquals(TEST_SUB_REGION_NAME, facet.getSubRegion(id));
    assertEquals(TEST_SUB_REGION_NAME, facet.getCharacterSubRegion(id));
    assertEquals(TEST_FULL_REGION_NAME, facet.getFullRegion(id));
}
Also used : PCTemplate(pcgen.core.PCTemplate) Test(org.junit.Test)

Example 82 with PCTemplate

use of pcgen.core.PCTemplate in project pcgen by PCGen.

the class RegionFacetTest method testRegionSetUseNameFalseRegionDominates.

@Test
public void testRegionSetUseNameFalseRegionDominates() {
    PCTemplate pct = new PCTemplate();
    pct.put(ObjectKey.REGION, Region.getConstant(TEST_REGION_NAME));
    pct.setName("TestTemplate");
    pct.put(ObjectKey.USETEMPLATENAMEFORREGION, false);
    tfacet.add(id, pct, this);
    assertEquals(TEST_REGION_NAME, facet.getRegion(id));
    assertEquals(Constants.NONE, facet.getCharacterRegion(id));
    assertEquals(Constants.NONE, facet.getSubRegion(id));
    assertEquals(Constants.NONE, facet.getCharacterSubRegion(id));
    assertEquals(TEST_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));
}
Also used : PCTemplate(pcgen.core.PCTemplate) Test(org.junit.Test)

Example 83 with PCTemplate

use of pcgen.core.PCTemplate in project pcgen by PCGen.

the class RegionFacetTest method testMultipleSubRegionSetSecondDominatesUseTemplateName.

@Test
public void testMultipleSubRegionSetSecondDominatesUseTemplateName() {
    PCTemplate pct = new PCTemplate();
    pct.put(ObjectKey.SUBREGION, SubRegion.getConstant(TEST_SUB_REGION_NAME));
    tfacet.add(id, pct, this);
    PCTemplate pct2 = new PCTemplate();
    pct2.setName("TestTemplateToo");
    pct2.put(ObjectKey.USETEMPLATENAMEFORSUBREGION, true);
    tfacet.add(id, pct2, this);
    assertEquals(Constants.NONE, facet.getRegion(id));
    assertEquals(Constants.NONE, facet.getCharacterRegion(id));
    assertEquals("TestTemplateToo", facet.getSubRegion(id));
    assertEquals(Constants.NONE, facet.getCharacterSubRegion(id));
    assertEquals(Constants.NONE + " (TestTemplateToo)", facet.getFullRegion(id));
    tfacet.remove(id, pct2, 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));
}
Also used : PCTemplate(pcgen.core.PCTemplate) Test(org.junit.Test)

Example 84 with PCTemplate

use of pcgen.core.PCTemplate in project pcgen by PCGen.

the class RegionFacetTest method testUseTemplateNameRegionSubRegionTrue.

@Test
public void testUseTemplateNameRegionSubRegionTrue() {
    PCTemplate pct = new PCTemplate();
    pct.setName("TestTemplate");
    pct.put(ObjectKey.USETEMPLATENAMEFORREGION, true);
    pct.put(ObjectKey.USETEMPLATENAMEFORSUBREGION, true);
    tfacet.add(id, pct, this);
    assertEquals("TestTemplate", facet.getRegion(id));
    assertEquals(Constants.NONE, facet.getCharacterRegion(id));
    assertEquals("TestTemplate", facet.getSubRegion(id));
    assertEquals(Constants.NONE, facet.getCharacterSubRegion(id));
    assertEquals("TestTemplate (TestTemplate)", 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));
}
Also used : PCTemplate(pcgen.core.PCTemplate) Test(org.junit.Test)

Example 85 with PCTemplate

use of pcgen.core.PCTemplate in project pcgen by PCGen.

the class GenderFacetTest method testGenderLocked.

@Test
public void testGenderLocked() {
    assertTrue(facet.canSetGender(id));
    PCTemplate pct = new PCTemplate();
    pct.put(ObjectKey.GENDER_LOCK, Gender.Female);
    tfacet.add(id, pct, this);
    assertFalse(facet.canSetGender(id));
    assertEquals(Gender.Female, facet.getGender(id));
    tfacet.remove(id, pct, this);
    assertTrue(facet.canSetGender(id));
    assertEquals(Gender.getDefaultValue(), facet.getGender(id));
}
Also used : PCTemplate(pcgen.core.PCTemplate) Test(org.junit.Test)

Aggregations

PCTemplate (pcgen.core.PCTemplate)215 Test (org.junit.Test)105 Race (pcgen.core.Race)66 PlayerCharacter (pcgen.core.PlayerCharacter)38 CDOMObject (pcgen.cdom.base.CDOMObject)31 ArrayList (java.util.ArrayList)19 CharID (pcgen.cdom.enumeration.CharID)18 ParseResult (pcgen.rules.persistence.token.ParseResult)14 SimpleAssociatedObject (pcgen.cdom.base.SimpleAssociatedObject)13 Vision (pcgen.core.Vision)12 LoadContext (pcgen.rules.context.LoadContext)12 PCClass (pcgen.core.PCClass)11 StringTokenizer (java.util.StringTokenizer)10 VariableKey (pcgen.cdom.enumeration.VariableKey)8 DataFacetChangeEvent (pcgen.cdom.facet.event.DataFacetChangeEvent)8 Ability (pcgen.core.Ability)8 Formula (pcgen.base.formula.Formula)6 Equipment (pcgen.core.Equipment)6 PCStat (pcgen.core.PCStat)6 AbstractTokenModelTest (tokenmodel.testsupport.AbstractTokenModelTest)6