Search in sources :

Example 96 with PCClass

use of pcgen.core.PCClass in project pcgen by PCGen.

the class PreClassTest method testAnyLevelsTwoClasses.

public void testAnyLevelsTwoClasses() throws Exception {
    final PCClass pcClass = new PCClass();
    pcClass.setName("MyClass");
    BuildUtilities.setFact(pcClass, "SpellType", "Arcane");
    final PCClass pcClass2 = new PCClass();
    pcClass2.setName("MyClass2");
    BuildUtilities.setFact(pcClass2, "SpellType", "Divine");
    final PlayerCharacter character = getCharacter();
    final PreParserFactory factory = PreParserFactory.getInstance();
    Prerequisite prereq = factory.parse("PRECLASS:2,ANY=1");
    character.incrementClassLevel(1, pcClass);
    assertEquals(false, PrereqHandler.passes(prereq, character, null));
    character.incrementClassLevel(1, pcClass2);
    assertEquals(true, PrereqHandler.passes(prereq, character, null));
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) PreParserFactory(pcgen.persistence.lst.prereq.PreParserFactory) PCClass(pcgen.core.PCClass)

Example 97 with PCClass

use of pcgen.core.PCClass in project pcgen by PCGen.

the class PreClassTest method testCharWithMultipleSpellClasses.

/**
	 * Test to ensure that a character will fail a test
	 * if it does not have the correct number of levels
	 * in the class.
	 * @throws Exception
	 */
public void testCharWithMultipleSpellClasses() throws Exception {
    LoadContext context = Globals.getContext();
    final PCClass pcClass = context.getReferenceContext().constructCDOMObject(PCClass.class, "MyClass");
    context.unconditionallyProcess(pcClass, "SPELLSTAT", "CHA");
    BuildUtilities.setFact(pcClass, "SpellType", "Arcane");
    context.unconditionallyProcess(pcClass.getOriginalClassLevel(1), "CAST", "5,4");
    final PCClass pcClass2 = context.getReferenceContext().constructCDOMObject(PCClass.class, "Other Class");
    context.unconditionallyProcess(pcClass2, "SPELLSTAT", "INT");
    BuildUtilities.setFact(pcClass2, "SpellType", "Arcane");
    context.unconditionallyProcess(pcClass2.getOriginalClassLevel(1), "CAST", "5,4");
    context.getReferenceContext().buildDerivedObjects();
    context.getReferenceContext().resolveReferences(null);
    context.loadCampaignFacets();
    final PlayerCharacter character = getCharacter();
    setPCStat(character, cha, 12);
    setPCStat(character, intel, 12);
    character.incrementClassLevel(1, pcClass);
    character.incrementClassLevel(2, pcClass2);
    final Prerequisite prereq = new Prerequisite();
    prereq.setKind("class");
    prereq.setKey("SPELLCASTER.ARCANE");
    prereq.setOperand("3");
    prereq.setTotalValues(true);
    prereq.setOperator(PrerequisiteOperator.GTEQ);
    final PreClassTester test = new PreClassTester();
    final int passes = test.passes(prereq, character, null);
    assertEquals(3, passes);
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) PreClassTester(plugin.pretokens.test.PreClassTester) LoadContext(pcgen.rules.context.LoadContext) PCClass(pcgen.core.PCClass)

Example 98 with PCClass

use of pcgen.core.PCClass in project pcgen by PCGen.

the class PreClassTest method testFromParserCharWithMultipleSpellClasses.

/**
	 * Test to ensure that a character will fail a test
	 * if it does not have the correct number of levels
	 * in the class.
	 * @throws Exception
	 */
public void testFromParserCharWithMultipleSpellClasses() throws Exception {
    LoadContext context = Globals.getContext();
    final PCClass pcClass = context.getReferenceContext().constructCDOMObject(PCClass.class, "MyClass");
    context.unconditionallyProcess(pcClass, "SPELLSTAT", "CHA");
    BuildUtilities.setFact(pcClass, "SpellType", "Arcane");
    context.unconditionallyProcess(pcClass.getOriginalClassLevel(1), "CAST", "5,4");
    final PCClass pcClass2 = context.getReferenceContext().constructCDOMObject(PCClass.class, "Other Class");
    context.unconditionallyProcess(pcClass2, "SPELLSTAT", "INT");
    BuildUtilities.setFact(pcClass2, "SpellType", "Arcane");
    context.unconditionallyProcess(pcClass2.getOriginalClassLevel(1), "CAST", "5,4");
    context.getReferenceContext().buildDerivedObjects();
    context.getReferenceContext().resolveReferences(null);
    context.loadCampaignFacets();
    final PlayerCharacter character = getCharacter();
    setPCStat(character, cha, 12);
    setPCStat(character, intel, 12);
    character.incrementClassLevel(1, pcClass);
    character.incrementClassLevel(2, pcClass2);
    final PreParserFactory factory = PreParserFactory.getInstance();
    final Prerequisite prereq = factory.parse("PRECLASS:1,SPELLCASTER.ARCANE=3");
    final PreClassTester test = new PreClassTester();
    int passes = test.passes(prereq, character, null);
    // Doens't pass - levels not summed...
    assertEquals(0, passes);
    character.incrementClassLevel(1, pcClass2);
    passes = test.passes(prereq, character, null);
    assertEquals(1, passes);
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) PreParserFactory(pcgen.persistence.lst.prereq.PreParserFactory) PreClassTester(plugin.pretokens.test.PreClassTester) LoadContext(pcgen.rules.context.LoadContext) PCClass(pcgen.core.PCClass)

Example 99 with PCClass

use of pcgen.core.PCClass 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 100 with PCClass

use of pcgen.core.PCClass in project pcgen by PCGen.

the class LocalSkillCostFacetTest method testRemoveUselessSource.

@Test
public void testRemoveUselessSource() {
    Skill t1 = getObject();
    assertFalse(getFacet().contains(id, class1, SkillCost.CLASS, t1));
    addCost(id, class1, t1, SkillCost.CLASS);
    assertTrue(getFacet().contains(id, class1, SkillCost.CLASS, t1));
    PCClass source2 = new PCClass();
    removeCosts(id, source2);
    assertTrue(getFacet().contains(id, class1, SkillCost.CLASS, t1));
}
Also used : Skill(pcgen.core.Skill) PCClass(pcgen.core.PCClass) Test(org.junit.Test)

Aggregations

PCClass (pcgen.core.PCClass)359 Test (org.junit.Test)96 PlayerCharacter (pcgen.core.PlayerCharacter)61 Skill (pcgen.core.Skill)55 ArrayList (java.util.ArrayList)35 Domain (pcgen.core.Domain)30 LoadContext (pcgen.rules.context.LoadContext)28 PCClassLevel (pcgen.cdom.inst.PCClassLevel)26 CDOMObject (pcgen.cdom.base.CDOMObject)23 CharacterSpell (pcgen.core.character.CharacterSpell)20 Spell (pcgen.core.spell.Spell)20 StringTokenizer (java.util.StringTokenizer)19 CharID (pcgen.cdom.enumeration.CharID)19 ClassSource (pcgen.cdom.helper.ClassSource)19 PreClassTester (plugin.pretokens.test.PreClassTester)16 SkillCost (pcgen.cdom.enumeration.SkillCost)15 ParseResult (pcgen.rules.persistence.token.ParseResult)15 Ability (pcgen.core.Ability)14 Race (pcgen.core.Race)14 BonusObj (pcgen.core.bonus.BonusObj)14