Search in sources :

Example 36 with AbilityCategory

use of pcgen.core.AbilityCategory in project pcgen by PCGen.

the class VFeatToken method getAbilityList.

/**
	 * @see pcgen.io.exporttoken.AbilityToken#getAbilityList(pcgen.core.PlayerCharacter, pcgen.core.AbilityCategory)
	 */
@Override
protected MapToList<Ability, CNAbility> getAbilityList(PlayerCharacter pc, final AbilityCategory aCategory) {
    final MapToList<Ability, CNAbility> listOfAbilities = new HashMapToList<>();
    Collection<AbilityCategory> allCats = SettingsHandler.getGame().getAllAbilityCategories();
    for (AbilityCategory aCat : allCats) {
        if (aCat.getParentCategory().equals(aCategory)) {
            for (CNAbility cna : pc.getPoolAbilities(aCat, Nature.VIRTUAL)) {
                listOfAbilities.addToListFor(cna.getAbility(), cna);
            }
        }
    }
    return listOfAbilities;
}
Also used : Ability(pcgen.core.Ability) CNAbility(pcgen.cdom.content.CNAbility) CNAbility(pcgen.cdom.content.CNAbility) HashMapToList(pcgen.base.util.HashMapToList) AbilityCategory(pcgen.core.AbilityCategory)

Example 37 with AbilityCategory

use of pcgen.core.AbilityCategory in project pcgen by PCGen.

the class AspectTest method testSimpleListReplacement.

/**
	 * Tests simple %LIST replacement.
	 */
public void testSimpleListReplacement() {
    final Ability pobj = TestHelper.makeAbility("dummy", AbilityCategory.FEAT, "Foo");
    Globals.getContext().unconditionallyProcess(pobj, "CHOOSE", "LANG|ALL");
    Globals.getContext().unconditionallyProcess(pobj, "MULT", "YES");
    Globals.getContext().getReferenceContext().constructCDOMObject(Language.class, "Foo");
    PlayerCharacter pc = getCharacter();
    final Aspect aspect = new Aspect(ASPECT_NAME, "%1");
    aspect.addVariable("%LIST");
    assertEquals("", aspect.getAspectText(pc, buildMap(pobj, AbilityCategory.FEAT, Nature.NORMAL)));
    AbilityCategory category = AbilityCategory.FEAT;
    CNAbility cna = pcgenFinalize(pobj, "Foo", pc, category);
    assertEquals("Foo", aspect.getAspectText(pc, Collections.singletonList(cna)));
}
Also used : Ability(pcgen.core.Ability) CNAbility(pcgen.cdom.content.CNAbility) CNAbility(pcgen.cdom.content.CNAbility) PlayerCharacter(pcgen.core.PlayerCharacter) AbilityCategory(pcgen.core.AbilityCategory)

Example 38 with AbilityCategory

use of pcgen.core.AbilityCategory in project pcgen by PCGen.

the class CountCommandTest method testCountAbilitiesByKey.

