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;
}
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;
}
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;
}
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);
}
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);
}
Aggregations