use of pcgen.core.PlayerCharacter in project pcgen by PCGen.
the class PreMultTest method testMultiFeats.
/**
* Test to ensure that a number of feat test will
* correctly require a number of separate feats in
* any combination of two types.
* @throws Exception
*/
public void testMultiFeats() throws Exception {
final Ability metamagic1 = new Ability();
metamagic1.addToListFor(ListKey.TYPE, Type.getConstant("METAMAGIC"));
metamagic1.setName("MM1");
metamagic1.put(StringKey.KEY_NAME, "MM1");
metamagic1.setCDOMCategory(AbilityCategory.FEAT);
final Ability metamagic2 = new Ability();
metamagic2.addToListFor(ListKey.TYPE, Type.getConstant("METAMAGIC"));
metamagic2.setName("MM2");
metamagic2.put(StringKey.KEY_NAME, "MM2");
metamagic2.setCDOMCategory(AbilityCategory.FEAT);
final Ability metamagic3 = new Ability();
metamagic3.addToListFor(ListKey.TYPE, Type.getConstant("METAMAGIC"));
metamagic3.setName("MM3");
metamagic3.put(StringKey.KEY_NAME, "MM3");
metamagic3.setCDOMCategory(AbilityCategory.FEAT);
final Ability item1 = new Ability();
item1.addToListFor(ListKey.TYPE, Type.getConstant("ItemCreation"));
item1.setName("IC1");
item1.put(StringKey.KEY_NAME, "IC1");
item1.setCDOMCategory(AbilityCategory.FEAT);
final Ability item2 = new Ability();
item2.addToListFor(ListKey.TYPE, Type.getConstant("ItemCreation"));
item2.setName("IC2");
item2.put(StringKey.KEY_NAME, "IC2");
item2.setCDOMCategory(AbilityCategory.FEAT);
final Ability item3 = new Ability();
item3.addToListFor(ListKey.TYPE, Type.getConstant("ItemCreation"));
item3.setName("IC3");
item3.put(StringKey.KEY_NAME, "IC3");
item3.setCDOMCategory(AbilityCategory.FEAT);
final PlayerCharacter character = getCharacter();
final PreAbilityParser producer = new PreAbilityParser();
final Prerequisite prereq = producer.parse("FEAT", "3,TYPE=Metamagic,TYPE=ItemCreation", false, false);
final PreMult test = new PreMult();
int passes = test.passes(prereq, character, null);
assertEquals("No feats should not pass", 0, passes);
addAbility(AbilityCategory.FEAT, metamagic1);
passes = test.passes(prereq, character, null);
assertEquals("One feat should not pass", 0, passes);
addAbility(AbilityCategory.FEAT, metamagic2);
passes = test.passes(prereq, character, null);
assertEquals("Two feats should not pass", 0, passes);
addAbility(AbilityCategory.FEAT, metamagic3);
passes = test.passes(prereq, character, null);
assertEquals("Three feats should pass", 1, passes);
removeAbility(AbilityCategory.FEAT, metamagic3);
addAbility(AbilityCategory.FEAT, item1);
passes = test.passes(prereq, character, null);
assertEquals("Three feats should pass", 1, passes);
addAbility(AbilityCategory.FEAT, item2);
addAbility(AbilityCategory.FEAT, item3);
addAbility(AbilityCategory.FEAT, metamagic3);
passes = test.passes(prereq, character, null);
assertEquals("Six feats should pass", 1, passes);
removeAbility(AbilityCategory.FEAT, metamagic3);
removeAbility(AbilityCategory.FEAT, item3);
removeAbility(AbilityCategory.FEAT, item2);
removeAbility(AbilityCategory.FEAT, item1);
removeAbility(AbilityCategory.FEAT, metamagic2);
removeAbility(AbilityCategory.FEAT, metamagic1);
}
use of pcgen.core.PlayerCharacter in project pcgen by PCGen.
the class PrePCLevelTest method testLevel.
/**
* Test that Level works
* @throws Exception
*/
public void testLevel() throws Exception {
final PlayerCharacter character = getCharacter();
character.incrementClassLevel(1, myClass, true);
myClass = character.getClassKeyed("MY_CLASS");
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PREPCLEVEL:MIN=2");
assertFalse("Character is not 2nd level", PrereqHandler.passes(prereq, character, null));
character.incrementClassLevel(1, myClass, true);
assertTrue("Character has 2 levels", PrereqHandler.passes(prereq, character, null));
character.incrementClassLevel(1, myClass, true);
prereq = factory.parse("PREPCLEVEL:MIN=2,MAX=3");
assertTrue("Character is 2nd or 3rd level", PrereqHandler.passes(prereq, character, null));
character.incrementClassLevel(1, myClass, true);
assertFalse("Character is not 2nd or 3rd level", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("!PREPCLEVEL:MIN=2,MAX=3");
assertTrue("Character is 2nd or 3rd level", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("!PREPCLEVEL:MIN=4");
assertFalse("Character is 4 or higher level", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("!PREPCLEVEL:MAX=3");
assertTrue("Character is 3rd or higher level", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.core.PlayerCharacter in project pcgen by PCGen.
the class PrePCLevelTest method testHD.
/**
* Test that HD are counted
* @throws Exception
*/
public void testHD() throws Exception {
final PlayerCharacter character = getCharacter();
character.incrementClassLevel(2, myClass, true);
myClass = character.getClassKeyed("MY_CLASS");
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PREPCLEVEL:MIN=4");
assertFalse("Character doesn't have 4 levels", PrereqHandler.passes(prereq, character, null));
character.setRace(race);
assertFalse("Character has 4 levels", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("!PREPCLEVEL:MIN=5");
assertTrue("Character doesn't have 5 or more levels", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("!PREPCLEVEL:MIN=3");
assertTrue("Character doesn't have 5 or more levels", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("!PREPCLEVEL:MAX=3");
assertFalse("Character doesn't have 3 or more levels", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("!PREPCLEVEL:MIN=6,MAX=7");
assertTrue("Character doesn't have between 6 and 7 levels", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREPCLEVEL:MIN=4,MAX=6");
assertFalse("Character doesn't have 4-6 levels", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREPCLEVEL:MIN=6,MAX=7");
assertFalse("Character doesn't have 6-7 levels", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREPCLEVEL:MAX=7");
assertTrue("Character has no more than 5 levels", PrereqHandler.passes(prereq, character, null));
character.incrementClassLevel(4, myClass, true);
prereq = factory.parse("PREPCLEVEL:MAX=6");
assertTrue("Character has no more than 6 levels", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.core.PlayerCharacter in project pcgen by PCGen.
the class PreRaceTest method testFail.
/**
* Test to ensure that we return false when races don't match.
*
* @throws Exception
*/
public void testFail() throws Exception {
final PlayerCharacter character = getCharacter();
final Race race = new Race();
race.setName("Human");
Globals.getContext().getReferenceContext().importObject(race);
character.setRace(race);
final Prerequisite prereq = new Prerequisite();
prereq.setKind("race");
prereq.setKey("Orc");
prereq.setOperator(PrerequisiteOperator.EQ);
final boolean passes = PrereqHandler.passes(prereq, character, null);
assertFalse(passes);
}
use of pcgen.core.PlayerCharacter in project pcgen by PCGen.
the class PreLevelMaxTest method testHD.
/**
* Test that HD are counted
* @throws Exception
*/
public void testHD() throws Exception {
final PlayerCharacter character = getCharacter();
character.incrementClassLevel(2, myClass, true);
myClass = character.getClassKeyed("MY_CLASS");
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PRELEVELMAX:3");
assertTrue("Character doesn't have 4 levels", PrereqHandler.passes(prereq, character, null));
character.setRace(race);
assertTrue("Character has 4 levels", PrereqHandler.passes(prereq, character, null));
}
Aggregations