use of pcgen.core.Ability in project pcgen by PCGen.
the class Gui2InfoFactoryTest method testGetChoices.
/**
* Test the getChoices method with text choices.
*/
public void testGetChoices() {
PlayerCharacter pc = getCharacter();
Gui2InfoFactory ca = new Gui2InfoFactory(pc);
Ability choiceAbility = TestHelper.makeAbility("Skill Focus", AbilityCategory.FEAT, "General");
choiceAbility.put(ObjectKey.MULTIPLE_ALLOWED, Boolean.TRUE);
StringToken st = new plugin.lsttokens.choose.StringToken();
ParseResult pr = st.parseToken(Globals.getContext(), choiceAbility, "SKILL|Perception|Acrobatics");
assertTrue(pr.passed());
Globals.getContext().commit();
pcgenFinalize(choiceAbility, "Perception", pc, AbilityCategory.FEAT);
assertEquals("Incorrect single choice", "Perception", ca.getChoices(choiceAbility));
pcgenFinalize(choiceAbility, "Acrobatics", pc, AbilityCategory.FEAT);
assertEquals("Incorrect multiple choice", "Acrobatics, Perception", ca.getChoices(choiceAbility));
}
use of pcgen.core.Ability in project pcgen by PCGen.
the class AbilityTokenTest method setUp.
/*
* @see TestCase#setUp()
*/
@Override
protected void setUp() throws Exception {
super.setUp();
PlayerCharacter character = getCharacter();
// Make some ability categories and add them to the game mode
Ability ab1 = TestHelper.makeAbility("Perform (Dance)", AbilityCategory.FEAT, "General.Fighter");
ab1.put(ObjectKey.MULTIPLE_ALLOWED, Boolean.FALSE);
ab1.put(ObjectKey.VISIBILITY, Visibility.DEFAULT);
List<Aspect> colourList = new ArrayList<>();
colourList.add(new Aspect("Colour", "Green"));
ab1.addToMapFor(MapKey.ASPECT, AspectName.getConstant("Colour"), colourList);
List<Aspect> sizeList = new ArrayList<>();
sizeList.add(new Aspect("Size", "L"));
ab1.addToMapFor(MapKey.ASPECT, AspectName.getConstant("Size"), sizeList);
List<Aspect> shapeList = new ArrayList<>();
Aspect cube = new Aspect("Shape", "Cube");
Prerequisite prereq = new Prerequisite();
prereq.setKind("ALIGN");
prereq.setKey("LG");
prereq.setOperator(PrerequisiteOperator.EQ);
cube.addPrerequisite(prereq);
shapeList.add(cube);
shapeList.add(new Aspect("Shape", "Icosahedron"));
ab1.addToMapFor(MapKey.ASPECT, AspectName.getConstant("Shape"), shapeList);
List<Aspect> sidesList = new ArrayList<>();
sidesList.add(new Aspect("Sides", "20"));
ab1.addToMapFor(MapKey.ASPECT, AspectName.getConstant("Sides"), sidesList);
List<Aspect> ageList = new ArrayList<>();
ageList.add(new Aspect("Age In Years", "2000"));
ab1.addToMapFor(MapKey.ASPECT, AspectName.getConstant("Age In Years"), ageList);
addAbility(AbilityCategory.FEAT, ab1);
TestHelper.makeSkill("Bluff", "Charisma", cha, true, SkillArmorCheck.NONE);
TestHelper.makeSkill("Listen", "Wisdom", wis, true, SkillArmorCheck.NONE);
skillFocus = TestHelper.makeAbility("Skill Focus", AbilityCategory.FEAT, "General");
BonusObj aBonus = Bonus.newBonus(Globals.getContext(), "SKILL|LIST|3");
if (aBonus != null) {
skillFocus.addToListFor(ListKey.BONUS, aBonus);
}
skillFocus.put(ObjectKey.MULTIPLE_ALLOWED, true);
Globals.getContext().unconditionallyProcess(skillFocus, "CHOOSE", "SKILL|ALL");
AbstractCharacterTestCase.applyAbility(character, AbilityCategory.FEAT, skillFocus, "KEY_Bluff");
AbstractCharacterTestCase.applyAbility(character, AbilityCategory.FEAT, skillFocus, "KEY_Listen");
character.calcActiveBonuses();
}
use of pcgen.core.Ability in project pcgen by PCGen.
the class AbilityTokenTest method construct.
protected CDOMObject construct(LoadContext loadContext, String one) {
Ability obj = loadContext.getReferenceContext().constructCDOMObject(Ability.class, one);
loadContext.getReferenceContext().reassociateCategory(AbilityCategory.FEAT, obj);
return obj;
}
use of pcgen.core.Ability in project pcgen by PCGen.
the class AbilityTokenTest method createSingle.
private List<CDOMReference<Ability>> createSingle(String name) {
List<CDOMReference<Ability>> refs = new ArrayList<>();
Ability obj = primaryContext.getReferenceContext().constructCDOMObject(Ability.class, name);
primaryContext.getReferenceContext().reassociateCategory(AbilityCategory.FEAT, obj);
CDOMDirectSingleRef<Ability> ar = CDOMDirectSingleRef.getRef(obj);
refs.add(ar);
if (name.indexOf('(') != -1) {
List<String> choices = new ArrayList<>();
AbilityUtilities.getUndecoratedName(name, choices);
assertEquals(1, choices.size());
ar.setChoice(choices.get(0));
}
return refs;
}
use of pcgen.core.Ability in project pcgen by PCGen.
the class QualifyTokenTest method testRoundRobinAbilitySpell.
@Test
public void testRoundRobinAbilitySpell() throws PersistenceLayerException {
AbilityCategory pac = primaryContext.getReferenceContext().constructCDOMObject(AbilityCategory.class, "NEWCAT");
AbilityCategory sac = secondaryContext.getReferenceContext().constructCDOMObject(AbilityCategory.class, "NEWCAT");
Ability ab = primaryContext.getReferenceContext().constructCDOMObject(Ability.class, "Abil3");
primaryContext.getReferenceContext().reassociateCategory(pac, ab);
ab = secondaryContext.getReferenceContext().constructCDOMObject(Ability.class, "Abil3");
secondaryContext.getReferenceContext().reassociateCategory(sac, ab);
primaryContext.getReferenceContext().constructCDOMObject(Spell.class, "Lightning Bolt");
secondaryContext.getReferenceContext().constructCDOMObject(Spell.class, "Lightning Bolt");
runRoundRobin("ABILITY=NEWCAT|Abil3", "SPELL|Lightning Bolt");
}
Aggregations