Search in sources :

Example 26 with AbilityCategory

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

the class CountCommandTest method setUp.

/*
	 * @see TestCase#setUp()
	 */
@Override
protected void setUp() throws Exception {
    super.setUp();
    final PlayerCharacter character = getCharacter();
    // Make some ability categories and add them to the game mode
    AbilityCategory bardCategory = Globals.getContext().getReferenceContext().constructNowIfNecessary(AbilityCategory.class, "BARDIC");
    AbilityCategory clericalCategory = Globals.getContext().getReferenceContext().constructNowIfNecessary(AbilityCategory.class, "CLERICAL");
    final Ability[] abArray = new Ability[14];
    abArray[0] = TestHelper.makeAbility("Quick Draw", AbilityCategory.FEAT, "General.Fighter");
    abArray[1] = TestHelper.makeAbility("Improved Initiative", AbilityCategory.FEAT, "General.Fighter");
    abArray[2] = TestHelper.makeAbility("Silent Step", AbilityCategory.FEAT, "General.Fighter.Rogue");
    abArray[3] = TestHelper.makeAbility("Silent Step (Greater)", AbilityCategory.FEAT, "General.Fighter.Rogue");
    abArray[4] = TestHelper.makeAbility("Hidden 01", AbilityCategory.FEAT, "ClassAbility");
    abArray[5] = TestHelper.makeAbility("Perform (Dance)", AbilityCategory.FEAT, "ClassAbility");
    abArray[6] = TestHelper.makeAbility("Perform (Dance)", "BARDIC", "Performance.SpecialAbility");
    abArray[7] = TestHelper.makeAbility("Perform (Oratory)", "BARDIC", "Performance.SpecialAbility");
    abArray[8] = TestHelper.makeAbility("Perform (Fiddle)", "BARDIC", "Performance.SpecialAbility");
    abArray[9] = TestHelper.makeAbility("Perform (Bass)", "BARDIC", "Performance.SpecialAbility");
    abArray[10] = TestHelper.makeAbility("Epic Performance (Dance)", "BARDIC", "Performance.ExtraordinaryAbility.Epic");
    abArray[11] = TestHelper.makeAbility("Epic Performance (Bass)", "BARDIC", "Performance.ExtraordinaryAbility.Epic");
    abArray[12] = TestHelper.makeAbility("Turning", "CLERICAL", "SpecialAbility.");
    abArray[13] = TestHelper.makeAbility("Epic Turning", "CLERICAL", "SpecialAbility.Epic");
    for (final Ability ab : abArray) {
        ab.put(ObjectKey.MULTIPLE_ALLOWED, Boolean.FALSE);
    }
    abArray[3].put(ObjectKey.VISIBILITY, Visibility.DISPLAY_ONLY);
    abArray[4].put(ObjectKey.VISIBILITY, Visibility.HIDDEN);
    abArray[5].put(ObjectKey.VISIBILITY, Visibility.HIDDEN);
    abArray[10].put(ObjectKey.VISIBILITY, Visibility.OUTPUT_ONLY);
    abArray[11].put(ObjectKey.VISIBILITY, Visibility.OUTPUT_ONLY);
    abArray[13].put(ObjectKey.VISIBILITY, Visibility.OUTPUT_ONLY);
    abArray[1].put(ObjectKey.MULTIPLE_ALLOWED, Boolean.TRUE);
    Globals.getContext().unconditionallyProcess(abArray[1], "CHOOSE", "STRING|one|two|three");
    AbstractCharacterTestCase.applyAbility(character, AbilityCategory.FEAT, abArray[1], "one");
    AbstractCharacterTestCase.applyAbility(character, AbilityCategory.FEAT, abArray[1], "two");
    addAbility(AbilityCategory.FEAT, abArray[0]);
    for (int i = 2; 6 > i; i++) {
        Ability anAbility = abArray[i];
        addAbility(AbilityCategory.FEAT, anAbility);
    }
    for (int i = 6; 12 > i; i++) {
        Ability anAbility = abArray[i];
        addAbility(bardCategory, anAbility);
    }
    for (int i = 12; 14 > i; i++) {
        Ability anAbility = abArray[i];
        addAbility(clericalCategory, anAbility);
    }
}
Also used : Ability(pcgen.core.Ability) PlayerCharacter(pcgen.core.PlayerCharacter) AbilityCategory(pcgen.core.AbilityCategory)

Example 27 with AbilityCategory

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

the class ForwardrefTokenTest method testRoundRobinJustAbility.

@Test
public void testRoundRobinJustAbility() throws PersistenceLayerException {
    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");
}
Also used : Ability(pcgen.core.Ability) AbilityCategory(pcgen.core.AbilityCategory) Test(org.junit.Test)

Example 28 with AbilityCategory

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

the class AbilityToken method parseNonEmptyToken.

