Search in sources :

Example 76 with PCTemplate

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")));
}
Also used : PCTemplate(pcgen.core.PCTemplate) Test(org.junit.Test)

Example 77 with PCTemplate

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));
}
Also used : PCTemplate(pcgen.core.PCTemplate) Test(org.junit.Test)

Example 78 with PCTemplate

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);
}
Also used : Race(pcgen.core.Race) PCTemplate(pcgen.core.PCTemplate) Test(org.junit.Test)

Example 79 with PCTemplate

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));
}
Also used : Race(pcgen.core.Race) PCTemplate(pcgen.core.PCTemplate) Test(org.junit.Test)

Example 80 with PCTemplate

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));
}
Also used : Race(pcgen.core.Race) 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