use of pcgen.cdom.content.CNAbility in project pcgen by PCGen.
the class BonusTest method testBonuswithLISTValue.
/**
* Test to make sure that fix for replacing %LIST within a
* bonuses value will work.
*/
public void testBonuswithLISTValue() {
final PlayerCharacter character = getCharacter();
LoadContext context = Globals.getContext();
setPCStat(character, intel, 18);
BonusObj bonus = Bonus.newBonus(context, "VISION|Darkvision|%LIST+10|TYPE=Magical Boon");
List<BonusObj> bonusList = new ArrayList<>();
bonusList.add(bonus);
Ability testBonus = new Ability();
testBonus.setName("TB1Assoc");
testBonus.setCDOMCategory(AbilityCategory.FEAT);
testBonus.addToListFor(ListKey.BONUS, bonus);
Globals.getContext().unconditionallyProcess(testBonus, "CHOOSE", "PCSTAT|ALL");
Globals.getContext().unconditionallyProcess(testBonus, "MULT", "YES");
CNAbility cna = AbstractCharacterTestCase.applyAbility(character, AbilityCategory.FEAT, testBonus, "INT");
testBonus = cna.getAbility();
character.calcActiveBonuses();
bonus = testBonus.getSafeListFor(ListKey.BONUS).get(0);
List<BonusPair> bonusPairs = character.getStringListFromBonus(bonus);
assertEquals(1, bonusPairs.size());
BonusPair bp = bonusPairs.get(0);
assertEquals("VISION.DARKVISION:MAGICAL BOON", bp.fullyQualifiedBonusType);
assertEquals(14, bp.resolve(character).intValue());
}
use of pcgen.cdom.content.CNAbility in project pcgen by PCGen.
the class BonusTest method testSpellKnownBonusWithLISTValue.
/**
* Test to make sure that fix for replacing %LIST within a
* bonuses value will work.
*/
public void testSpellKnownBonusWithLISTValue() {
final PlayerCharacter character = getCharacter();
LoadContext context = Globals.getContext();
context.getReferenceContext().constructNowIfNecessary(PCClass.class, "Wizard");
BonusObj bonus = Bonus.newBonus(context, "SPELLKNOWN|%LIST|1");
List<BonusObj> bonusList = new ArrayList<>();
bonusList.add(bonus);
Ability testBonus = new Ability();
testBonus.setName("TB1Assoc");
testBonus.setCDOMCategory(AbilityCategory.FEAT);
testBonus.addToListFor(ListKey.BONUS, bonus);
Globals.getContext().unconditionallyProcess(testBonus, "CHOOSE", "SPELLLEVEL|Wizard|1|5");
Globals.getContext().unconditionallyProcess(testBonus, "MULT", "YES");
CNAbility cna = AbstractCharacterTestCase.applyAbility(character, AbilityCategory.FEAT, testBonus, "CLASS.Wizard;LEVEL.1");
testBonus = cna.getAbility();
character.calcActiveBonuses();
bonus = testBonus.getSafeListFor(ListKey.BONUS).get(0);
List<BonusPair> bonusPairs = character.getStringListFromBonus(bonus);
assertEquals(1, bonusPairs.size());
BonusPair bp = bonusPairs.get(0);
assertEquals("SPELLKNOWN.CLASS.Wizard;LEVEL.1", bp.fullyQualifiedBonusType);
}
use of pcgen.cdom.content.CNAbility in project pcgen by PCGen.
the class AutoWeaponProfListTargetTest method containsExpected.
private boolean containsExpected() {
Collection<CNAbilitySelection> casSet = directAbilityFacet.getSet(id);
for (CNAbilitySelection cnas : casSet) {
CNAbility cas = cnas.getCNAbility();
boolean featExpected = cas.getAbilityCategory() == AbilityCategory.FEAT;
boolean abilityExpected = cas.getAbility().equals(context.getReferenceContext().silentlyGetConstructedCDOMObject(Ability.class, AbilityCategory.FEAT, "Granted"));
boolean natureExpected = cas.getNature() == Nature.AUTOMATIC;
boolean selectionExpected = "English".equals(cnas.getSelection());
if (featExpected && abilityExpected && natureExpected && selectionExpected) {
return true;
}
}
return false;
}
use of pcgen.cdom.content.CNAbility in project pcgen by PCGen.
the class GlobalAbilityTest method containsExpected.
@Override
protected boolean containsExpected(Ability granted) {
Collection<CNAbilitySelection> casSet = getTargetFacet().getSet(id);
for (CNAbilitySelection cnas : casSet) {
CNAbility cas = cnas.getCNAbility();
boolean featExpected = cas.getAbilityCategory() == AbilityCategory.FEAT;
boolean abilityExpected = cas.getAbility().equals(context.getReferenceContext().silentlyGetConstructedCDOMObject(Ability.class, AbilityCategory.FEAT, "Granted"));
boolean natureExpected = cas.getNature() == Nature.VIRTUAL;
boolean selectionExpected = cnas.getSelection() == null;
if (featExpected && abilityExpected && natureExpected && selectionExpected) {
return true;
}
}
return false;
}
use of pcgen.cdom.content.CNAbility in project pcgen by PCGen.
the class PlayerCharacterOutput method getFeatList.
String getFeatList() {
StringBuilder sb = new StringBuilder();
boolean firstLine = true;
for (CNAbility cna : pc.getCNAbilities(AbilityCategory.FEAT, Nature.NORMAL)) {
if (!firstLine) {
sb.append(", ");
}
firstLine = false;
sb.append(QualifiedName.qualifiedName(pc, Collections.singletonList(cna)));
}
return sb.toString();
}
Aggregations