@Override
protected ParseResult parseNonEmptyToken(LoadContext context, KitAbilities kitAbil, String value) {
    int pipeLoc = value.indexOf(Constants.PIPE);
    if (pipeLoc == -1) {
        return new ParseResult.Fail("No pipe found.  ABILITY token " + "in a Kit requires CATEGORY=<cat>|<ability>,<ability>", context);
    }
    String catString = value.substring(0, pipeLoc);
    if (!catString.startsWith("CATEGORY=")) {
        return new ParseResult.Fail("No CATEGORY= found.  ABILITY token " + "in a Kit requires CATEGORY=<cat>|<abilities>", context);
    }
    if (catString.length() < 10) {
        return new ParseResult.Fail("No category found.  ABILITY token " + "in a Kit requires CATEGORY=<cat>|<abilities>", context);
    }
    String acName = catString.substring(9);
    CDOMSingleRef<AbilityCategory> acRef = context.getReferenceContext().getCDOMReference(ABILITY_CATEGORY_CLASS, acName);
    /*
		 * CONSIDER In the future it would be nice to not have to do this cast,
		 * but that should be reserved for the time when the Pool nature of
		 * AbilityCategory is separated from the Organizational nature of
		 * AbilityCategory
		 */
    kitAbil.setCategory(acRef);
    String rest = value.substring(pipeLoc + 1);
    if (isEmpty(rest) || hasIllegalSeparator('|', rest)) {
        return new ParseResult.Fail("No abilities found.  ABILITY token " + "in a Kit requires CATEGORY=<cat>|<abilities>");
    }
    StringTokenizer st = new StringTokenizer(rest, Constants.PIPE);
    ReferenceManufacturer<Ability> rm = context.getReferenceContext().getManufacturer(ABILITY_CLASS, ABILITY_CATEGORY_CLASS, acName);
    if (rm == null) {
        return new ParseResult.Fail("Could not get Reference Manufacturer for Category: " + acName, context);
    }
    while (st.hasMoreTokens()) {
        String token = st.nextToken();
        if (token.startsWith("CATEGORY=")) {
            return new ParseResult.Fail("Attempting to change the Category to '" + token + "': " + value);
        }
        CDOMReference<Ability> ref = TokenUtilities.getTypeOrPrimitive(rm, token);
        if (ref == null) {
            return ParseResult.INTERNAL_ERROR;
        }
        kitAbil.addAbility(ref);
    }
    return ParseResult.SUCCESS;
}
Also used : Ability(pcgen.core.Ability) StringTokenizer(java.util.StringTokenizer) AbilityCategory(pcgen.core.AbilityCategory)

Example 29 with AbilityCategory

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

the class CNAbilitySelectionUtilitiesTest method setUp.

@Before
public void setUp() throws Exception {
    CNAbilityFactory.reset();
    feat = new AbilityCategory();
    feat.setName("FEAT");
    fighterfeat = new AbilityCategory();
    fighterfeat.setName("Fighter Feat");
    fighterfeat.setAbilityCategory(CDOMDirectSingleRef.getRef(feat));
    specialty = new AbilityCategory();
    specialty.setName("Specialty");
    nomult = new Ability();
    nomult.setName("NoMult");
    nomult.setCDOMCategory(feat);
    multyes = new Ability();
    multyes.setName("MultYes");
    multyes.setCDOMCategory(feat);
    multyes.put(ObjectKey.MULTIPLE_ALLOWED, true);
    stackyes = new Ability();
    stackyes.setName("MultYes");
    stackyes.setCDOMCategory(feat);
    stackyes.put(ObjectKey.MULTIPLE_ALLOWED, true);
    stackyes.put(ObjectKey.STACKS, true);
    othernomult = new Ability();
    othernomult.setName("OtherNoMult");
    othernomult.setCDOMCategory(feat);
}
Also used : Ability(pcgen.core.Ability) CNAbility(pcgen.cdom.content.CNAbility) AbilityCategory(pcgen.core.AbilityCategory) Before(org.junit.Before)

Example 30 with AbilityCategory

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

the class AbilityToken method decodeChoice.

@Override
public Ability decodeChoice(LoadContext context, String s) {
    StringTokenizer st = new StringTokenizer(s, Constants.PIPE);
    String catString = st.nextToken();
    if (!catString.startsWith("CATEGORY=")) {
        throw new IllegalArgumentException("String in AbilityToken.decodeChoice " + "must start with CATEGORY=, found: " + s);
    }
    String cat = catString.substring(9);
    AbilityCategory ac = SettingsHandler.getGame().getAbilityCategory(cat);
    if (ac == null) {
        throw new IllegalArgumentException("Category in AbilityToken.decodeChoice " + "must exist found: " + cat);
    }
    String ab = st.nextToken();
    Ability a = context.getReferenceContext().silentlyGetConstructedCDOMObject(Ability.class, ac, ab);
    if (a == null) {
        throw new IllegalArgumentException("Second argument in String in AbilityToken.decodeChoice " + "must be an Ability, but it was not found: " + s);
    }
    return a;
}
Also used : Ability(pcgen.core.Ability) StringTokenizer(java.util.StringTokenizer) 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