Search in sources :

Example 51 with PlayerCharacter

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));
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) PreParserFactory(pcgen.persistence.lst.prereq.PreParserFactory) Race(pcgen.core.Race)

Example 52 with PlayerCharacter

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));
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) PreParserFactory(pcgen.persistence.lst.prereq.PreParserFactory) BonusObj(pcgen.core.bonus.BonusObj) LoadContext(pcgen.rules.context.LoadContext) PCClassLevel(pcgen.cdom.inst.PCClassLevel)

Example 53 with PlayerCharacter

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);
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) Kit(pcgen.core.Kit)

Example 54 with PlayerCharacter

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);
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) Kit(pcgen.core.Kit)

Example 55 with PlayerCharacter

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);
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter)

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