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