use of pcgen.core.PlayerCharacter in project pcgen by PCGen.
the class PreFactTest method testFact.
/**
* Test the PREFACT code
* @throws Exception
*/
public void testFact() throws Exception {
final PlayerCharacter character = getCharacter();
Race race = new Race();
BuildUtilities.setFact(race, "ABB", "Hgln");
race.setName("Hobgoblin");
character.setRace(race);
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PREFACT:1,RACE,ABB=Hum");
assertFalse("Character should not be a matching race", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREFACT:1,RACE,ABB=Hgln");
assertTrue("Character should be a matching race", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.core.PlayerCharacter in project pcgen by PCGen.
the class PreHPTest method testHP.
/**
* Test the PREHP code
* @throws Exception
*/
public void testHP() throws Exception {
final PlayerCharacter character = getCharacter();
LoadContext context = Globals.getContext();
character.incrementClassLevel(1, myClass, true);
myClass = character.getClassList().get(0);
PCClassLevel pcl = character.getActiveClassLevel(myClass, 1);
character.setHP(pcl, 4);
character.calcActiveBonuses();
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PREHP:4");
assertTrue("Character should have 4 hp", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREHP:5");
assertFalse("Character should have less than 5 hp", PrereqHandler.passes(prereq, character, null));
final BonusObj hpBonus = Bonus.newBonus(context, "HP|CURRENTMAX|1");
myClass.addToListFor(ListKey.BONUS, hpBonus);
character.calcActiveBonuses();
assertTrue("Character should have 5 hp", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.core.PlayerCharacter in project pcgen by PCGen.
the class PreKitTest method testNotAbsent.
/**
* Ensure a character with the requested kit correctly fails
* !PREKIT
*/
public void testNotAbsent() {
final PlayerCharacter character = getCharacter();
Kit kit = TestHelper.makeKit("Dungeoneering Kit (Common)");
// Note this is a shortcut rather than doing a full apply of the kit
character.addKit(kit);
final Prerequisite prereq = new Prerequisite();
prereq.setKind("kit");
prereq.setKey("KEY_Dungeoneering Kit (Common)");
prereq.setOperator(PrerequisiteOperator.LT);
prereq.setOperand("1");
final boolean passes = PrereqHandler.passes(prereq, character, null);
assertFalse("Expected kit to be present", passes);
}
use of pcgen.core.PlayerCharacter in project pcgen by PCGen.
the class PreKitTest method testKitPresence.
/**
* Ensure a character with a kit correctly passes
* PREKIT
*/
public void testKitPresence() {
final PlayerCharacter character = getCharacter();
Kit kit = TestHelper.makeKit("Dungeoneering Kit (Common)");
// Note this is a shortcut rather than doing a full apply of the kit
character.addKit(kit);
final Prerequisite prereq = new Prerequisite();
prereq.setKind("kit");
prereq.setKey("KEY_Dungeoneering Kit (Common)");
prereq.setOperator(PrerequisiteOperator.GTEQ);
prereq.setOperand("1");
final boolean passes = PrereqHandler.passes(prereq, character, null);
assertTrue("Expected kit to be present", passes);
}
use of pcgen.core.PlayerCharacter in project pcgen by PCGen.
the class PreKitTest method testBadOperand.
/**
* Ensure a test with a non integer operand fails with a meaningfull
* error message
*/
public void testBadOperand() {
final PlayerCharacter character = getCharacter();
final Prerequisite prereq = new Prerequisite();
prereq.setKind("kit");
prereq.setKey("half%");
prereq.setOperator(PrerequisiteOperator.GTEQ);
prereq.setOperand("One");
final boolean passes = PrereqHandler.passes(prereq, character, null);
assertFalse(passes);
}
Aggregations