Search in sources :

Example 86 with Ability

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));
}
Also used : Ability(pcgen.core.Ability) PlayerCharacter(pcgen.core.PlayerCharacter) ParseResult(pcgen.rules.persistence.token.ParseResult) StringToken(plugin.lsttokens.choose.StringToken)

Example 87 with Ability

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();
}
Also used : Ability(pcgen.core.Ability) PlayerCharacter(pcgen.core.PlayerCharacter) BonusObj(pcgen.core.bonus.BonusObj) ArrayList(java.util.ArrayList) Aspect(pcgen.cdom.helper.Aspect) Prerequisite(pcgen.core.prereq.Prerequisite)

Example 88 with Ability

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;
}
Also used : Ability(pcgen.core.Ability)

Example 89 with Ability

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;
}
Also used : Ability(pcgen.core.Ability) ArrayList(java.util.ArrayList) CDOMReference(pcgen.cdom.base.CDOMReference)

Example 90 with Ability

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");
}
Also used : Ability(pcgen.core.Ability) AbilityCategory(pcgen.core.AbilityCategory) Test(org.junit.Test)

Aggregations

Ability (pcgen.core.Ability)279 CNAbility (pcgen.cdom.content.CNAbility)128 AbilityCategory (pcgen.core.AbilityCategory)60 PlayerCharacter (pcgen.core.PlayerCharacter)54 Test (org.junit.Test)46 ArrayList (java.util.ArrayList)43 CNAbilitySelection (pcgen.cdom.helper.CNAbilitySelection)25 ParseResult (pcgen.rules.persistence.token.ParseResult)21 HashMapToList (pcgen.base.util.HashMapToList)15 PCClass (pcgen.core.PCClass)15 Spell (pcgen.core.spell.Spell)15 StringTokenizer (java.util.StringTokenizer)14 TestContext (plugin.lsttokens.editcontext.testsupport.TestContext)13 LoadContext (pcgen.rules.context.LoadContext)12 SpecialAbility (pcgen.core.SpecialAbility)11 CharacterSpell (pcgen.core.character.CharacterSpell)11 PreParserFactory (pcgen.persistence.lst.prereq.PreParserFactory)11 List (java.util.List)10 CDOMObject (pcgen.cdom.base.CDOMObject)10 CDOMSingleRef (pcgen.cdom.reference.CDOMSingleRef)10