public void testCountAbilitiesByKey() {
    final PlayerCharacter character = getCharacter();
    AbilityCategory gCat = Globals.getContext().getReferenceContext().constructNowIfNecessary(AbilityCategory.class, "CLERICAL");
    final Ability ab = TestHelper.makeAbility("Eat Burger", "CLERICAL", "Clerical.General");
    ab.put(ObjectKey.MULTIPLE_ALLOWED, Boolean.TRUE);
    Globals.getContext().unconditionallyProcess(ab, "CHOOSE", "STRING|munch|devour|nibble|ignore");
    // now the tests
    final StringBuilder sB = new StringBuilder(100);
    sB.append("count(\"ABILITIES\",");
    sB.append("\"KEY=KEY_Eat Burger\")");
    final String countByKey = sB.toString();
    is(character.getVariableValue(countByKey, ""), eq(0.0, 0.1), countByKey + " no choices");
    AbstractCharacterTestCase.applyAbility(character, gCat, ab, "munch");
    is(character.getVariableValue(countByKey, ""), eq(1.0, 0.1), countByKey + " one choice");
    AbstractCharacterTestCase.applyAbility(character, gCat, ab, "devour");
    character.setDirty(true);
    is(character.getVariableValue(countByKey, ""), eq(2.0, 0.1), countByKey + " two choices");
    AbstractCharacterTestCase.applyAbility(character, gCat, ab, "nibble");
    character.setDirty(true);
    is(character.getVariableValue(countByKey, ""), eq(3.0, 0.1), countByKey + " three choices");
    String countKeyChoice = "count(\"ABILITIES\",\"KEY=KEY_Eat Burger(munch)\")";
    is(character.getVariableValue(countKeyChoice, ""), eq(1.0, 0.1), countKeyChoice + " chosen");
    String countStr = "count(\"ABILITIES\",\"KEY=KEY_Turning\")";
    is(character.getVariableValue(countStr, ""), eq(1.0, 0.1), countStr + " single application");
}
Also used : Ability(pcgen.core.Ability) PlayerCharacter(pcgen.core.PlayerCharacter) AbilityCategory(pcgen.core.AbilityCategory)

Example 39 with AbilityCategory

use of pcgen.core.AbilityCategory in project pcgen by PCGen.

the class CountCommandTest method testCountAbilitiesByName.

