Search in sources :

Example 46 with PreParserFactory

use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.

the class PreSpellSchoolTest method testTwoClassSchool.

public void testTwoClassSchool() throws Exception {
    final PlayerCharacter character = getCharacter();
    final PreParserFactory factory = PreParserFactory.getInstance();
    Prerequisite prereq = factory.parse("PRESPELLSCHOOL:3,Fire=2,Useful=2");
    assertFalse(PrereqHandler.passes(prereq, character, null));
    character.incrementClassLevel(1, wiz);
    boolean passes = PrereqHandler.passes(prereq, character, null);
    assertFalse(passes);
    character.incrementClassLevel(1, wiz);
    passes = PrereqHandler.passes(prereq, character, null);
    assertFalse(passes);
    character.incrementClassLevel(1, cle);
    passes = PrereqHandler.passes(prereq, character, null);
    assertFalse(passes);
    character.incrementClassLevel(1, cle);
    passes = PrereqHandler.passes(prereq, character, null);
    assertTrue(passes);
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) PreParserFactory(pcgen.persistence.lst.prereq.PreParserFactory)

Example 47 with PreParserFactory

use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.

the class PreSpellDescriptorTest method testNotTwoClassDescriptor.

public void testNotTwoClassDescriptor() throws Exception {
    final PlayerCharacter character = getCharacter();
    final PreParserFactory factory = PreParserFactory.getInstance();
    Prerequisite prereq = factory.parse("!PRESPELLDESCRIPTOR:3,Fire=2,Useful=2");
    assertTrue(PrereqHandler.passes(prereq, character, null));
    character.incrementClassLevel(1, wiz);
    boolean passes = PrereqHandler.passes(prereq, character, null);
    assertTrue(passes);
    character.incrementClassLevel(1, wiz);
    passes = PrereqHandler.passes(prereq, character, null);
    assertTrue(passes);
    character.incrementClassLevel(1, cle);
    passes = PrereqHandler.passes(prereq, character, null);
    assertTrue(passes);
    character.incrementClassLevel(1, cle);
    passes = PrereqHandler.passes(prereq, character, null);
    assertFalse(passes);
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) PreParserFactory(pcgen.persistence.lst.prereq.PreParserFactory)

Example 48 with PreParserFactory

use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.

the class DomainTokenTest method testUnparseSinglePre.

@Test
public void testUnparseSinglePre() throws PersistenceLayerException {
    Domain wp1 = construct(primaryContext, "TestWP1");
    CDOMDirectSingleRef<Domain> ref = CDOMDirectSingleRef.getRef(wp1);
    PreParserFactory prereqParser = PreParserFactory.getInstance();
    Prerequisite prereq = prereqParser.parse("PRERACE:1,Dwarf");
    assertNotNull(prereq);
    QualifiedObject<CDOMSingleRef<Domain>> qo = new QualifiedObject<>(ref, prereq);
    primaryProf.addToListFor(ListKey.DOMAIN, qo);
    String[] unparsed = getToken().unparse(primaryContext, primaryProf);
    expectSingle(unparsed, getLegalValue() + "|PRERACE:1,Dwarf");
}
Also used : PreParserFactory(pcgen.persistence.lst.prereq.PreParserFactory) QualifiedObject(pcgen.core.QualifiedObject) Domain(pcgen.core.Domain) CDOMSingleRef(pcgen.cdom.reference.CDOMSingleRef) Prerequisite(pcgen.core.prereq.Prerequisite) Test(org.junit.Test)

Example 49 with PreParserFactory

use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.

the class MonNonSkillTHDTokenTest method testUnparseOnePrereq.

@Test
public void testUnparseOnePrereq() throws PersistenceLayerException {
    BonusObj bonus = getBonus(1);
    PreParserFactory prereqParser = PreParserFactory.getInstance();
    Prerequisite prereq = prereqParser.parse("PRERACE:1,Dwarf");
    assertNotNull(prereq);
    bonus.addPrerequisite(prereq);
    primaryProf.addToListFor(ListKey.BONUS, bonus);
    String[] sap = getToken().unparse(primaryContext, primaryProf);
    expectSingle(sap, "1|PRERACE:1,Dwarf");
}
Also used : PreParserFactory(pcgen.persistence.lst.prereq.PreParserFactory) BonusObj(pcgen.core.bonus.BonusObj) Prerequisite(pcgen.core.prereq.Prerequisite) Test(org.junit.Test)

Example 50 with PreParserFactory

use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.

the class StartFeatsTokenTest method getBonus.

private BonusObj getBonus(int bonusValue) throws PersistenceLayerException {
    BonusObj bon = Bonus.newBonus(primaryContext, "FEAT|POOL|" + bonusValue);
    assertNotNull(bon);
    PreParserFactory prereqParser = PreParserFactory.getInstance();
    Prerequisite prereq = prereqParser.parse("PREMULT:1,[PREHD:MIN=1],[PRELEVEL:MIN=1]");
    assertNotNull(prereq);
    bon.addPrerequisite(prereq);
    bon.setTokenSource(token.getTokenName());
    return bon;
}
Also used : PreParserFactory(pcgen.persistence.lst.prereq.PreParserFactory) BonusObj(pcgen.core.bonus.BonusObj) Prerequisite(pcgen.core.prereq.Prerequisite)

Aggregations

PreParserFactory (pcgen.persistence.lst.prereq.PreParserFactory)107 PlayerCharacter (pcgen.core.PlayerCharacter)89 LoadContext (pcgen.rules.context.LoadContext)16 BonusObj (pcgen.core.bonus.BonusObj)13 Prerequisite (pcgen.core.prereq.Prerequisite)12 Ability (pcgen.core.Ability)11 PCClass (pcgen.core.PCClass)11 ArrayList (java.util.ArrayList)7 Test (org.junit.Test)7 StringTokenizer (java.util.StringTokenizer)5 Domain (pcgen.core.Domain)5 PCTemplate (pcgen.core.PCTemplate)5 PersistenceLayerException (pcgen.persistence.PersistenceLayerException)5 URI (java.net.URI)4 Equipment (pcgen.core.Equipment)4 PersistenceManager (pcgen.persistence.PersistenceManager)4 DamageReduction (pcgen.cdom.content.DamageReduction)3 ClassSource (pcgen.cdom.helper.ClassSource)3 CDOMSingleRef (pcgen.cdom.reference.CDOMSingleRef)3 QualifiedObject (pcgen.core.QualifiedObject)3