Search in sources :

Example 31 with AbilityCategory

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

the class AbilityAllListToken method getAbilityList.

/**
	 * @see pcgen.io.exporttoken.AbilityListToken#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 (AbilityCategory.ANY.equals(aCategory) || aCat.getParentCategory().equals(aCategory)) {
            for (CNAbility cna : pc.getPoolAbilities(aCat, Nature.NORMAL)) {
                listOfAbilities.addToListFor(cna.getAbility(), cna);
            }
            for (CNAbility cna : pc.getPoolAbilities(aCat, Nature.AUTOMATIC)) {
                listOfAbilities.addToListFor(cna.getAbility(), cna);
            }
            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 32 with AbilityCategory

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

the class AbilityAllToken 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 (AbilityCategory.ANY.equals(aCategory) || aCat.getParentCategory().equals(aCategory)) {
            for (CNAbility cna : pc.getPoolAbilities(aCat, Nature.NORMAL)) {
                listOfAbilities.addToListFor(cna.getAbility(), cna);
            }
            for (CNAbility cna : pc.getPoolAbilities(aCat, Nature.AUTOMATIC)) {
                listOfAbilities.addToListFor(cna.getAbility(), cna);
            }
            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 33 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 34 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 35 with AbilityCategory

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

the class QualifyIntegrationTest method testRoundRobinNoSet.

@Test
public void testRoundRobinNoSet() throws PersistenceLayerException {
    verifyCleanStart();
    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);
    TestContext tc = new TestContext();
    emptyCommit(testCampaign, tc);
    commit(modCampaign, tc, "ABILITY=NEWCAT|Abil3");
    completeRoundRobin(tc);
}
Also used : Ability(pcgen.core.Ability) TestContext(plugin.lsttokens.editcontext.testsupport.TestContext) AbilityCategory(pcgen.core.AbilityCategory) Test(org.junit.Test)

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