use of pcgen.core.AbilityCategory in project pcgen by PCGen.
the class AbilityToken method decodeChoice.
@Override
public Ability decodeChoice(LoadContext context, String encoded, Category<?> category) {
String key;
AbilityCategory abilityCat = (AbilityCategory) category;
StringTokenizer st = new StringTokenizer(encoded, Constants.PIPE);
if (st.countTokens() > 1) {
String catString = st.nextToken();
if (!catString.startsWith("CATEGORY=")) {
throw new IllegalArgumentException("Ability choice must be key name or CATEGORY=category|ability" + " found: " + encoded);
}
String cat = catString.substring(9);
abilityCat = SettingsHandler.getGame().getAbilityCategory(cat);
key = st.nextToken();
} else {
key = encoded;
}
Ability a = context.getReferenceContext().silentlyGetConstructedCDOMObject(Ability.class, abilityCat, key);
if (a == null) {
throw new IllegalArgumentException("String in decodeChoice " + "must be an Ability, but it was not found: " + encoded);
}
return a;
}
use of pcgen.core.AbilityCategory in project pcgen by PCGen.
the class QualifyTokenTest method testRoundRobinJustAbility.
@Test
public void testRoundRobinJustAbility() 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);
runRoundRobin("ABILITY=NEWCAT|Abil3");
}
use of pcgen.core.AbilityCategory in project pcgen by PCGen.
the class ServesAsTokenTest method testRoundRobinJustAbility.
@Test
public void testRoundRobinJustAbility() throws PersistenceLayerException {
primaryProf = new Ability();
secondaryProf = new Ability();
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);
runRoundRobin("ABILITY=NEWCAT|Abil3");
}
use of pcgen.core.AbilityCategory in project pcgen by PCGen.
the class AbilityLstTest method testRoundRobinTwoCategory.
@Test
public void testRoundRobinTwoCategory() throws PersistenceLayerException {
construct(primaryContext, "Abil1");
construct(secondaryContext, "Abil1");
construct(primaryContext, "Abil2");
construct(secondaryContext, "Abil2");
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);
ab = primaryContext.getReferenceContext().constructCDOMObject(Ability.class, "Abil4");
primaryContext.getReferenceContext().reassociateCategory(pac, ab);
ab = secondaryContext.getReferenceContext().constructCDOMObject(Ability.class, "Abil4");
secondaryContext.getReferenceContext().reassociateCategory(sac, ab);
runRoundRobin("FEAT|VIRTUAL|Abil1|Abil2", "NEWCAT|VIRTUAL|Abil3|Abil4");
}
use of pcgen.core.AbilityCategory in project pcgen by PCGen.
the class AbstractCNASEnforcingFacetTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
getFacet().addDataFacetChangeListener(listener);
CNAbilityFactory.reset();
DataSetID cid = DataSetID.getID();
id = CharID.getID(cid);
altid = CharID.getID(cid);
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);
}
Aggregations