use of pcgen.core.AbilityCategory in project pcgen by PCGen.
the class ExportHandlerTest method testExpressionOutput.
public void testExpressionOutput() throws IOException {
LoadContext context = Globals.getContext();
Ability dummyFeat = new Ability();
dummyFeat.setName("DummyFeat");
dummyFeat.setCDOMCategory(AbilityCategory.FEAT);
final PlayerCharacter pc = getCharacter();
// Create a variable
dummyFeat.put(VariableKey.getConstant("NegLevels"), FormulaFactory.getFormulaFor(0));
// Create a bonus to it
Ability dummyFeat2 = new Ability();
dummyFeat2.setName("DummyFeat2");
dummyFeat2.setCDOMCategory(AbilityCategory.FEAT);
final BonusObj aBonus = Bonus.newBonus(context, "VAR|NegLevels|7");
if (aBonus != null) {
dummyFeat2.addToListFor(ListKey.BONUS, aBonus);
}
AbilityCategory cat = context.getReferenceContext().constructCDOMObject(AbilityCategory.class, "Maneuver");
AbilityCategory cat2 = context.getReferenceContext().constructCDOMObject(AbilityCategory.class, "Maneuver(Special)");
Ability dummyFeat3 = new Ability();
dummyFeat3.setName("DummyFeat3");
dummyFeat3.setCDOMCategory(cat);
Ability dummyFeat4 = new Ability();
dummyFeat4.setName("DummyFeat4");
dummyFeat4.setCDOMCategory(cat2);
addAbility(AbilityCategory.FEAT, dummyFeat);
addAbility(AbilityCategory.FEAT, dummyFeat2);
addAbility(cat, dummyFeat3);
addAbility(cat2, dummyFeat4);
assertEquals("Unsigned output", "7", evaluateToken("VAR.NegLevels.INTVAL", pc));
assertEquals("Signed output", "+7", evaluateToken("VAR.NegLevels.INTVAL.SIGN", pc));
String tok = "";
tok = "count(\"ABILITIES\", \"CATEGORY=Maneuver\")";
// if this evaluates math wise, the values should be string "1.0"
assertFalse("Token: |" + tok + "| != 1.0: ", evaluateToken(tok, pc).equals("1.0"));
tok = "VAR.count(\"ABILITIES\", \"CATEGORY=Maneuver\")";
assertTrue("Token: |" + tok + "| == 1.0: ", evaluateToken(tok, pc).equals("1.0"));
tok = "COUNT[\"ABILITIES\", \"CATEGORY=Maneuver\"]";
assertFalse("Token: |" + tok + "| != 1.0: ", evaluateToken(tok, pc).equals("1.0"));
tok = "count(\"ABILITIES\", \"CATEGORY=Maneuver(Special)\")";
assertFalse("Token: |" + tok + "| != 1.0 ", evaluateToken(tok, pc).equals("1.0"));
tok = "${count(\"ABILITIES\", \"CATEGORY=Maneuver(Special)\")+5}";
assertFalse("Token: |" + tok + "| == 5.0 ", evaluateToken(tok, pc).equals("5.0"));
tok = "${count(\"ABILITIES\", \"CATEGORY=Maneuver(Special)\")+5}";
assertTrue("Token: |" + tok + "| != 6.0 ", evaluateToken(tok, pc).equals("6.0"));
tok = "${(count(\"ABILITIES\", \"CATEGORY=Maneuver(Special)\")+5)/3}";
assertFalse("Token: |" + tok + "| == 3.0 ", evaluateToken(tok, pc).equals("3.0"));
tok = "${(count(\"ABILITIES\", \"CATEGORY=Maneuver(Special)\")+5)/3}";
assertTrue("Token: |" + tok + "| != 2.0 ", evaluateToken(tok, pc).equals("2.0"));
}
use of pcgen.core.AbilityCategory in project pcgen by PCGen.
the class ForwardrefTokenTest method testRoundRobinAbilitySpell.
@Test
public void testRoundRobinAbilitySpell() throws PersistenceLayerException {
primaryContext.getReferenceContext().constructCDOMObject(Spell.class, "Lightning Bolt");
secondaryContext.getReferenceContext().constructCDOMObject(Spell.class, "Lightning Bolt");
AbilityCategory newCatp = primaryContext.getReferenceContext().constructCDOMObject(AbilityCategory.class, "NEWCAT");
AbilityCategory newCats = secondaryContext.getReferenceContext().constructCDOMObject(AbilityCategory.class, "NEWCAT");
Ability a = primaryContext.getReferenceContext().constructCDOMObject(Ability.class, "Abil3");
primaryContext.getReferenceContext().reassociateCategory(newCatp, a);
Ability b = secondaryContext.getReferenceContext().constructCDOMObject(Ability.class, "Abil3");
secondaryContext.getReferenceContext().reassociateCategory(newCats, b);
runRoundRobin("ABILITY=NEWCAT|Abil3", "SPELL|Lightning Bolt");
}
Aggregations