Search in sources :

Example 1 with SpellMemToken

use of plugin.exporttokens.SpellMemToken in project pcgen by PCGen.

the class SpellMemTokenTest method testSpontaneousCasterKnown.

/**
	 * Test the SPELLMEM tag for a spontaneous caster. Checks that the
	 * list of known spells is auto populated and that the spell can be
	 * retrieved correctly.
	 */
public void testSpontaneousCasterKnown() {
    PlayerCharacter character = getCharacter();
    String spellBook = "Travel";
    character.setRace(human);
    character.incrementClassLevel(1, arcaneClass, true);
    PCClass ac = character.getClassKeyed(arcaneClass.getKeyName());
    CharacterSpell aCharacterSpell = new CharacterSpell(ac, testSpell);
    aCharacterSpell.addInfo(1, 1, null);
    character.addCharacterSpell(ac, aCharacterSpell);
    character.addSpellBook(spellBook);
    List<CharacterSpell> spellList = character.getCharacterSpells(ac, testSpell, "", 1);
    CharacterSpell charSpell = spellList.get(0);
    String result = character.addSpell(charSpell, null, arcaneClass.getKeyName(), Globals.getDefaultSpellBook(), 1, 1);
    assertEquals("No CHA, so should reject attempt to add spell", "You can only learn 0 spells for level 1 " + "\nand there are no higher-level slots available.", result);
    SpellMemToken token = new SpellMemToken();
    assertEquals("Retrieve spell from known list of arcane caster.", "Test Spell", token.getToken("SPELLMEM.0.0.1.0.NAME", character, null));
}
Also used : SpellMemToken(plugin.exporttokens.SpellMemToken) PlayerCharacter(pcgen.core.PlayerCharacter) CharacterSpell(pcgen.core.character.CharacterSpell) PCClass(pcgen.core.PCClass)

Example 2 with SpellMemToken

use of plugin.exporttokens.SpellMemToken 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

PCClass (pcgen.core.PCClass)2 PlayerCharacter (pcgen.core.PlayerCharacter)2 CharacterSpell (pcgen.core.character.CharacterSpell)2 SpellMemToken (plugin.exporttokens.SpellMemToken)2