use of pcgen.core.PlayerCharacter in project pcgen by PCGen.
the class PreLevelMaxTest 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("PRELEVELMAX:1");
assertTrue("Character is not 2nd level", PrereqHandler.passes(prereq, character, null));
character.incrementClassLevel(1, myClass, true);
assertFalse("Character has 2 levels", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.core.PlayerCharacter in project pcgen by PCGen.
the class PreLevelMaxTest method testPCLevel.
/**
* Make sure BONUS:PCLEVEL is not counted
* @throws Exception
*/
public void testPCLevel() throws Exception {
final PlayerCharacter character = getCharacter();
LoadContext context = Globals.getContext();
character.incrementClassLevel(2, myClass, true);
myClass = character.getClassKeyed("MY_CLASS");
character.setRace(race);
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PRELEVELMAX:5");
final BonusObj levelBonus = Bonus.newBonus(context, "PCLEVEL|MY_CLASS|2");
myClass.addToListFor(ListKey.BONUS, levelBonus);
character.calcActiveBonuses();
assertTrue("Character has only 4 levels", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.core.PlayerCharacter in project pcgen by PCGen.
the class PreLevelTest method testPCLevel.
/**
* Make sure BONUS:PCLEVEL is not counted
* @throws Exception
*/
public void testPCLevel() throws Exception {
final PlayerCharacter character = getCharacter();
LoadContext context = Globals.getContext();
character.incrementClassLevel(2, myClass, true);
myClass = character.getClassKeyed("MY_CLASS");
character.setRace(race);
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PRELEVEL:MIN=6");
final BonusObj levelBonus = Bonus.newBonus(context, "PCLEVEL|MY_CLASS|2");
myClass.addToListFor(ListKey.BONUS, levelBonus);
character.calcActiveBonuses();
assertFalse("Character has only 4 levels", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PRELEVEL:MAX=6");
assertTrue("Character has only 4 levels", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("!PRELEVEL:MAX=6");
assertFalse("Character is less than 6 levels", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("!PRELEVEL:MIN=5");
assertTrue("Character has only 4 levels", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PRELEVEL:MIN=4,MAX=6");
assertTrue("Character has 4-6 levels", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PRELEVEL:MIN=6,MAX=8");
assertFalse("Character does not have 6-8 levels", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("!PRELEVEL:MIN=6,MAX=8");
assertTrue("Character is not 6-8 levels", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.core.PlayerCharacter in project pcgen by PCGen.
the class PreLevelTest 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("PRELEVEL: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("PRELEVEL: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("!PRELEVEL:MIN=2,MAX=3");
assertTrue("Character is 2nd or 3rd level", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("!PRELEVEL:MIN=4");
assertFalse("Character is 4 or higher level", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("!PRELEVEL: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 PreEquipSecondaryTest method testNotEquipped.
/**
* Verify that negated PREEQUIPSECONDARY tests work.
*/
public void testNotEquipped() throws Exception {
final PlayerCharacter character = getCharacter();
final Equipment longsword = new Equipment();
longsword.setName("Longsword");
final Equipment dagger = new Equipment();
dagger.setName("Dagger");
character.addEquipment(longsword);
longsword.setIsEquipped(true, character);
longsword.setLocation(EquipmentLocation.EQUIPPED_SECONDARY);
character.doAfavorForAunitTestThatIgnoresEquippingRules();
final Prerequisite prereqDaggerNotSec = PreParserFactory.getInstance().parse("!PREEQUIPSECONDARY:1,Dagger");
assertTrue("Dagger not equipped", PrereqHandler.passes(prereqDaggerNotSec, character, null));
character.addEquipment(dagger);
dagger.setIsEquipped(true, character);
dagger.setLocation(EquipmentLocation.EQUIPPED_PRIMARY);
assertTrue("Dagger not equipped", PrereqHandler.passes(prereqDaggerNotSec, character, null));
final Prerequisite prereqLongswordNotSec = PreParserFactory.getInstance().parse("!PREEQUIPSECONDARY:1,Longsword");
assertFalse("Longsword equipped", PrereqHandler.passes(prereqLongswordNotSec, character, null));
}
Aggregations