use of pcgen.rules.context.LoadContext 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.rules.context.LoadContext 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.rules.context.LoadContext in project pcgen by PCGen.
the class PreEquipTwoWeaponTest method testWield.
/**
* Test wield category tests
* @throws Exception
*/
public void testWield() throws Exception {
final PlayerCharacter character = getCharacter();
final Race race = new Race();
race.setName("Test Race");
CDOMDirectSingleRef<SizeAdjustment> mediumRef = CDOMDirectSingleRef.getRef(medium);
CDOMDirectSingleRef<SizeAdjustment> largeRef = CDOMDirectSingleRef.getRef(large);
race.put(FormulaKey.SIZE, new FixedSizeFormula(mediumRef));
character.setRace(race);
LoadContext context = Globals.getContext();
final Equipment longsword = new Equipment();
longsword.setName("Longsword");
character.addEquipment(longsword);
longsword.setIsEquipped(true, character);
longsword.setLocation(EquipmentLocation.EQUIPPED_TWO_HANDS);
character.doAfavorForAunitTestThatIgnoresEquippingRules();
Prerequisite prereq = new Prerequisite();
prereq.setKind("equiptwoweapon");
prereq.setKey("WIELDCATEGORY=OneHanded");
prereq.setOperand("1");
prereq.setOperator(PrerequisiteOperator.EQ);
// Test 3.0 Style
longsword.put(ObjectKey.SIZE, mediumRef);
longsword.put(ObjectKey.BASESIZE, mediumRef);
assertTrue("Weapon is M therefore OneHanded", PrereqHandler.passes(prereq, character, null));
longsword.put(ObjectKey.SIZE, largeRef);
longsword.put(ObjectKey.BASESIZE, largeRef);
assertFalse("Weapon is L therefore TwoHanded", PrereqHandler.passes(prereq, character, null));
// Test 3.5 style
longsword.put(ObjectKey.SIZE, mediumRef);
longsword.put(ObjectKey.BASESIZE, mediumRef);
longsword.put(ObjectKey.WIELD, context.getReferenceContext().silentlyGetConstructedCDOMObject(WieldCategory.class, "TwoHanded"));
assertFalse("Weapon is TwoHanded", PrereqHandler.passes(prereq, character, null));
longsword.put(ObjectKey.WIELD, context.getReferenceContext().silentlyGetConstructedCDOMObject(WieldCategory.class, "OneHanded"));
assertTrue("Weapon is OneHanded", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.rules.context.LoadContext in project pcgen by PCGen.
the class PreFactSetTest method additionalSetUp.
@Override
protected void additionalSetUp() throws Exception {
LoadContext context = Globals.getContext();
BuildUtilities.createFactSet(context, "PANTHEON", Deity.class);
super.additionalSetUp();
}
use of pcgen.rules.context.LoadContext in project pcgen by PCGen.
the class PreFactTest method additionalSetUp.
@Override
protected void additionalSetUp() throws Exception {
LoadContext context = Globals.getContext();
BuildUtilities.createFact(context, "Abb", Race.class);
super.additionalSetUp();
}
Aggregations