//    /* Test the cast where we only have the type os count, i.e. all Abilities */   
//    public void testCountAbilities01()
//    {
//        final PlayerCharacter character = getCharacter();
//
//        is(character.getVariableValue("count(\"ABILITIES\")",""),
//           eq(15.0, 0.1),
//           "count(\"ABILITIES\")");
//    }
//
//    /* Test case 02 count all of the abilities of category FEAT */
//    public void testCountAbilities02()
//    {
//        final PlayerCharacter character = getCharacter();
//
//        is(character.getVariableValue("count(\"ABILITIES\",\"CATEGORY=FEAT\")",""),
//           eq(7.0, 0.1),
//           "count(\"ABILITIES\",\"CATEGORY=FEAT\")");
//    }
//
//    /* Test case 03 count all of the abilities of category BARDIC */
//    public void testCountAbilities03()
//    {
//        final PlayerCharacter character = getCharacter();
//
//        is(character.getVariableValue("count(\"ABILITIES\",\"CATEGORY=BARDIC\")",""),
//           eq(6.0, 0.1),
//           "count(\"ABILITIES\",\"CATEGORY=BARDIC\")");
//    }
//
//    /* Test case 04 count all of the abilities of category CLERICAL */
//    public void testCountAbilities04()
//    {
//        final PlayerCharacter character = getCharacter();
//
//        is(character.getVariableValue("count(\"ABILITIES\",\"CATEGORY=CLERICAL\")",""),
//           eq(2.0, 0.1),
//           "count(\"ABILITIES\",\"CATEGORY=CLERICAL\")");
//    }
//
//    /* Test case 05 count all of the abilities of category FEAT _and_ BARDIC (should be zero) */
//    public void testCountAbilities05()
//    {
//        final PlayerCharacter character = getCharacter();
//
//        is(character.getVariableValue("count(\"ABILITIES\",\"CATEGORY=FEAT\",\"CATEGORY=BARDIC\")",""),
//           eq(0.0, 0.1),
//           "count(\"ABILITIES\",\"CATEGORY=FEAT\",\"CATEGORY=BARDIC\")");
//    }
//
//    /* Test case 06 count all of the abilities of category FEAT _and_ BARDIC using the
//     * explicit [and], this should still be zero */
//    public void testCountAbilities06()
//    {
//        final PlayerCharacter character = getCharacter();
//
//        is(character.getVariableValue("count(\"ABILITIES\",\"CATEGORY=FEAT[and]CATEGORY=BARDIC\")",""),
//           eq(0.0, 0.1),
//           "count(\"ABILITIES\",\"CATEGORY=FEAT[and]CATEGORY=BARDIC\")");
//    }
//
//    /* Test case 07 count all of the abilities of category FEAT _or_ BARDIC */
//    public void testCountAbilities07()
//    {
//        final PlayerCharacter character = getCharacter();
//
//        is(character.getVariableValue("count(\"ABILITIES\",\"CATEGORY=FEAT[or]CATEGORY=BARDIC\")",""),
//           eq(13.0, 0.1),
//           "count(\"ABILITIES\",\"CATEGORY=FEAT[or]CATEGORY=BARDIC\")");
//    }
//
//
//    /* Test case 08 count all of the abilities of category FEAT _or_ BARDIC _or_ CLERICAL */
//    public void testCountAbilities08()
//    {
//        final PlayerCharacter character = getCharacter();
//
//        is(character.getVariableValue("count(\"ABILITIES\",\"CATEGORY=FEAT[or]CATEGORY=BARDIC[or]CATEGORY=CLERICAL\")",""),
//           eq(15.0, 0.1),
//           "count(\"ABILITIES\",\"CATEGORY=FEAT[or]CATEGORY=BARDIC[or]CATEGORY=CLERICAL\")");
//    }
//
//
//
//    /* Test case 09 count all of the abilities with visibility DEFAULT */
//    public void testCountAbilities09()
//    {
//        final PlayerCharacter character = getCharacter();
//
//        is(character.getVariableValue("count(\"ABILITIES\",\"VISIBILITY=DEFAULT\")",""),
//           eq(9.0, 0.1),
//           "count(\"ABILITIES\",\"VISIBILITY=DEFAULT\")");
//    }
//
//
//    /* Test case 10 count all of the abilities with visibility OUTPUT_ONLY */
//    public void testCountAbilities10()
//    {
//        final PlayerCharacter character = getCharacter();
//
//        is(character.getVariableValue("count(\"ABILITIES\",\"VISIBILITY=OUTPUT_ONLY\")",""),
//           eq(3.0, 0.1),
//           "count(\"ABILITIES\",\"VISIBILITY=OUTPUT_ONLY\")");
//    }
//
//    /* Test case 11 count all of the abilities with visibility DISPLAY_ONLY */
//    public void testCountAbilities11()
//    {
//        final PlayerCharacter character = getCharacter();
//
//        is(character.getVariableValue("count(\"ABILITIES\",\"VISIBILITY=DISPLAY_ONLY\")",""),
//           eq(1.0, 0.1),
//           "count(\"ABILITIES\",\"VISIBILITY=DISPLAY_ONLY\")");
//    }
//
//    /* Test case 12 count all of the abilities with visibility HIDDEN */
//    public void testCountAbilities12()
//    {
//        final PlayerCharacter character = getCharacter();
//
//        is(character.getVariableValue("count(\"ABILITIES\",\"VISIBILITY=HIDDEN\")",""),
//           eq(2.0, 0.1),
//           "count(\"ABILITIES\",\"VISIBILITY=HIDDEN\")");
//    }
//
//    /* Test case 13 count all the Abilities of category FEAT with visibility DEFAULT */
//    public void testCountAbilities13()
//    {
//        final PlayerCharacter character = getCharacter();
//
//        is(character.getVariableValue("count(\"ABILITIES\",\"CATEGORY=FEAT\",\"VISIBILITY=DEFAULT\")",""),
//            eq(4.0, 0.1),
//            "count(\"ABILITIES\",\"CATEGORY=FEAT\",\"VISIBILITY=DEFAULT\")");
//    }
//
//    /* Test case 14 count all the Abilities in Categories FEAT or CLERICAL with visibility DEFAULT or OUTPUT_ONLY  */
//    public void testCountAbilities14()
//    {
//        final PlayerCharacter character = getCharacter();
//
//        is(character.getVariableValue("count(\"ABILITIES\",\"CATEGORY=FEAT[or]CATEGORY=CLERICAL\",\"VISIBILITY=DEFAULT[or]VISIBILITY=OUTPUT_ONLY\")",""),
//           eq(6.0, 0.1),
//           "count(\"ABILITIES\",\"CATEGORY=FEAT[or]CATEGORY=CLERICAL\",\"VISIBILITY=DEFAULT[or]VISIBILITY=OUTPUT_ONLY\")");
//    }
//
//
//    /*****************
//     * TYPE Tests
//     */
//
//
//	public void testCountAbilities15()
//	{
//		final PlayerCharacter character = getCharacter();
//
//		is(character.getVariableValue("count(\"ABILITIES\",\"TYPE=Fighter\")",""),
//		   eq(5.0, 0.1),
//		   "count(\"ABILITIES\",\"TYPE=Fighter\")");
//    }
//
//	public void testCountAbilities16()
//	{
//		final PlayerCharacter character = getCharacter();
//
//        is(character.getVariableValue("count(\"ABILITIES\",\"TYPE=General.Fighter\")", ""),
//           eq(5.0, 0.1),
//           "count(\"ABILITIES\",\"TYPE=General.Fighter\")");
//    }
//
//    public void testCountAbilities17()
//    {
//        final PlayerCharacter character = getCharacter();
//
//        is(character.getVariableValue("count(\"ABILITIES\",\"TYPE=General.Fighter[or]TYPE=Epic\")", ""),
//           eq(8.0, 0.1),
//           "count(\"ABILITIES\",\"TYPE=General.Fighter[or]TYPE=Epic\")");
//    }
//
//
//    public void testCountAbilities18()
//    {
//        final PlayerCharacter character = getCharacter();
//
//        is(character.getVariableValue("count(\"ABILITIES\",\"(TYPE=Performance[or]TYPE=Epic)[and]TYPE=SpecialAbility\")", ""),
//           eq(5.0, 0.1),
//           "count(\"ABILITIES\",\"(TYPE=Performance[or]TYPE=Epic)[and]TYPE=SpecialAbility\")");
//    }
//
//    public void testCountAbilities19()
//    {
//        final PlayerCharacter character = getCharacter();
//
//        is(character.getVariableValue("count(\"ABILITIES\",\"TYPE=Performance[or](TYPE=Epic[and]TYPE=SpecialAbility)\")", ""),
//           eq(7.0, 0.1),
//           "count(\"ABILITIES\",\"TYPE=Performance[or](TYPE=Epic[and]TYPE=SpecialAbility)\")");
//    }
//
//    public void testCountAbilities20()
//    {
//        final PlayerCharacter character = getCharacter();
//
//        is(character.getVariableValue("count(\"ABILITIES\",\"TYPE=Performance[or](TYPE=Epic.SpecialAbility)\")", ""),
//           eq(7.0, 0.1),
//           "count(\"ABILITIES\",\"TYPE=Performance[or](TYPE=Epic.SpecialAbility)\")");
//    }
//
//    /*****************
//     * NATURE Tests
//     */
//
//    public void testCountAbilities21()
//	{
//		final PlayerCharacter character = getCharacter();
//
//        is(character.getVariableValue("count(\"ABILITIES\",\"NATURE=AUTOMATIC\")",""),
//		   eq(0.0, 0.1),
//		   "count(\"ABILITIES\",\"NATURE=AUTOMATIC\")");
//    }
//
//	public void testCountAbilities22()
//	{
//		final PlayerCharacter character = getCharacter();
//
//    	is(character.getVariableValue("count(\"ABILITIES\",\"NATURE=VIRTUAL\")",""),
//		   eq(0.0, 0.1),
//		   "count(\"ABILITIES\",\"NATURE=VIRTUAL\")");
//    }
//
//	public void testCountAbilities23()
//	{
//		final PlayerCharacter character = getCharacter();
//
//		is(character.getVariableValue("count(\"ABILITIES\",\"NATURE=NORMAL\")",""),
//		   eq(15.0, 0.1),
//		   "count(\"ABILITIES\",\"NATURE=NORMAL\")");
//    }
//
//
//    /*****************
//     * NAME Tests
//     */
//
//    public void testCountAbilities24()
//    {
//        final PlayerCharacter character = getCharacter();
//
//        is(character.getVariableValue("count(\"ABILITIES\",\"NAME=Dance Monkey boy dance\")",""),
//           eq(0.0, 0.1),
//           "count(\"ABILITIES\",\"NAME=Dance Monkey boy dance\")");
//    }
//
//    public void testCountAbilities25()
//    {
//        final PlayerCharacter character = getCharacter();
//
//        is(character.getVariableValue("count(\"ABILITIES\",\"NAME=Improved Initiative\")",""),
//           eq(2.0, 0.1),
//           "count(\"ABILITIES\",\"NAME=Improved Initiative\")");
//    }
//
//    public void testCountAbilities26()
//    {
//        final PlayerCharacter character = getCharacter();
//
//        is(character.getVariableValue("count(\"ABILITIES\",\"NAME=Perform (Dance)\")",""),
//           eq(2.0, 0.1),
//           "count(\"ABILITIES\",\"NAME=Perform (Dance)\")");
//    }
//
//    public void testCountAbilities27()
//    {
//        final PlayerCharacter character = getCharacter();
//
//        is(character.getVariableValue("count(\"ABILITIES\",\"NAME=Epic Performance (Dance)\")",""),
//           eq(1.0, 0.1),
//           "count(\"ABILITIES\",\"NAME=Epic Performance (Dance)\")");
//    }
//
//    public void testCountAbilities28()
//    {
//        final PlayerCharacter character = getCharacter();
//
//        is(character.getVariableValue("count(\"ABILITIES\",\"NAME=Skill Focus (Profession (Basket weaving))[or]CATEGORY=FEAT\")",""),
//           eq(7.0, 0.1),
//           "count(\"ABILITIES\",\"NAME=Skill Focus (Profession (Basket weaving))[or]CATEGORY=FEAT\")");
//    }
//
//
//    public void testCountAbilities29()
//    {
//        final PlayerCharacter character = getCharacter();
//
//        final StringBuilder sB = new StringBuilder(100);
//
//        sB.append("count(\"ABILITIES\",");
//        sB.append("\"NAME=Turning");
//        sB.append("[or](((TYPE=Fighter)[and](TYPE=General))[and](NATURE=NORMAL))\")");
//
//        final String s = sB.toString();
//
//        is(character.getVariableValue(s,""), eq(6.0, 0.1), s);
//    }
public void testCountAbilitiesByName() {
    final PlayerCharacter character = getCharacter();
    AbilityCategory gCat = Globals.getContext().getReferenceContext().constructNowIfNecessary(AbilityCategory.class, "CLERICAL");
    final Ability ab = TestHelper.makeAbility("Eat Burger", "CLERICAL", "Clerical.General");
    ab.put(ObjectKey.MULTIPLE_ALLOWED, Boolean.TRUE);
    Globals.getContext().unconditionallyProcess(ab, "CHOOSE", "STRING|munch|devour|nibble|ignore");
    // now the tests
    final StringBuilder sB = new StringBuilder(100);
    sB.append("count(\"ABILITIES\",");
    sB.append("\"NAME=Eat Burger\")");
    final String s = sB.toString();
    is(character.getVariableValue(s, ""), eq(0.0, 0.1), s + " no choices");
    AbilityCategory category = gCat;
    pcgenFinalize(ab, "munch", character, category);
    is(character.getVariableValue(s, ""), eq(1.0, 0.1), s + " one choice");
    pcgenFinalize(ab, "devour", character, category);
    character.setDirty(true);
    is(character.getVariableValue(s, ""), eq(2.0, 0.1), s + " two choices");
    pcgenFinalize(ab, "nibble", character, category);
    assertEquals(3, character.getConsolidatedAssociationList(ab).size());
    character.setDirty(true);
    is(character.getVariableValue(s, ""), eq(3.0, 0.1), s + " three choices");
}
Also used : Ability(pcgen.core.Ability) PlayerCharacter(pcgen.core.PlayerCharacter) AbilityCategory(pcgen.core.AbilityCategory)

