Search in sources :

Example 1 with PreClassLevelMaxParser

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

the class PreClassTest method testPreClassLevelMax.

/**
	 * Test the PRE CLASSLEVELMAX token 
	 * @throws Exception
	 */
public void testPreClassLevelMax() throws Exception {
    final PreClassLevelMaxParser parser = new PreClassLevelMaxParser();
    final Prerequisite prereq = parser.parse("CLASSLEVELMAX", "1,Monk=1", false, false);
    final Prerequisite dualPrereq = parser.parse("CLASSLEVELMAX", "2,Monk=1,Fighter=1", false, false);
    final Prerequisite singlePrereq = parser.parse("CLASSLEVELMAX", "1,Monk=1,Fighter=1", false, false);
    final PlayerCharacter character = getCharacter();
    assertTrue("Should pass with no levels", PrereqHandler.passes(prereq, character, null));
    assertTrue("Should pass with no levels of either", PrereqHandler.passes(dualPrereq, character, null));
    final PCClass pcClass = new PCClass();
    pcClass.setName("Monk");
    character.incrementClassLevel(1, pcClass);
    assertTrue("Should pass with 1 level", PrereqHandler.passes(prereq, character, null));
    assertTrue("Should pass with 1 level of one", PrereqHandler.passes(dualPrereq, character, null));
    final PCClass ftrClass = new PCClass();
    ftrClass.setName("Fighter");
    character.incrementClassLevel(1, ftrClass);
    assertTrue("Should pass with 1 level of each", PrereqHandler.passes(dualPrereq, character, null));
    character.incrementClassLevel(1, pcClass);
    assertFalse("Should not pass with 2 levels", PrereqHandler.passes(prereq, character, null));
    assertFalse("Should not pass with 2 levels of one", PrereqHandler.passes(dualPrereq, character, null));
    assertTrue("Should pass with 2 levels of one", PrereqHandler.passes(singlePrereq, character, null));
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) PreClassLevelMaxParser(plugin.pretokens.parser.PreClassLevelMaxParser) PCClass(pcgen.core.PCClass)

Example 2 with PreClassLevelMaxParser

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

the class PreClassLevelMaxRobin method setUp.

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

Example 3 with PreClassLevelMaxParser

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

the class PreClassTest method testOldPreClassLevelMax.

public void testOldPreClassLevelMax() throws Exception {
    final PreClassLevelMaxParser parser = new PreClassLevelMaxParser();
    try {
        parser.parse("CLASSLEVELMAX", "Fighter=2", false, false);
        fail();
    } catch (PersistenceLayerException e) {
    // Do Nothing, we should catch an exception here
    }
}
Also used : PersistenceLayerException(pcgen.persistence.PersistenceLayerException) PreClassLevelMaxParser(plugin.pretokens.parser.PreClassLevelMaxParser)

Aggregations

PreClassLevelMaxParser (plugin.pretokens.parser.PreClassLevelMaxParser)3 PCClass (pcgen.core.PCClass)1 PlayerCharacter (pcgen.core.PlayerCharacter)1 PersistenceLayerException (pcgen.persistence.PersistenceLayerException)1 PreClassParser (plugin.pretokens.parser.PreClassParser)1 PreClassWriter (plugin.pretokens.writer.PreClassWriter)1