Search in sources :

Example 1 with PreRuleParser

use of plugin.pretokens.parser.PreRuleParser in project pcgen by PCGen.

the class PreRuleTest method ruleDisabled.

/**
	 * Test to ensure that we return false when races don't match.
	 * 
	 * @throws Exception
	 */
public void ruleDisabled() throws Exception {
    assertFalse("Our rule should start as false", Globals.checkRule("PRERULE"));
    PreRuleParser parser = new PreRuleParser();
    Prerequisite prereq = parser.parse("RULE", "1,PRERULE", false, false);
    boolean passes = PrereqHandler.passes(prereq, getCharacter(), null);
    assertFalse("PreRule should fail when rule is disabled.", passes);
    prereq = parser.parse("RULE", "1,PRERULE", true, false);
    passes = PrereqHandler.passes(prereq, getCharacter(), null);
    assertTrue("!PreRule should pass when rule is disabled.", passes);
}
Also used : PreRuleParser(plugin.pretokens.parser.PreRuleParser)

Example 2 with PreRuleParser

use of plugin.pretokens.parser.PreRuleParser in project pcgen by PCGen.

the class PreRuleTest method ruleEnabled.

/**
	 * Test to ensure that we return false when races don't match.
	 * 
	 * @throws Exception
	 */
public void ruleEnabled() throws Exception {
    RuleCheck preRule = SettingsHandler.getGame().getModeContext().getReferenceContext().silentlyGetConstructedCDOMObject(RuleCheck.class, "PRERULE");
    preRule.setDefault(true);
    assertTrue("Our rule should now be true", Globals.checkRule("PRERULE"));
    PreRuleParser parser = new PreRuleParser();
    Prerequisite prereq = parser.parse("RULE", "1,PRERULE", false, false);
    boolean passes = PrereqHandler.passes(prereq, getCharacter(), null);
    assertTrue("PreRule should pass when rule is enabled.", passes);
    prereq = parser.parse("RULE", "1,PRERULE", true, false);
    passes = PrereqHandler.passes(prereq, getCharacter(), null);
    assertFalse("!PreRule should fail when rule is enabled.", passes);
}
Also used : PreRuleParser(plugin.pretokens.parser.PreRuleParser) RuleCheck(pcgen.core.RuleCheck)

Example 3 with PreRuleParser

use of plugin.pretokens.parser.PreRuleParser in project pcgen by PCGen.

the class PreRuleRoundRobin method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    TokenRegistration.register(new PreRuleParser());
    TokenRegistration.register(new PreRuleWriter());
}
Also used : PreRuleWriter(plugin.pretokens.writer.PreRuleWriter) PreRuleParser(plugin.pretokens.parser.PreRuleParser)

Example 4 with PreRuleParser

use of plugin.pretokens.parser.PreRuleParser in project pcgen by PCGen.

the class PreRuleParserTest method testPositive.

/**
	 * @throws Exception
	 */
@Test
public void testPositive() throws Exception {
    PreRuleParser parser = new PreRuleParser();
    Prerequisite prereq = parser.parse("RULE", "1,DISPLAYTYPETRAITS", false, false);
    assertEquals("<prereq kind=\"rule\" key=\"DISPLAYTYPETRAITS\" operator=\"GTEQ\" operand=\"1\" >\n</prereq>\n", prereq.toString());
    assertFalse("Prerule should nto need a character", prereq.isCharacterRequired());
}
Also used : PreRuleParser(plugin.pretokens.parser.PreRuleParser) Prerequisite(pcgen.core.prereq.Prerequisite) Test(org.junit.Test)

Example 5 with PreRuleParser

use of plugin.pretokens.parser.PreRuleParser in project pcgen by PCGen.

the class PreRuleParserTest method testNegative.

/**
	 * @throws Exception
	 */
@Test
public void testNegative() throws Exception {
    PreRuleParser parser = new PreRuleParser();
    Prerequisite prereq = parser.parse("RULE", "1,DISPLAYTYPETRAITS", true, false);
    assertEquals("<prereq kind=\"rule\" key=\"DISPLAYTYPETRAITS\" operator=\"LT\" operand=\"1\" >\n</prereq>\n", prereq.toString());
    assertFalse("Prerule should nto need a character", prereq.isCharacterRequired());
}
Also used : PreRuleParser(plugin.pretokens.parser.PreRuleParser) Prerequisite(pcgen.core.prereq.Prerequisite) Test(org.junit.Test)

Aggregations

PreRuleParser (plugin.pretokens.parser.PreRuleParser)5 Test (org.junit.Test)2 Prerequisite (pcgen.core.prereq.Prerequisite)2 RuleCheck (pcgen.core.RuleCheck)1 PreRuleWriter (plugin.pretokens.writer.PreRuleWriter)1