Search in sources :

Example 41 with CharacterSpell

use of pcgen.core.character.CharacterSpell in project pcgen by PCGen.

the class SpellMemTokenTest method testPreparedCaster.

/**
	 * Test the SPELLMEM tag for a spontaneous caster. Checks that the
	 * list of known spells is auto populated and that a spell can be added to
	 * a prepared list, and that the spell can be retrieved correctly from both
	 * books.
	 */
public void testPreparedCaster() {
    PlayerCharacter character = getCharacter();
    String spellBook = "Travel";
    character.setRace(human);
    character.incrementClassLevel(1, divineClass, true);
    PCClass dc = character.getClassKeyed(divineClass.getKeyName());
    CharacterSpell aCharacterSpell = new CharacterSpell(dc, testSpell);
    aCharacterSpell.addInfo(1, 1, null);
    character.addCharacterSpell(dc, aCharacterSpell);
    character.addSpellBook(spellBook);
    List<CharacterSpell> spellList = character.getCharacterSpells(dc, testSpell, "", 1);
    CharacterSpell charSpell = spellList.get(0);
    String result = character.addSpell(charSpell, null, divineClass.getKeyName(), Globals.getDefaultSpellBook(), 1, 1);
    assertEquals("Known spells already has all spells, should reject.", "The Known Spells spellbook contains all spells of this level that you " + "know. You cannot place spells in multiple times.", result);
    result = character.addSpell(charSpell, null, divineClass.getKeyName(), spellBook, 1, 1);
    assertEquals("No WIS, so should reject attempt to add spell", "You can only prepare 0 spells for level 1 " + "\nand there are no higher-level slots available.", result);
    setPCStat(character, wis, 12);
    character.calcActiveBonuses();
    result = character.addSpell(charSpell, null, divineClass.getKeyName(), spellBook, 1, 1);
    assertEquals("Should be no error messages from adding spell", "", result);
    SpellMemToken token = new SpellMemToken();
    assertEquals("Retrieve spell from known list of divine caster.", "Test Spell", token.getToken("SPELLMEM.0.0.1.0.NAME", character, null));
    assertEquals("Retrieve spell from prepared list of divine caster.", "Test Spell", token.getToken("SPELLMEM.0.2.1.0.NAME", character, null));
}
Also used : SpellMemToken(plugin.exporttokens.SpellMemToken) PlayerCharacter(pcgen.core.PlayerCharacter) CharacterSpell(pcgen.core.character.CharacterSpell) PCClass(pcgen.core.PCClass)

Aggregations

CharacterSpell (pcgen.core.character.CharacterSpell)41 Spell (pcgen.core.spell.Spell)22 ArrayList (java.util.ArrayList)16 PCClass (pcgen.core.PCClass)12 SpellInfo (pcgen.core.character.SpellInfo)12 PObject (pcgen.core.PObject)7 SpellBook (pcgen.core.character.SpellBook)6 Ability (pcgen.core.Ability)5 StringTokenizer (java.util.StringTokenizer)4 CNAbility (pcgen.cdom.content.CNAbility)4 Formula (pcgen.base.formula.Formula)3 CDOMList (pcgen.cdom.base.CDOMList)3 CDOMObject (pcgen.cdom.base.CDOMObject)3 PlayerCharacter (pcgen.core.PlayerCharacter)3 AssociatedPrereqObject (pcgen.cdom.base.AssociatedPrereqObject)2 CDOMReference (pcgen.cdom.base.CDOMReference)2 ClassSource (pcgen.cdom.helper.ClassSource)2 SpellSchool (pcgen.cdom.identifier.SpellSchool)2 ClassSpellList (pcgen.cdom.list.ClassSpellList)2 DomainSpellList (pcgen.cdom.list.DomainSpellList)2