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));
}
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());
}
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));
}
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));
}
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);
}
Aggregations