Search in sources :

Example 81 with Ability

use of pcgen.core.Ability in project pcgen by PCGen.

the class PreMultTest method testMultiFeats.

/**
	 * Test to ensure that a number of feat test will
	 * correctly require a number of separate feats in
	 * any combination of two types.
	 * @throws Exception
	 */
public void testMultiFeats() throws Exception {
    final Ability metamagic1 = new Ability();
    metamagic1.addToListFor(ListKey.TYPE, Type.getConstant("METAMAGIC"));
    metamagic1.setName("MM1");
    metamagic1.put(StringKey.KEY_NAME, "MM1");
    metamagic1.setCDOMCategory(AbilityCategory.FEAT);
    final Ability metamagic2 = new Ability();
    metamagic2.addToListFor(ListKey.TYPE, Type.getConstant("METAMAGIC"));
    metamagic2.setName("MM2");
    metamagic2.put(StringKey.KEY_NAME, "MM2");
    metamagic2.setCDOMCategory(AbilityCategory.FEAT);
    final Ability metamagic3 = new Ability();
    metamagic3.addToListFor(ListKey.TYPE, Type.getConstant("METAMAGIC"));
    metamagic3.setName("MM3");
    metamagic3.put(StringKey.KEY_NAME, "MM3");
    metamagic3.setCDOMCategory(AbilityCategory.FEAT);
    final Ability item1 = new Ability();
    item1.addToListFor(ListKey.TYPE, Type.getConstant("ItemCreation"));
    item1.setName("IC1");
    item1.put(StringKey.KEY_NAME, "IC1");
    item1.setCDOMCategory(AbilityCategory.FEAT);
    final Ability item2 = new Ability();
    item2.addToListFor(ListKey.TYPE, Type.getConstant("ItemCreation"));
    item2.setName("IC2");
    item2.put(StringKey.KEY_NAME, "IC2");
    item2.setCDOMCategory(AbilityCategory.FEAT);
    final Ability item3 = new Ability();
    item3.addToListFor(ListKey.TYPE, Type.getConstant("ItemCreation"));
    item3.setName("IC3");
    item3.put(StringKey.KEY_NAME, "IC3");
    item3.setCDOMCategory(AbilityCategory.FEAT);
    final PlayerCharacter character = getCharacter();
    final PreAbilityParser producer = new PreAbilityParser();
    final Prerequisite prereq = producer.parse("FEAT", "3,TYPE=Metamagic,TYPE=ItemCreation", false, false);
    final PreMult test = new PreMult();
    int passes = test.passes(prereq, character, null);
    assertEquals("No feats should not pass", 0, passes);
    addAbility(AbilityCategory.FEAT, metamagic1);
    passes = test.passes(prereq, character, null);
    assertEquals("One feat should not pass", 0, passes);
    addAbility(AbilityCategory.FEAT, metamagic2);
    passes = test.passes(prereq, character, null);
    assertEquals("Two feats should not pass", 0, passes);
    addAbility(AbilityCategory.FEAT, metamagic3);
    passes = test.passes(prereq, character, null);
    assertEquals("Three feats should pass", 1, passes);
    removeAbility(AbilityCategory.FEAT, metamagic3);
    addAbility(AbilityCategory.FEAT, item1);
    passes = test.passes(prereq, character, null);
    assertEquals("Three feats should pass", 1, passes);
    addAbility(AbilityCategory.FEAT, item2);
    addAbility(AbilityCategory.FEAT, item3);
    addAbility(AbilityCategory.FEAT, metamagic3);
    passes = test.passes(prereq, character, null);
    assertEquals("Six feats should pass", 1, passes);
    removeAbility(AbilityCategory.FEAT, metamagic3);
    removeAbility(AbilityCategory.FEAT, item3);
    removeAbility(AbilityCategory.FEAT, item2);
    removeAbility(AbilityCategory.FEAT, item1);
    removeAbility(AbilityCategory.FEAT, metamagic2);
    removeAbility(AbilityCategory.FEAT, metamagic1);
}
Also used : Ability(pcgen.core.Ability) PreAbilityParser(plugin.pretokens.parser.PreAbilityParser) PlayerCharacter(pcgen.core.PlayerCharacter)

Example 82 with Ability

use of pcgen.core.Ability in project pcgen by PCGen.

the class ExportHandlerTest method testFor.

