Spells

knitr::opts_chunk$set(collapse = TRUE, comment = "#>")
# devtools::install_github("njlyon0/dndR", force = TRUE)
library(dndR)

Searching for Spells

There are a lot of spells in the various Dungeons & Dragons source books that your character might be able to invoke. Finding specific spells can be a daunting task in the face of the sheer number of spells that exist so dndR has some functions to hopefully make this effort more manageable for your magic-using player characters and NPCs.

The spell_list function lets you search through official spells based on several criteria that you specify. A dataframe including all of the big-picture information for spells that meet your criteria is returned to help orient you for any subsequent steps you plan on taking. Note that all spell_list arguments that accept characters are case in-sensitive and queries use partial string matching so you don't need to try to engineer exact matches.

This function lets you can query spells based on one or more of the following criteria:

# Find all sorcerer spells that have the word 'bolt' in the name
bolt_df <- dndR::spell_list(name = "bolt", class = "sorcerer")

# Check the structure of that output
str(bolt_df)
# Find all seventh-level necromancy spells in the wizard spell list
necro_df <- dndR::spell_list(school = "necromancy", class = "wizard", level = 7)

# Check the structure
str(necro_df)

Spell Descriptions

If you need to access the specific description of a particular spell (or spells), you can use the spell_text function. This returns an R-style dataframe equivalent of the sort of spell card information you'd find in the back of a typical D&D source book.

# Get the Chill Touch spell description
dndR::spell_text(name = "chill touch")

I typically use this function to get more detail on a particular spell after searching more broadly with spell_list but I think it's also nice as a quick reference if you need to consult the specific language of the spell description or remind yourself how casting the spell with a higher level spell slot affects the spell.



Try the dndR package in your browser

Any scripts or data that you put into this service are public.

dndR documentation built on May 29, 2024, 11:02 a.m.