Search in sources :

Example 56 with PCTemplate

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

the class RegionFacetTest method testRegionSubRegionSet.

@Test
public void testRegionSubRegionSet() {
    PCTemplate pct = new PCTemplate();
    pct.put(ObjectKey.REGION, Region.getConstant(TEST_REGION_NAME));
    pct.put(ObjectKey.SUBREGION, SubRegion.getConstant(TEST_SUB_REGION_NAME));
    tfacet.add(id, pct, this);
    assertEquals(TEST_REGION_NAME, facet.getRegion(id));
    assertEquals(Constants.NONE, facet.getCharacterRegion(id));
    assertEquals(TEST_SUB_REGION_NAME, facet.getSubRegion(id));
    assertEquals(Constants.NONE, facet.getCharacterSubRegion(id));
    assertEquals(TEST_FULL_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 57 with PCTemplate

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

the class PreVisionTest method testVisionNotPresentZero.

/**
	 * @throws Exception
	 */
public void testVisionNotPresentZero() throws Exception {
    final PlayerCharacter character = getCharacter();
    final PCTemplate template = new PCTemplate();
    final Prerequisite prereq = new Prerequisite();
    prereq.setKind("vision");
    prereq.setKey("darkvision");
    prereq.setOperator(PrerequisiteOperator.LT);
    prereq.setOperand("ANY");
    boolean passes = PrereqHandler.passes(prereq, character, null);
    assertTrue(passes);
    template.putToList(Vision.VISIONLIST, CDOMDirectSingleRef.getRef(new Vision(VisionType.getVisionType("Darkvision"), FormulaFactory.ZERO)), new SimpleAssociatedObject());
    character.addTemplate(template);
    passes = PrereqHandler.passes(prereq, character, null);
    assertFalse(passes);
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) Vision(pcgen.core.Vision) PCTemplate(pcgen.core.PCTemplate) SimpleAssociatedObject(pcgen.cdom.base.SimpleAssociatedObject)

Example 58 with PCTemplate

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

the class PreVisionTest method testVisionNotZeroZero.

/**
	 * @throws Exception
	 */
public void testVisionNotZeroZero() throws Exception {
    final PlayerCharacter character = getCharacter();
    final PCTemplate template = new PCTemplate();
    final Prerequisite prereq = new Prerequisite();
    prereq.setKind("vision");
    prereq.setKey("darkvision");
    prereq.setOperator(PrerequisiteOperator.LT);
    prereq.setOperand("0");
    boolean passes = PrereqHandler.passes(prereq, character, null);
    assertFalse(passes);
    template.putToList(Vision.VISIONLIST, CDOMDirectSingleRef.getRef(new Vision(VisionType.getVisionType("Darkvision"), FormulaFactory.ZERO)), new SimpleAssociatedObject());
    character.addTemplate(template);
    passes = PrereqHandler.passes(prereq, character, null);
    assertFalse(passes);
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) Vision(pcgen.core.Vision) PCTemplate(pcgen.core.PCTemplate) SimpleAssociatedObject(pcgen.cdom.base.SimpleAssociatedObject)

Example 59 with PCTemplate

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

the class PreVisionTest method testVisionZeroTen.

/**
	 * @throws Exception
	 */
public void testVisionZeroTen() throws Exception {
    final PlayerCharacter character = getCharacter();
    final PCTemplate template = new PCTemplate();
    final Prerequisite prereq = new Prerequisite();
    prereq.setKind("vision");
    prereq.setKey("darkvision");
    prereq.setOperator(PrerequisiteOperator.GTEQ);
    prereq.setOperand("0");
    boolean passes = PrereqHandler.passes(prereq, character, null);
    assertTrue(passes);
    template.putToList(Vision.VISIONLIST, CDOMDirectSingleRef.getRef(new Vision(VisionType.getVisionType("Darkvision"), FormulaFactory.getFormulaFor(10))), new SimpleAssociatedObject());
    character.addTemplate(template);
    passes = PrereqHandler.passes(prereq, character, null);
    assertTrue(passes);
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) Vision(pcgen.core.Vision) PCTemplate(pcgen.core.PCTemplate) SimpleAssociatedObject(pcgen.cdom.base.SimpleAssociatedObject)

Example 60 with PCTemplate

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

the class PreVisionTest method testVisionPass.

/**
	 * @throws Exception
	 */
public void testVisionPass() throws Exception {
    final PlayerCharacter character = getCharacter();
    final PCTemplate template = new PCTemplate();
    template.putToList(Vision.VISIONLIST, CDOMDirectSingleRef.getRef(new Vision(VisionType.getVisionType("Darkvision"), FormulaFactory.getFormulaFor(60))), new SimpleAssociatedObject());
    character.addTemplate(template);
    final Prerequisite prereq = new Prerequisite();
    prereq.setKind("vision");
    prereq.setKey("darkvision");
    prereq.setOperator(PrerequisiteOperator.GTEQ);
    prereq.setOperand("30");
    final boolean passes = PrereqHandler.passes(prereq, character, null);
    assertTrue(passes);
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) Vision(pcgen.core.Vision) PCTemplate(pcgen.core.PCTemplate) SimpleAssociatedObject(pcgen.cdom.base.SimpleAssociatedObject)

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