Example 40 with AbilityCategory

use of pcgen.core.AbilityCategory in project pcgen by PCGen.

the class CountDistinctCommandTest method testCountAbilitiesByKey.

public void testCountAbilitiesByKey() {
    final PlayerCharacter character = getCharacter();
    AbilityCategory gCat = Globals.getContext().getReferenceContext().constructNowIfNecessary(AbilityCategory.class, "CLERICAL");
    final Ability ab = TestHelper.makeAbility("Eat Burger", "CLERICAL", "Clerical.General");
    ab.put(ObjectKey.MULTIPLE_ALLOWED, Boolean.TRUE);
    // now the tests
    final StringBuilder sB = new StringBuilder(100);
    sB.append("countdistinct(\"ABILITIES\",");
    sB.append("\"KEY=KEY_Eat Burger\")");
    final String s = sB.toString();
    is(character.getVariableValue(s, ""), eq(0.0, 0.1), s + " no choices");
    Globals.getContext().unconditionallyProcess(ab, "CHOOSE", "STRING|munch|devour|nibble|ignore");
    AbstractCharacterTestCase.applyAbility(character, gCat, ab, "munch");
    is(character.getVariableValue(s, ""), eq(1.0, 0.1), s + " one choice");
    AbstractCharacterTestCase.applyAbility(character, gCat, ab, "devour");
    character.setDirty(true);
    is(character.getVariableValue(s, ""), eq(1.0, 0.1), s + " two choices");
    AbstractCharacterTestCase.applyAbility(character, gCat, ab, "nibble");
    character.setDirty(true);
    is(character.getVariableValue(s, ""), eq(1.0, 0.1), s + " three choices");
    String countKeyChoice = "countdistinct(\"ABILITIES\",\"KEY=KEY_Eat Burger(munch)\")";
    is(character.getVariableValue(countKeyChoice, ""), eq(1.0, 0.1), countKeyChoice + " chosen");
    String countStr = "countdistinct(\"ABILITIES\",\"KEY=KEY_Turning\")";
    is(character.getVariableValue(countStr, ""), eq(1.0, 0.1), countStr + " single application");
}
Also used : Ability(pcgen.core.Ability) PlayerCharacter(pcgen.core.PlayerCharacter) AbilityCategory(pcgen.core.AbilityCategory)

Aggregations

AbilityCategory (pcgen.core.AbilityCategory)72 Ability (pcgen.core.Ability)60 CNAbility (pcgen.cdom.content.CNAbility)34 HashMapToList (pcgen.base.util.HashMapToList)14 ArrayList (java.util.ArrayList)10 PlayerCharacter (pcgen.core.PlayerCharacter)10 StringTokenizer (java.util.StringTokenizer)9 Test (org.junit.Test)9 CNAbilitySelection (pcgen.cdom.helper.CNAbilitySelection)7 Nature (pcgen.cdom.enumeration.Nature)6 BigDecimal (java.math.BigDecimal)5 AssociatedPrereqObject (pcgen.cdom.base.AssociatedPrereqObject)4 CDOMObject (pcgen.cdom.base.CDOMObject)4 CDOMReference (pcgen.cdom.base.CDOMReference)4 CDOMSingleRef (pcgen.cdom.reference.CDOMSingleRef)4 PCTemplate (pcgen.core.PCTemplate)3 SpecialAbility (pcgen.core.SpecialAbility)3 BonusObj (pcgen.core.bonus.BonusObj)3 ParseResult (pcgen.rules.persistence.token.ParseResult)3 HashSet (java.util.HashSet)2