public void testFor() throws IOException {
    PlayerCharacter pc = getCharacter();
    Ability dummyFeat1 = new Ability();
    dummyFeat1.setName("1");
    dummyFeat1.setCDOMCategory(AbilityCategory.FEAT);
    Ability dummyFeat2 = new Ability();
    dummyFeat2.setName("2");
    dummyFeat2.setCDOMCategory(AbilityCategory.FEAT);
    Ability dummyFeat3 = new Ability();
    dummyFeat3.setName("3");
    dummyFeat3.setCDOMCategory(AbilityCategory.FEAT);
    Ability dummyFeat4 = new Ability();
    dummyFeat4.setName("4");
    dummyFeat4.setCDOMCategory(AbilityCategory.FEAT);
    Ability dummyFeat5 = new Ability();
    dummyFeat5.setName("5");
    dummyFeat5.setCDOMCategory(AbilityCategory.FEAT);
    Ability dummyFeat6 = new Ability();
    dummyFeat6.setName("6");
    dummyFeat6.setCDOMCategory(AbilityCategory.FEAT);
    Ability dummyFeat7 = new Ability();
    dummyFeat7.setName("7");
    dummyFeat7.setCDOMCategory(AbilityCategory.FEAT);
    addAbility(AbilityCategory.FEAT, dummyFeat1);
    addAbility(AbilityCategory.FEAT, dummyFeat2);
    addAbility(AbilityCategory.FEAT, dummyFeat3);
    addAbility(AbilityCategory.FEAT, dummyFeat4);
    addAbility(AbilityCategory.FEAT, dummyFeat5);
    addAbility(AbilityCategory.FEAT, dummyFeat6);
    addAbility(AbilityCategory.FEAT, dummyFeat7);
    assertEquals("Test for evaluates correctly", "----------------", evaluateToken("FOR.1,((24-STRLEN[SKILL.0])),24,-,NONE,NONE,1", pc));
    assertEquals("Test for evaluates correctly", "                ", evaluateToken("FOR.1,((24-STRLEN[SKILL.0])),24, ,NONE,NONE,1", pc));
    String tok = "DFOR." + "0" + ",${((count(\"ABILITIES\";\"CATEGORY=FEAT\")+1)/2)}" + ",1" + ",${(count(\"ABILITIES\";\"CATEGORY=FEAT\")+1)}" + ",${((count(\"ABILITIES\";\"CATEGORY=FEAT\")+1)/2)}" + ", \\FEAT.%.NAME\\ " + ",[" + ",]" + ",0";
    //Logging.errorPrint( "DFOR Test: " + evaluateToken(tok, pc));
    // Test DFOR with alternate syntax for jep passthrough.  ie, anything 
    // surrounded by ${x} will tbe sent straight to be processed.  We
    // will assume that x is a well formed type of value.  This was to get around 
    // the problems with DFOR not taking ((count("ABILITIES";"CATEGORY=FEAT")+1)
    // since it could not figure out how to parse it to send to the right place.
    assertEquals("Test for DFOR ", "[ 1  5 ][ 2  6 ][ 3  7 ][ 4   ]", evaluateToken(tok, pc));
}
Also used : Ability(pcgen.core.Ability) PlayerCharacter(pcgen.core.PlayerCharacter)

Example 83 with Ability

use of pcgen.core.Ability 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 84 with Ability

use of pcgen.core.Ability in project pcgen by PCGen.

the class AbilityListTokenTest method setUp.

/*
	 * @see TestCase#setUp()
	 */
@Override
protected void setUp() throws Exception {
    super.setUp();
    // Make some ability categories and add them to the game mode
    AbilityCategory bardCategory = Globals.getContext().getReferenceContext().constructNowIfNecessary(AbilityCategory.class, "BARDIC");
    Ability ab1 = TestHelper.makeAbility("Perform (Dance)", AbilityCategory.FEAT, "General.Fighter");
    ab1.put(ObjectKey.MULTIPLE_ALLOWED, Boolean.FALSE);
    ab1.put(ObjectKey.VISIBILITY, Visibility.DEFAULT);
    addAbility(AbilityCategory.FEAT, ab1);
    Ability ab2 = TestHelper.makeAbility("Perform (Dance)", "BARDIC", "General.Bardic");
    ab2.put(ObjectKey.MULTIPLE_ALLOWED, Boolean.FALSE);
    addAbility(bardCategory, ab2);
    Ability ab3 = TestHelper.makeAbility("Perform (Oratory)", AbilityCategory.FEAT, "General.Fighter");
    ab3.put(ObjectKey.MULTIPLE_ALLOWED, Boolean.FALSE);
    addAbility(AbilityCategory.FEAT, ab3);
    Ability ab4 = TestHelper.makeAbility("Silent Step", AbilityCategory.FEAT, "General");
    ab4.put(ObjectKey.MULTIPLE_ALLOWED, Boolean.FALSE);
    addAbility(AbilityCategory.FEAT, ab4);
}
Also used : Ability(pcgen.core.Ability) AbilityCategory(pcgen.core.AbilityCategory)

Example 85 with Ability

use of pcgen.core.Ability 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

Ability (pcgen.core.Ability)279 CNAbility (pcgen.cdom.content.CNAbility)128 AbilityCategory (pcgen.core.AbilityCategory)60 PlayerCharacter (pcgen.core.PlayerCharacter)54 Test (org.junit.Test)46 ArrayList (java.util.ArrayList)43 CNAbilitySelection (pcgen.cdom.helper.CNAbilitySelection)25 ParseResult (pcgen.rules.persistence.token.ParseResult)21 HashMapToList (pcgen.base.util.HashMapToList)15 PCClass (pcgen.core.PCClass)15 Spell (pcgen.core.spell.Spell)15 StringTokenizer (java.util.StringTokenizer)14 TestContext (plugin.lsttokens.editcontext.testsupport.TestContext)13 LoadContext (pcgen.rules.context.LoadContext)12 SpecialAbility (pcgen.core.SpecialAbility)11 CharacterSpell (pcgen.core.character.CharacterSpell)11 PreParserFactory (pcgen.persistence.lst.prereq.PreParserFactory)11 List (java.util.List)10 CDOMObject (pcgen.cdom.base.CDOMObject)10 CDOMSingleRef (pcgen.cdom.reference.CDOMSingleRef)10