Search in sources :

Example 56 with AbilityCategory

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;
}
Also used : Ability(pcgen.core.Ability) StringTokenizer(java.util.StringTokenizer) AbilityCategory(pcgen.core.AbilityCategory)

Example 57 with AbilityCategory

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");
}
Also used : Ability(pcgen.core.Ability) AbilityCategory(pcgen.core.AbilityCategory) Test(org.junit.Test)

Example 58 with AbilityCategory

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");
}
Also used : Ability(pcgen.core.Ability) AbilityCategory(pcgen.core.AbilityCategory) Test(org.junit.Test)

Example 59 with AbilityCategory

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");
}
Also used : Ability(pcgen.core.Ability) AbilityCategory(pcgen.core.AbilityCategory) Test(org.junit.Test)

Example 60 with AbilityCategory

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);
}
Also used : Ability(pcgen.core.Ability) CNAbility(pcgen.cdom.content.CNAbility) DataSetID(pcgen.cdom.enumeration.DataSetID) 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