Search in sources :

Example 81 with PlayerCharacter

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));
}
Also used : Ability(pcgen.core.Ability) PlayerCharacter(pcgen.core.PlayerCharacter) BonusObj(pcgen.core.bonus.BonusObj) EquipSet(pcgen.core.character.EquipSet) LoadContext(pcgen.rules.context.LoadContext) Spell(pcgen.core.spell.Spell)

Example 82 with PlayerCharacter

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);
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) EquipSet(pcgen.core.character.EquipSet)

Example 83 with PlayerCharacter

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());
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) Race(pcgen.core.Race) LoadContext(pcgen.rules.context.LoadContext)

Example 84 with PlayerCharacter

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");
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) ExportHandler(pcgen.io.ExportHandler)

Example 85 with PlayerCharacter

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

Aggregations

PlayerCharacter (pcgen.core.PlayerCharacter)438 PreParserFactory (pcgen.persistence.lst.prereq.PreParserFactory)89 PCClass (pcgen.core.PCClass)61 LoadContext (pcgen.rules.context.LoadContext)58 Ability (pcgen.core.Ability)54 Equipment (pcgen.core.Equipment)41 PCTemplate (pcgen.core.PCTemplate)38 EquipSet (pcgen.core.character.EquipSet)32 BonusObj (pcgen.core.bonus.BonusObj)29 Race (pcgen.core.Race)28 CharID (pcgen.cdom.enumeration.CharID)25 ExportHandler (pcgen.io.ExportHandler)24 Test (org.junit.Test)20 ArrayList (java.util.ArrayList)16 PreClassTester (plugin.pretokens.test.PreClassTester)16 CDOMObject (pcgen.cdom.base.CDOMObject)15 Skill (pcgen.core.Skill)14 CNAbility (pcgen.cdom.content.CNAbility)13 URI (java.net.URI)11 URISyntaxException (java.net.URISyntaxException)11