Search in sources :

Example 6 with Aspect

use of pcgen.cdom.helper.Aspect in project pcgen by PCGen.

the class MapKeyMapTest method setUp.

/**
	 * @see junit.framework.TestCase#setUp()
	 */
@Before
public void setUp() throws Exception {
    mapKeyMap = new MapKeyMap();
    ageKey = AspectName.getConstant("agE");
    nameKey = AspectName.getConstant("Name");
    breedKey = AspectName.getConstant("breed");
    List<Aspect> ageList = new ArrayList<>();
    ageAspect = new Aspect("age", AGE);
    ageList.add(ageAspect);
    mapKeyMap.addToMapFor(MapKey.ASPECT, ageKey, ageList);
    List<Aspect> nameList = new ArrayList<>();
    nameAspect = new Aspect("name", NAME);
    nameList.add(nameAspect);
    mapKeyMap.addToMapFor(MapKey.ASPECT, nameKey, nameList);
    List<Aspect> breedList = new ArrayList<>();
    breedAspect = new Aspect("breed", BREED);
    breedList.add(breedAspect);
    mapKeyMap.addToMapFor(MapKey.ASPECT, breedKey, breedList);
}
Also used : ArrayList(java.util.ArrayList) Aspect(pcgen.cdom.helper.Aspect) Before(org.junit.Before)

Example 7 with Aspect

use of pcgen.cdom.helper.Aspect in project pcgen by PCGen.

the class VAbilityTokenTest method setUp.

/*
	 * @see TestCase#setUp()
	 */
@Override
protected void setUp() throws Exception {
    super.setUp();
    PlayerCharacter character = getCharacter();
    // Make some ability categories and add them to the game mode
    Ability ab1 = TestHelper.makeAbility("Perform (Dance)", AbilityCategory.FEAT, "General.Fighter");
    ab1.put(ObjectKey.MULTIPLE_ALLOWED, Boolean.FALSE);
    ab1.put(ObjectKey.VISIBILITY, Visibility.DEFAULT);
    List<Aspect> colourList = new ArrayList<>();
    colourList.add(new Aspect("Colour", "Green"));
    ab1.addToMapFor(MapKey.ASPECT, AspectName.getConstant("Colour"), colourList);
    List<Aspect> sizeList = new ArrayList<>();
    sizeList.add(new Aspect("Size", "L"));
    ab1.addToMapFor(MapKey.ASPECT, AspectName.getConstant("Size"), sizeList);
    List<Aspect> shapeList = new ArrayList<>();
    Aspect cube = new Aspect("Shape", "Cube");
    Prerequisite prereq = new Prerequisite();
    prereq.setKind("ALIGN");
    prereq.setKey("LG");
    prereq.setOperator(PrerequisiteOperator.EQ);
    cube.addPrerequisite(prereq);
    shapeList.add(cube);
    shapeList.add(new Aspect("Shape", "Icosahedron"));
    ab1.addToMapFor(MapKey.ASPECT, AspectName.getConstant("Shape"), shapeList);
    List<Aspect> sidesList = new ArrayList<>();
    sidesList.add(new Aspect("Sides", "20"));
    ab1.addToMapFor(MapKey.ASPECT, AspectName.getConstant("Sides"), sidesList);
    List<Aspect> ageList = new ArrayList<>();
    ageList.add(new Aspect("Age In Years", "2000"));
    ab1.addToMapFor(MapKey.ASPECT, AspectName.getConstant("Age In Years"), ageList);
    CNAbility cna = CNAbilityFactory.getCNAbility(AbilityCategory.FEAT, Nature.VIRTUAL, ab1);
    character.addAbility(new CNAbilitySelection(cna), UserSelection.getInstance(), UserSelection.getInstance());
    TestHelper.makeSkill("Bluff", "Charisma", cha, true, SkillArmorCheck.NONE);
    TestHelper.makeSkill("Listen", "Wisdom", wis, true, SkillArmorCheck.NONE);
    skillFocus = TestHelper.makeAbility("Skill Focus", AbilityCategory.FEAT, "General");
    BonusObj aBonus = Bonus.newBonus(Globals.getContext(), "SKILL|LIST|3");
    if (aBonus != null) {
        skillFocus.addToListFor(ListKey.BONUS, aBonus);
    }
    skillFocus.put(ObjectKey.MULTIPLE_ALLOWED, true);
    Globals.getContext().unconditionallyProcess(skillFocus, "CHOOSE", "SKILL|ALL");
    cna = CNAbilityFactory.getCNAbility(AbilityCategory.FEAT, Nature.VIRTUAL, skillFocus);
    character.addAbility(new CNAbilitySelection(cna, "KEY_Bluff"), UserSelection.getInstance(), UserSelection.getInstance());
    character.addAbility(new CNAbilitySelection(cna, "KEY_Listen"), UserSelection.getInstance(), UserSelection.getInstance());
    character.calcActiveBonuses();
}
Also used : Ability(pcgen.core.Ability) CNAbility(pcgen.cdom.content.CNAbility) CNAbility(pcgen.cdom.content.CNAbility) PlayerCharacter(pcgen.core.PlayerCharacter) BonusObj(pcgen.core.bonus.BonusObj) ArrayList(java.util.ArrayList) CNAbilitySelection(pcgen.cdom.helper.CNAbilitySelection) Aspect(pcgen.cdom.helper.Aspect) Prerequisite(pcgen.core.prereq.Prerequisite)

