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