Search in sources :

Example 86 with Prerequisite

use of pcgen.core.prereq.Prerequisite in project pcgen by PCGen.

the class PreMoveParserTest method testNotFlyAndWalk.

/**
	 * @throws Exception
	 */
@Test
public void testNotFlyAndWalk() throws Exception {
    PreMoveParser parser = new PreMoveParser();
    Prerequisite prereq = parser.parse("MOVE", "1,Walk=30,Fly=20", true, false);
    assertEquals("<prereq operator=\"LT\" operand=\"1\" >\n" + "<prereq kind=\"move\" count-multiples=\"true\" key=\"Walk\" operator=\"GTEQ\" operand=\"30\" >\n" + "</prereq>\n" + "<prereq kind=\"move\" count-multiples=\"true\" key=\"Fly\" operator=\"GTEQ\" operand=\"20\" >\n" + "</prereq>\n" + "</prereq>\n", prereq.toString());
}
Also used : PreMoveParser(plugin.pretokens.parser.PreMoveParser) Prerequisite(pcgen.core.prereq.Prerequisite) Test(org.junit.Test)

Example 87 with Prerequisite

use of pcgen.core.prereq.Prerequisite in project pcgen by PCGen.

the class PreMoveParserTest method testNotFly1.

/**
	 * @throws Exception
	 */
@Test
public void testNotFly1() throws Exception {
    PreMoveParser parser = new PreMoveParser();
    Prerequisite prereq = parser.parse("MOVE", "1,Fly=1", true, false);
    assertEquals("<prereq kind=\"move\" key=\"Fly\" operator=\"LT\" operand=\"1\" >\n</prereq>\n", prereq.toString());
}
Also used : PreMoveParser(plugin.pretokens.parser.PreMoveParser) Prerequisite(pcgen.core.prereq.Prerequisite) Test(org.junit.Test)

Example 88 with Prerequisite

use of pcgen.core.prereq.Prerequisite in project pcgen by PCGen.

the class PreMultParserTest method testUnbalancedBracket.

@Test
public void testUnbalancedBracket() {
    PreMultParser parser = new PreMultParser();
    try {
        Prerequisite prereq = parser.parse("mult", "1,[PREPROFWITHARMOR:1,TYPE.Medium],[PREFEAT:1,Armor Proficiency (Medium)", false, false);
        fail("Expected unbalanced bracket to be detected.");
    } catch (PersistenceLayerException e) {
        assertEquals("Unbalanced [] in PREMULT '[PREPROFWITHARMOR:1,TYPE.Medium],[PREFEAT:1,Armor Proficiency (Medium)'.", e.getMessage());
    }
}
Also used : PersistenceLayerException(pcgen.persistence.PersistenceLayerException) Prerequisite(pcgen.core.prereq.Prerequisite) Test(org.junit.Test)

Example 89 with Prerequisite

use of pcgen.core.prereq.Prerequisite in project pcgen by PCGen.

the class PreParserFactoryTest method testOverrideQualifies.

/**
	 * @throws Exception
	 */
public void testOverrideQualifies() throws Exception {
    PreParserFactory factory = PreParserFactory.getInstance();
    Prerequisite prereq = factory.parse("PREVARNEQ:Q:Enraged,1");
    assertEquals("<prereq kind=\"var\" key=\"Enraged\" operator=\"NEQ\" operand=\"1\" override-qualify=\"true\" >\n</prereq>\n", prereq.toString());
}
Also used : Prerequisite(pcgen.core.prereq.Prerequisite)

Example 90 with Prerequisite

use of pcgen.core.prereq.Prerequisite in project pcgen by PCGen.

the class PreParserFactoryTest method testInvertResult.

public void testInvertResult() throws Exception {
    PreParserFactory factory = PreParserFactory.getInstance();
    Prerequisite prereq = factory.parse("!PREALIGN:LG,LN,LE");
    assertEquals("<prereq operator=\"LT\" operand=\"1\" >\n" + "<prereq kind=\"align\" key=\"LG\" operator=\"EQ\" operand=\"1\" >\n</prereq>\n" + "<prereq kind=\"align\" key=\"LN\" operator=\"EQ\" operand=\"1\" >\n</prereq>\n" + "<prereq kind=\"align\" key=\"LE\" operator=\"EQ\" operand=\"1\" >\n</prereq>\n" + "</prereq>\n", prereq.toString());
    prereq = factory.parse("PREALIGN:NG,TN,NE,CG,CN,CE");
    assertEquals("<prereq operator=\"GTEQ\" operand=\"1\" >\n" + "<prereq kind=\"align\" key=\"NG\" operator=\"EQ\" operand=\"1\" >\n</prereq>\n" + "<prereq kind=\"align\" key=\"TN\" operator=\"EQ\" operand=\"1\" >\n</prereq>\n" + "<prereq kind=\"align\" key=\"NE\" operator=\"EQ\" operand=\"1\" >\n</prereq>\n" + "<prereq kind=\"align\" key=\"CG\" operator=\"EQ\" operand=\"1\" >\n</prereq>\n" + "<prereq kind=\"align\" key=\"CN\" operator=\"EQ\" operand=\"1\" >\n</prereq>\n" + "<prereq kind=\"align\" key=\"CE\" operator=\"EQ\" operand=\"1\" >\n</prereq>\n" + "</prereq>\n", prereq.toString());
}
Also used : Prerequisite(pcgen.core.prereq.Prerequisite)

Aggregations

Prerequisite (pcgen.core.prereq.Prerequisite)267 PersistenceLayerException (pcgen.persistence.PersistenceLayerException)62 Test (org.junit.Test)61 PrerequisiteOperator (pcgen.core.prereq.PrerequisiteOperator)50 StringTokenizer (java.util.StringTokenizer)36 ArrayList (java.util.ArrayList)35 StringWriter (java.io.StringWriter)19 AssociatedPrereqObject (pcgen.cdom.base.AssociatedPrereqObject)19 CDOMReference (pcgen.cdom.base.CDOMReference)18 ParseResult (pcgen.rules.persistence.token.ParseResult)18 BonusObj (pcgen.core.bonus.BonusObj)13 TreeSet (java.util.TreeSet)12 PreParserFactory (pcgen.persistence.lst.prereq.PreParserFactory)12 CDOMSingleRef (pcgen.cdom.reference.CDOMSingleRef)10 Domain (pcgen.core.Domain)10 QualifiedObject (pcgen.core.QualifiedObject)10 PrerequisiteWriterInterface (pcgen.persistence.lst.output.prereq.PrerequisiteWriterInterface)10 PrerequisiteWriter (pcgen.persistence.lst.output.prereq.PrerequisiteWriter)9 Ungranted (pcgen.cdom.base.Ungranted)8 PrerequisiteException (pcgen.core.prereq.PrerequisiteException)8