Example 8 with Aspect

use of pcgen.cdom.helper.Aspect in project pcgen by PCGen.

the class AspectToken method parseNonEmptyToken.

@Override
protected ParseResult parseNonEmptyToken(LoadContext context, Ability ability, String value) {
    int pipeLoc = value.indexOf(Constants.PIPE);
    if (pipeLoc == -1) {
        return new ParseResult.Fail(getTokenName() + " expecting '|', format is: " + "AspectName|Aspect value|Variable|... was: " + value, context);
    }
    String key = value.substring(0, pipeLoc);
    if (key.isEmpty()) {
        return new ParseResult.Fail(getTokenName() + " expecting non-empty type, " + "format is: AspectName|Aspect value|Variable|... was: " + value, context);
    }
    String val = value.substring(pipeLoc + 1);
    if (val.isEmpty()) {
        return new ParseResult.Fail(getTokenName() + " expecting non-empty value, " + "format is: AspectName|Aspect value|Variable|... was: " + value, context);
    }
    if (val.startsWith(Constants.PIPE)) {
        return new ParseResult.Fail(getTokenName() + " expecting non-empty value, " + "format is: AspectName|Aspect value|Variable|... was: " + value, context);
    }
    Aspect a = parseAspect(key, val);
    MapChanges<AspectName, List<Aspect>> mc = context.getObjectContext().getMapChanges(ability, MapKey.ASPECT);
    Map<AspectName, List<Aspect>> fullMap = mc.getAdded();
    List<Aspect> aspects = fullMap.get(a.getKey());
    if (aspects == null) {
        aspects = new ArrayList<>();
    }
    aspects.add(a);
    context.getObjectContext().put(ability, MapKey.ASPECT, a.getKey(), aspects);
    return ParseResult.SUCCESS;
}
Also used : AspectName(pcgen.cdom.enumeration.AspectName) ArrayList(java.util.ArrayList) List(java.util.List) Aspect(pcgen.cdom.helper.Aspect)

Aggregations

Aspect (pcgen.cdom.helper.Aspect)8 ArrayList (java.util.ArrayList)6 Prerequisite (pcgen.core.prereq.Prerequisite)3 List (java.util.List)2 AspectName (pcgen.cdom.enumeration.AspectName)2 Ability (pcgen.core.Ability)2 PlayerCharacter (pcgen.core.PlayerCharacter)2 BonusObj (pcgen.core.bonus.BonusObj)2 StringTokenizer (java.util.StringTokenizer)1 TreeSet (java.util.TreeSet)1 Before (org.junit.Before)1 Test (org.junit.Test)1 CNAbility (pcgen.cdom.content.CNAbility)1 CNAbilitySelection (pcgen.cdom.helper.CNAbilitySelection)1