Search in sources :

Example 61 with PCTemplate

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

the class PreWeaponProfTest method testOneOption.

/**
	 * Test with a simple weapon proficiency
	 * @throws Exception
	 */
public void testOneOption() throws Exception {
    final PlayerCharacter character = getCharacter();
    PCTemplate pct = new PCTemplate();
    LoadContext context = Globals.getContext();
    context.unconditionallyProcess(pct, "AUTO", "WEAPONPROF|Longsword|Dagger");
    assertTrue(context.getReferenceContext().resolveReferences(null));
    Prerequisite prereq;
    final PreParserFactory factory = PreParserFactory.getInstance();
    prereq = factory.parse("PREWEAPONPROF:1,Longsword");
    assertFalse("Character has no proficiencies", PrereqHandler.passes(prereq, character, null));
    character.addTemplate(pct);
    assertTrue("Character has the Longsword proficiency.", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREWEAPONPROF:1,Longbow");
    assertFalse("Character does not have the Longbow proficiency", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREWEAPONPROF:1,Dagger");
    assertTrue("Character has the Dagger proficiency.", PrereqHandler.passes(prereq, character, null));
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) PreParserFactory(pcgen.persistence.lst.prereq.PreParserFactory) LoadContext(pcgen.rules.context.LoadContext) PCTemplate(pcgen.core.PCTemplate)

Example 62 with PCTemplate

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

the class PreWeaponProfTest method testWithFeatThatGrantsBonus.

/**
	 * Test Preweaponprof with a feat that has a bonus tag
	 * This test was written to help find the source of bug 1699779
	 * @throws Exception
	 */
public void testWithFeatThatGrantsBonus() throws Exception {
    final PlayerCharacter character = getCharacter();
    PCTemplate pctls = new PCTemplate();
    LoadContext context = Globals.getContext();
    context.unconditionallyProcess(pctls, "AUTO", "WEAPONPROF|Longsword");
    assertTrue(context.getReferenceContext().resolveReferences(null));
    final FeatLoader featLoader = new FeatLoader();
    CampaignSourceEntry cse;
    try {
        cse = new CampaignSourceEntry(new Campaign(), new URI("file:/" + getClass().getName() + ".java"));
    } catch (URISyntaxException e) {
        throw new UnreachableError(e);
    }
    int baseHp = character.hitPoints();
    Ability bar = new Ability();
    final String barStr = "Bar	TYPE:General	DESC:See Text	BONUS:HP|CURRENTMAX|50";
    featLoader.parseLine(Globals.getContext(), bar, barStr, cse);
    addAbility(AbilityCategory.FEAT, bar);
    assertEquals("Character should have 50 bonus hp added.", baseHp + 50, character.hitPoints());
    character.addTemplate(pctls);
    Ability foo = new Ability();
    final String fooStr = "Foo	TYPE:General	DESC:See Text	BONUS:HP|CURRENTMAX|50|PREWEAPONPROF:1,Longsword";
    featLoader.parseLine(Globals.getContext(), foo, fooStr, cse);
    addAbility(AbilityCategory.FEAT, foo);
    assertEquals("Character has the longsword proficiency so the bonus should be added", baseHp + 50 + 50, character.hitPoints());
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) Ability(pcgen.core.Ability) PlayerCharacter(pcgen.core.PlayerCharacter) Campaign(pcgen.core.Campaign) FeatLoader(pcgen.persistence.lst.FeatLoader) LoadContext(pcgen.rules.context.LoadContext) URISyntaxException(java.net.URISyntaxException) UnreachableError(pcgen.base.lang.UnreachableError) PCTemplate(pcgen.core.PCTemplate) URI(java.net.URI)

Example 63 with PCTemplate

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

the class PreTypeTest method test996803_2.

/**
	 * Ensure a character with a template correctly passes
	 * PRETEMPLATE
	 */
public void test996803_2() {
    final PlayerCharacter character = getCharacter();
    final PCTemplate template = new PCTemplate();
    template.setName("Half-Celestial");
    template.addToListFor(ListKey.TYPE, Type.getConstant("Outsider"));
    character.addTemplate(template);
    final Prerequisite prereq = new Prerequisite();
    prereq.setKind("type");
    prereq.setKey("Outsider");
    prereq.setOperand("1");
    prereq.setOperator(PrerequisiteOperator.NEQ);
    final boolean passes = PrereqHandler.passes(prereq, character, null);
    assertFalse(passes);
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) PCTemplate(pcgen.core.PCTemplate)

Example 64 with PCTemplate

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

the class PreVisionTest method testVisionPresentTen.

/**
	 * @throws Exception
	 */
public void testVisionPresentTen() 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("ANY");
    boolean passes = PrereqHandler.passes(prereq, character, null);
    assertFalse(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 65 with PCTemplate

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

the class PreVisionTest method testVisionPresentZero.

/**
	 * @throws Exception
	 */
public void testVisionPresentZero() 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("ANY");
    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);
    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