Search in sources :

Example 31 with PlayerCharacter

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

the class PreShieldProfTest method testShieldProfAddedWithAutoShieldProf.

/**
	 * Test the PREPROFWITHSHIELD with shieldprofs added by a AUTO:SHIELDPROF tag
	 * This is probably more an integration test than a unit test
	 * 
	 * @throws Exception the exception
	 */
public void testShieldProfAddedWithAutoShieldProf() throws Exception {
    final PlayerCharacter character = getCharacter();
    Prerequisite prereq;
    final PreParserFactory factory = PreParserFactory.getInstance();
    prereq = factory.parse("PREPROFWITHSHIELD:1,Heavy Steel Shield");
    assertFalse("Character has no proficiencies", PrereqHandler.passes(prereq, character, null));
    final Ability martialProf = TestHelper.makeAbility("Shield Proficiency (Single)", AbilityCategory.FEAT, "General");
    Globals.getContext().unconditionallyProcess(martialProf, "AUTO", "SHIELDPROF|SHIELDTYPE.Heavy");
    AbstractCharacterTestCase.applyAbility(character, AbilityCategory.FEAT, martialProf, null);
    assertTrue("Character has the Heavy Steel Shield proficiency.", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREPROFWITHSHIELD:1,Heavy Wooden Shield");
    assertTrue("Character has the Heavy Wooden Shield proficiency.", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREPROFWITHSHIELD:1,Light Wooden Shield");
    assertFalse("Character does not have the Light Wooden Shield proficiency.", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREPROFWITHSHIELD:1,TYPE.Heavy");
    assertTrue("Character has heavy shield prof.", PrereqHandler.passes(prereq, character, null));
}
Also used : Ability(pcgen.core.Ability) PlayerCharacter(pcgen.core.PlayerCharacter) PreParserFactory(pcgen.persistence.lst.prereq.PreParserFactory)

Example 32 with PlayerCharacter

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

the class PreShieldProfTest method testWithFeatThatGrantsBonus.

/**
	 * Test PREPROFWITHSHIELD with a feat that has a bonus tag
	 * 
	 * @throws Exception the exception
	 */
public void testWithFeatThatGrantsBonus() throws Exception {
    final PlayerCharacter character = getCharacter();
    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());
    final Ability martialProf = TestHelper.makeAbility("Shield Proficiency (Single)", "FEAT", "General");
    Globals.getContext().unconditionallyProcess(martialProf, "AUTO", "SHIELDPROF|Full Plate");
    assertTrue(Globals.getContext().getReferenceContext().resolveReferences(null));
    AbstractCharacterTestCase.applyAbility(character, AbilityCategory.FEAT, martialProf, null);
    Ability foo = new Ability();
    final String fooStr = "Foo	TYPE:General	DESC:See Text	BONUS:HP|CURRENTMAX|50|PREPROFWITHSHIELD:1,Full Plate";
    featLoader.parseLine(Globals.getContext(), foo, fooStr, cse);
    addAbility(AbilityCategory.FEAT, foo);
    assertEquals("Character has the Full Plate 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) URISyntaxException(java.net.URISyntaxException) UnreachableError(pcgen.base.lang.UnreachableError) URI(java.net.URI)

Example 33 with PlayerCharacter

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

the class PreShieldProfTest method testType.

/**
	 * Test a PREPROFWITHSHIELD that checks for a number of profs of a certain type.
	 * 
	 * @throws Exception the exception
	 */
public void testType() throws Exception {
    final PlayerCharacter character = getCharacter();
    Globals.getContext().getReferenceContext().constructCDOMObject(Equipment.class, "A Shield");
    Prerequisite prereq;
    final PreParserFactory factory = PreParserFactory.getInstance();
    prereq = factory.parse("PREPROFWITHSHIELD:1,TYPE.Medium");
    assertFalse("Character has no proficiencies", PrereqHandler.passes(prereq, character, null));
    final Ability martialProf = TestHelper.makeAbility("Shield Proficiency (Single)", "FEAT", "General");
    Globals.getContext().unconditionallyProcess(martialProf, "AUTO", "SHIELDPROF|SHIELDTYPE=Medium");
    Globals.getContext().getReferenceContext().resolveReferences(null);
    AbstractCharacterTestCase.applyAbility(character, AbilityCategory.FEAT, martialProf, null);
    assertTrue("Character has Medium Shield Proficiency", PrereqHandler.passes(prereq, character, null));
}
Also used : Ability(pcgen.core.Ability) PlayerCharacter(pcgen.core.PlayerCharacter) PreParserFactory(pcgen.persistence.lst.prereq.PreParserFactory)

Example 34 with PlayerCharacter

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

the class PreShieldProfTest method testOneOption.

/**
	 * Test with a simple shield proficiency.
	 * 
	 * @throws Exception the exception
	 */
public void testOneOption() throws Exception {
    final PlayerCharacter character = getCharacter();
    Prerequisite prereq;
    final PreParserFactory factory = PreParserFactory.getInstance();
    prereq = factory.parse("PREPROFWITHSHIELD:1,Heavy Wooden Shield");
    assertFalse("Character has no proficiencies", PrereqHandler.passes(prereq, character, null));
    final Ability martialProf = TestHelper.makeAbility("Shield Proficiency (Single)", "FEAT", "General");
    Globals.getContext().unconditionallyProcess(martialProf, "AUTO", "SHIELDPROF|Heavy Wooden Shield");
    Globals.getContext().unconditionallyProcess(martialProf, "AUTO", "SHIELDPROF|Heavy Steel Shield");
    assertTrue(Globals.getContext().getReferenceContext().resolveReferences(null));
    AbstractCharacterTestCase.applyAbility(character, AbilityCategory.FEAT, martialProf, null);
    assertTrue("Character has the Heavy Wooden Shield proficiency.", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREPROFWITHSHIELD:1,Light Wooden Shield");
    assertFalse("Character does not have the Light Wooden Shield proficiency", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREPROFWITHSHIELD:1,Heavy Steel Shield");
    assertTrue("Character has the Heavy Steel Shield proficiency.", PrereqHandler.passes(prereq, character, null));
}
Also used : Ability(pcgen.core.Ability) PlayerCharacter(pcgen.core.PlayerCharacter) PreParserFactory(pcgen.persistence.lst.prereq.PreParserFactory)

Example 35 with PlayerCharacter

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

the class PreMultTest method setUp.

/**
	 * @see junit.framework.TestCase#setUp()
	 */
@Override
protected void setUp() throws Exception {
    super.setUp();
    final PlayerCharacter character = getCharacter();
    myClass = new PCClass();
    myClass.setName("My Class");
    knowledge = new Skill();
    Globals.getContext().unconditionallyProcess(knowledge, "CLASSES", "My Class");
    knowledge.setName("KNOWLEDGE (ARCANA)");
    TestHelper.addType(knowledge, "KNOWLEDGE.INT");
    SkillRankControl.modRanks(8.0, myClass, true, character, knowledge);
}
Also used : Skill(pcgen.core.Skill) PlayerCharacter(pcgen.core.PlayerCharacter) PCClass(pcgen.core.PCClass)

Aggregations

PlayerCharacter (pcgen.core.PlayerCharacter)438 PreParserFactory (pcgen.persistence.lst.prereq.PreParserFactory)89 PCClass (pcgen.core.PCClass)61 LoadContext (pcgen.rules.context.LoadContext)58 Ability (pcgen.core.Ability)54 Equipment (pcgen.core.Equipment)41 PCTemplate (pcgen.core.PCTemplate)38 EquipSet (pcgen.core.character.EquipSet)32 BonusObj (pcgen.core.bonus.BonusObj)29 Race (pcgen.core.Race)28 CharID (pcgen.cdom.enumeration.CharID)25 ExportHandler (pcgen.io.ExportHandler)24 Test (org.junit.Test)20 ArrayList (java.util.ArrayList)16 PreClassTester (plugin.pretokens.test.PreClassTester)16 CDOMObject (pcgen.cdom.base.CDOMObject)15 Skill (pcgen.core.Skill)14 CNAbility (pcgen.cdom.content.CNAbility)13 URI (java.net.URI)11 URISyntaxException (java.net.URISyntaxException)11