use of pcgen.core.PlayerCharacter in project pcgen by PCGen.
the class WeaponTokenTest method testWpnFinesse.
/**
* Test the processing of a finesseable weapon both with and without weapon finesse
* and temporary bonuses.
*/
public void testWpnFinesse() {
PlayerCharacter character = getCharacter();
assertEquals("Prof should be longsword", "KEY_LONGSWORD", fineSword.get(ObjectKey.WEAPON_PROF).get().getKeyName());
LoadContext context = Globals.getContext();
character.addEquipment(fineSword);
EquipSet es = new EquipSet("0.1.3", "Longsword (Fine)", fineSword.getName(), fineSword);
character.addEquipSet(es);
character.setCalcEquipmentList();
// Test weapon profs effects on large weapons
WeaponToken token = new WeaponToken();
assertEquals("Fine sword", "+18/+13/+8/+3", token.getToken("WEAPON.3.BASEHIT", character, null));
// Now apply weapon finess and check dex is used rather than str
Ability wpnFinesse = new Ability();
wpnFinesse.setName("Weapon Finesse");
wpnFinesse.setCDOMCategory(AbilityCategory.FEAT);
wpnFinesse.put(StringKey.KEY_NAME, "Weapon Finesse");
final BonusObj wfBonus = Bonus.newBonus(context, "COMBAT|TOHIT.Finesseable|((max(STR,DEX)-STR)+SHIELDACCHECK)|TYPE=NotRanged");
wpnFinesse.addToListFor(ListKey.BONUS, wfBonus);
addAbility(AbilityCategory.FEAT, wpnFinesse);
assertEquals("Fine sword", "+19/+14/+9/+4", token.getToken("WEAPON.3.BASEHIT", character, null));
// Add a temp penalty to dex and check that it is applied
character.setUseTempMods(true);
Spell spell2 = new Spell();
spell2.setName("Concrete Boots");
final BonusObj aBonus = Bonus.newBonus(context, "STAT|DEX|-4");
if (aBonus != null) {
spell2.addToListFor(ListKey.BONUS, aBonus);
}
BonusObj penalty = spell2.getRawBonusList(character).get(0);
character.addTempBonus(penalty, spell2, character);
character.calcActiveBonuses();
assertEquals("Fine sword", "+18/+13/+8/+3", token.getToken("WEAPON.3.BASEHIT", character, null));
}
use of pcgen.core.PlayerCharacter in project pcgen by PCGen.
the class WeaponTokenTest method testAmmunition.
/**
* test the AMUNITION count sub token
*/
public void testAmmunition() {
PlayerCharacter character = getCharacter();
character.addEquipment(largeSword);
EquipSet es = new EquipSet("0.1.3", "Large Sword", largeSword.getName(), largeSword);
character.addEquipSet(es);
character.addEquipment(longbow);
es = new EquipSet("0.1.4", "Longbow", longbow.getName(), longbow);
character.addEquipSet(es);
character.setCalcEquipmentList();
WeaponToken token = new WeaponToken();
assertEquals("non-ammo weapon", largeSword.getName(), token.getToken("WEAPON.4.NAME", character, null));
assertEquals("Ammo weapon", longbow.getName(), token.getToken("WEAPON.3.NAME", character, null));
assertEquals("Ammo count for a non-ammo weapon", "0", token.getToken("WEAPON.4.AMMUNITION", character, null));
String result = token.getToken("WEAPON.3.AMMUNITION", character, null);
assertEquals("Ammo count for an empty ammo weapon", "0", result);
character.addEquipment(arrow);
es = new EquipSet("0.1.4.1", "Arrow", arrow.getName(), arrow);
character.addEquipSet(es);
character.setCalcEquipmentList();
result = token.getToken("WEAPON.3.AMMUNITION", character, null);
assertEquals("Ammo count for longbow with one arrow", "1", result);
}
use of pcgen.core.PlayerCharacter in project pcgen by PCGen.
the class PCGVer2ParserCharacterTest method testRaceAddSpellcaster.
/**
* Check that a racial ADD:SPELLCASTER happens exactly once on character
* load. Duplication of the association has occurred a couple of times in
* the past.
* @throws Exception
*/
public void testRaceAddSpellcaster() throws Exception {
LoadContext context = Globals.getContext();
Race rakshasha = context.getReferenceContext().silentlyGetConstructedCDOMObject(Race.class, "Rakshasa");
PlayerCharacter pc = getCharacter();
pc.setImporting(true);
PCGVer2Parser pcgParser = new PCGVer2Parser(pc);
String[] pcgLines = { "RACE:Rakshasa|ADD:[SPELLCASTER:Sorcerer|CHOICE:Sorcerer]" };
pcgParser.parsePCG(pcgLines);
PersistentTransitionChoice<?> tc = rakshasha.getListFor(ListKey.ADD).get(0);
List<Object> assocList = pc.getAssocList(tc, AssociationListKey.ADD);
assertEquals("Number of associations for ADD " + assocList, 1, assocList.size());
}
use of pcgen.core.PlayerCharacter in project pcgen by PCGen.
the class AbilityListTokenTest method testCategory.
/**
* Test the output for negative numbers with fractions.
*/
public void testCategory() {
AbilityListToken tok = new AbilityListToken();
ExportHandler eh = new ExportHandler(null);
PlayerCharacter character = getCharacter();
is(tok.getToken("ABILITYLIST.BARDIC", character, eh), strEq("Perform (Dance)"), "ABILITYLIST.BARDIC");
}
use of pcgen.core.PlayerCharacter in project pcgen by PCGen.
the class AbilityListTokenTest method testCount.
/**
* Test the JEP count function on abilities.
*/
public void testCount() {
// verbose = true;
PlayerCharacter character = getCharacter();
AbilityCategory featCategory = SettingsHandler.getGame().getAbilityCategory("Feat");
Ability ab5 = TestHelper.makeAbility("Silent Step (Greater)", AbilityCategory.FEAT, "General");
ab5.put(ObjectKey.MULTIPLE_ALLOWED, Boolean.FALSE);
ab5.put(ObjectKey.VISIBILITY, Visibility.OUTPUT_ONLY);
addAbility(featCategory, ab5);
Ability ab6 = TestHelper.makeAbility("Perform (Fiddle)", AbilityCategory.FEAT, "Bardic");
ab6.put(ObjectKey.MULTIPLE_ALLOWED, Boolean.FALSE);
addAbility(featCategory, ab6);
is(character.getVariableValue("count(\"ABILITIES\",\"CATEGORY=FEAT\",\"VISIBILITY=DEFAULT\")", ""), eq(4.0, 0.1), "count(\"ABILITIES\",\"CATEGORY=FEAT\",\"VISIBILITY=DEFAULT\")");
is(character.getVariableValue("count(\"ABILITIES\",\"CATEGORY=FEAT\",\"VISIBILITY=DEFAULT[or]VISIBILITY=OUTPUT_ONLY\")", ""), eq(5.0, 0.1), "count(\"ABILITIES\",\"CATEGORY=FEAT\",\"VISIBILITY=DEFAULT[or]VISIBILITY=OUTPUT_ONLY\")");
is(character.getVariableValue("count(\"ABILITIES\",\"CATEGORY=FEAT[and]TYPE=Fighter\",\"VISIBILITY=DEFAULT[or]VISIBILITY=OUTPUT_ONLY\")", ""), eq(2.0, 0.1), "count(\"ABILITIES\",\"CATEGORY=FEAT[and]TYPE=Fighter\",\"VISIBILITY=DEFAULT[or]VISIBILITY=OUTPUT_ONLY\")");
is(character.getVariableValue("count(\"ABILITIES\",\"CATEGORY=BARDIC[and]TYPE=Bardic.General\")", ""), eq(1.0, 0.1), "count(\"ABILITIES\",\"CATEGORY=BARDIC[and]TYPE=Bardic.General\")");
is(character.getVariableValue("count(\"ABILITIES\",\"NATURE=AUTOMATIC\")", ""), eq(0.0, 0.1), "count(\"ABILITIES\",\"NATURE=AUTOMATIC\")");
is(character.getVariableValue("count(\"ABILITIES\",\"NATURE=VIRTUAL\")", ""), eq(0.0, 0.1), "count(\"ABILITIES\",\"NATURE=VIRTUAL\")");
is(character.getVariableValue("count(\"ABILITIES\",\"NATURE=NORMAL\")", ""), eq(6.0, 0.1), "count(\"ABILITIES\",\"NATURE=NORMAL\")");
is(character.getVariableValue("count(\"ABILITIES\")", ""), eq(6.0, 0.1), "count(\"ABILITIES\")");
}
Aggregations