5e-database icon indicating copy to clipboard operation
5e-database copied to clipboard

Convert Spellcasting Ability information into a full object

Open pwtyler opened this issue 8 years ago • 65 comments

"special_abilities": [{
    "name": "Spellcasting",
    "desc": "The acolyte is a 1st-level spellcaster. Its spellcasting ability is Wisdom (spell save DC 12, +4 to hit with spell attacks). The acolyte has following cleric spells prepared:\n\n• Cantrips (at will): light, sacred flame, thaumaturgy\n• 1st level (3 slots): bless, cure wounds, sanctuary",
    "attack_bonus": 0
}]

would read something like

"special_abilities": [
    {
        "name": "Spellcasting",
        "desc": {
            "spellcasting_level":1,
            "spellcasting_ability":"wisdom",
            "spellcasting_dc":12,
            "spellcasting_attack_modifier":4,
            "spellcasting_school":"cleric",
            "spells":{
                "cantrips": [ "light", "sacred flame", "thaumaturgy" ],
                "1st":[ "bless", "cure wounds", "sanctuary" ]
            },
            "spell_slots":{
                "1st":3
            }
        }
    }
]

I'd love input/thoughts on structure, key names, etc above.

pwtyler avatar Jan 14 '18 18:01 pwtyler

Oh, you might also wanna cross reference the Levels objects, I think some of the info such as spell slots per level are already on there.

I'm not sure which would be better to place them in - the spell casting object or the levels object, or both. What to you think?

adrpadua avatar Jan 15 '18 22:01 adrpadua

Looks like the spell slots for a monster and a PC may not line up by level. With the above example, acolyte is a first-level cleric, with three first-level spell slots. According to 5e-SRD-Levels.json, a first-level cleric has two first-level spell slots.

Here is my latest version of the Spellcasting object:

{
    "name": "Spellcasting",
    "desc": "The acolyte is a 1st-level spellcaster. Its spellcasting ability is Wisdom (spell save DC 12, +4 to hit with spell attacks). The acolyte has following cleric spells prepared:\n\n\u2022 Cantrips (at will): light, sacred flame, thaumaturgy\n\u2022 1st level (3 slots): bless, cure wounds, sanctuary",
    "attack_bonus": 4,
    "data": {
        "spellcasting_level": 1,
        "spellcasting_ability": "wisdom",
        "spellcasting_dc": 12,
        "spellcasting_modifier": 4,
        "spellcasting_school": "cleric",
        "spells": {
            "cantrips": [
                "light",
                "sacred flame",
                "thaumaturgy"
            ],
            "1st_level": [
                "bless",
                "cure wounds",
                "sanctuary"
            ]
        },
        "spell_slots": {
            "1st_level": 3
        },
        "notes": ""
    }
}

Based on my read of the spellcasters desc blocks I parsed, the only monster requiring special information is the note under the archmage, which lists the spells he or she has prepared before combat.

I also took a pass at a similar block for innate spellcasters. Here is the Unicorn's block.

{
    "name": "Innate Spellcasting",
    "desc": "The unicorn's innate spellcasting ability is Charisma (spell save DC 14). The unicorn can innately cast the following spells, requiring no components:\n\nAt will: detect evil and good, druidcraft, pass without trace\n1\/day each: calm emotions, dispel evil and good, entangle",
    "attack_bonus": 0,
    "data": {
        "spellcasting_ability": "charisma",
        "spellcasting_dc": 14,
        "spellcasting_modifier": 0,
        "spells": {
            "at_will": [
                "detect evil and good",
                "druidcraft",
                "pass without trace"
            ],
            "1_per_day_each": [
                "calm emotions",
                "dispel evil and good",
                "entangle"
            ]
        }
    }
}

The only key data missing from the innate spellcasting data object is the question of components. Most do not require any components, but some, like the Deva and the Guardian Naga, do require verbal components. Perhaps this can simply be under a notes key? I'm open to suggestions and will figure out parsing that data out of the desc once I know where to put it.

I'm also on the fence about the keys for the innate spells. I don't love the 1_per_day_each key, but the / escapes awkwardly, so we need some solution. One option would be to combine spells + spell slots into a single object, something like the following:

"spells": {
    "cantrips": {
        "slots":"at will",
        "spells": [
            "light",
            "sacred flame",
            "thaumaturgy"
        ]
    },
    "1st_level": {
        "slots":3,
        "spells": [
            "bless",
            "cure wounds",
            "sanctuary"
        ]
    }
}

Under the innate casters, like cantrips, we could replace the "slots" value with the 3/day each. As mentioned in the slack channel, I have my "work in progress" branched on my fork, and can open a PR if that is more helpful for conversation, but I don't consider it "ready". I can also share my super-ugly parsing script written in php if that's helpful at all.

pwtyler avatar Jan 16 '18 04:01 pwtyler

I don't know if you've been working on this at all. I do like where it is going. But it might make sense to start by treating Spellcasting and Innate Spellcasting as separate structures at first until we see a convergence. I'd also make sure the spells include the url to the spells they represent.

But I do like the idea of combining spells and slots together. I don't know if it will make as much sense with Innate Spellcasting though. I do agree that 1_per_day_each is probably not a good key and that information should be stored as values instead.

bagelbits avatar Apr 14 '19 19:04 bagelbits

I'll try and take a look at this when I have some time.

bagelbits avatar Oct 28 '19 19:10 bagelbits

Some thoughts on the format.

Spellcasting:

{
  "name": "Spellcasting",
  "desc": "The acolyte is a 1st-level spellcaster. Its spellcasting ability is Wisdom (spell save DC 12, +4 to hit with spell attacks). The acolyte has following cleric spells prepared:\n\n\u2022 Cantrips (at will): light, sacred flame, thaumaturgy\n\u2022 1st level (3 slots): bless, cure wounds, sanctuary",
  "spellcasting": {
    "spellcasting_level": 1,
    "spellcasting_ability": {
      "name": "WIS",
      "url": "http://www.dnd5eapi.co/api/ability-scores/5"
    },
    "spellcasting_dc": 12,
    "spellcasting_modifier": 4,
    "spellcasting_school": "cleric",
    "spells": [
      {
        "level": "cantrip",
        "spells": [
          {
            "name": "Light",
            "url": "http://www.dnd5eapi.co/api/spells/180"
          },
          {
            "name": "Sacred Flame",
            "url": "http://www.dnd5eapi.co/api/spells/250"
          },
          
          {
            "name": "Thaumaturgy",
            "url": "http://www.dnd5eapi.co/api/spells/291"
          }
          
        ]
      },
      {
        "level": 1,
        "slots":3,
        "spells": [
          {
            "name": "Bless",
            "url": "http://www.dnd5eapi.co/api/spells/29"
          },
          {
            "name": "Cure Wounds",
            "url": "http://www.dnd5eapi.co/api/spells/70"
          },
          {
            "name": "Sanctuary",
            "url": "http://www.dnd5eapi.co/api/spells/251"
          }
        ]
      }
    ]
  }
}

Innate Spellcasting:

{
  "name": "Innate Spellcasting",
  "desc": "The unicorn's innate spellcasting ability is Charisma (spell save DC 14). The unicorn can innately cast the following spells, requiring no components:\n\nAt will: detect evil and good, druidcraft, pass without trace\n1\/day each: calm emotions, dispel evil and good, entangle",
  "spellcasting": {
    "spellcasting_ability": {
      "name": "CHA",
      "url": "http://www.dnd5eapi.co/api/ability-scores/6"
    },
    "spellcasting_dc": 14,
    "spellcasting_modifier": 0,
    "components_required": [],
    "spells": [
      {
        "per_day": "at will",
        "spells": [
          {
            "name": "Detect Evil and Good",
            "url": "http://www.dnd5eapi.co/api/spells/78"
          },
          {
            "name": "Druidcraft",
            "url": "http://www.dnd5eapi.co/api/spells/94"
          },
          {
            "name": "Pass without Trace",
            "url": "http://www.dnd5eapi.co/api/spells/214"
          }
        ]
      },
      {
        "per_day": 1,
        "spells": [
          {
            "name": "Calm Emotions",
            "url": "http://www.dnd5eapi.co/api/spells/37"
          },
          {
            "name": "Dispel Evil and Good",
            "url": "http://www.dnd5eapi.co/api/spells/85"
          },
          {
            "name": "Entangle",
            "url": "http://www.dnd5eapi.co/api/spells/99"
          }
        ]
      }
    ]
  }
}

bagelbits avatar Oct 28 '19 23:10 bagelbits

I would remove the spellcasting_ prefix from the members of the spellcasting object. It's redundant and already reads appropriately when in a debugger: spellcasting.dc

ogregoire avatar Oct 29 '19 15:10 ogregoire

I'm concerned that the SpellCastingDC for inate casting, as this should be a built score, as characters can also have a inate spell casting and it will level with them

Alex-frazer avatar Oct 29 '19 15:10 Alex-frazer

also, per_day isn't greatly placed, as each spell in the per_day could have a different number of times in a day or a different refresher cause (sunrise, long rest etc)

Alex-frazer avatar Oct 29 '19 15:10 Alex-frazer

also, per_day isn't greatly placed, as each spell in the per_day could have a different number of times in a day or a different refresher cause (sunrise, long rest etc)

I agree.

I would rather see the following:

"spells": [
  {
    "name": ... ,
    "url": .... ,
    "refreshes_on": "day" // "at_will", "long_rest", "short_rest", "sunrise", etc.
  }
]

ogregoire avatar Oct 29 '19 15:10 ogregoire

@Alex-frazer Ah, you're right about the Save DC. Since it's calculated by:

DC = 8 + proficiency bonus + spellcasting ability modifier And it seems like you can figure out the proficiency bonus based on the CR.

bagelbits avatar Oct 29 '19 17:10 bagelbits

@ogregoire I like where this is going. How might you depict that a spell can be used three times a day though?

bagelbits avatar Oct 29 '19 17:10 bagelbits

Maybe use another semantics?

"spells": [
  {
    "name": ... ,
    "url": .... ,
    "usage": "3x per day" // "at will", "1x per long rest", "3x per short rest", etc.
  }
]

ogregoire avatar Oct 29 '19 18:10 ogregoire

I think both the casting DC and attack modifier can be calculated. But for now, it probably makes more sense to keep it in for ease of look up.

bagelbits avatar Oct 30 '19 20:10 bagelbits

Also, it would end up looking like this:

Spellcasting:

{
  "name": "Spellcasting",
  "desc": "The acolyte is a 1st-level spellcaster. Its spellcasting ability is Wisdom (spell save DC 12, +4 to hit with spell attacks). The acolyte has following cleric spells prepared:\n\n\u2022 Cantrips (at will): light, sacred flame, thaumaturgy\n\u2022 1st level (3 slots): bless, cure wounds, sanctuary",
  "spellcasting": {
    "level": 1,
    "ability": {
      "name": "WIS",
      "url": "http://www.dnd5eapi.co/api/ability-scores/5"
    },
    "dc": 12,
    "modifier": 4,
    "school": "cleric",
    "spells": [
      {
        "level": "cantrip",
        "spells": [
          {
            "name": "Light",
            "url": "http://www.dnd5eapi.co/api/spells/180"
          },
          {
            "name": "Sacred Flame",
            "url": "http://www.dnd5eapi.co/api/spells/250"
          },
          
          {
            "name": "Thaumaturgy",
            "url": "http://www.dnd5eapi.co/api/spells/291"
          }
          
        ]
      },
      {
        "level": 1,
        "slots":3,
        "spells": [
          {
            "name": "Bless",
            "url": "http://www.dnd5eapi.co/api/spells/29"
          },
          {
            "name": "Cure Wounds",
            "url": "http://www.dnd5eapi.co/api/spells/70"
          },
          {
            "name": "Sanctuary",
            "url": "http://www.dnd5eapi.co/api/spells/251"
          }
        ]
      }
    ]
  }
}

Innate Spellcasting:

{
  "name": "Innate Spellcasting",
  "desc": "The unicorn's innate spellcasting ability is Charisma (spell save DC 14). The unicorn can innately cast the following spells, requiring no components:\n\nAt will: detect evil and good, druidcraft, pass without trace\n1\/day each: calm emotions, dispel evil and good, entangle",
  "spellcasting": {
    "ability": {
      "name": "CHA",
      "url": "http://www.dnd5eapi.co/api/ability-scores/6"
    },
    "dc": 14,
    "modifier": 0,
    "components_required": [],
    "spells": [
      {
        "name": "Detect Evil and Good",
        "url": "http://www.dnd5eapi.co/api/spells/78",
        "usage": "at will"
      },
      {
        "name": "Druidcraft",
        "url": "http://www.dnd5eapi.co/api/spells/94",
        "usage": "at will"
      },
      {
        "name": "Pass without Trace",
        "url": "http://www.dnd5eapi.co/api/spells/214",
        "usage": "at will"
      },
      {
        "name": "Calm Emotions",
        "url": "http://www.dnd5eapi.co/api/spells/37",
        "usage": "1x per day"
      },
      {
        "name": "Dispel Evil and Good",
        "url": "http://www.dnd5eapi.co/api/spells/85",
        "usage": "1x per day"
      },
      {
        "name": "Entangle",
        "url": "http://www.dnd5eapi.co/api/spells/99",
        "usage": "1x per day"
      }
    ]
  }
}

bagelbits avatar Oct 30 '19 20:10 bagelbits

for usage, we could do a more programatic coding, such as -1 for at will, and then numerical representation for the number of times a day ?

Or is this all meant to be readable more than anything

Alex-frazer avatar Oct 31 '19 09:10 Alex-frazer

@Alex-frazer The "Limited Usage" section of the SRD (follow link or on page 259 of the PDF) says there exists 3 different types of restrictions:

X/Day. The notation “X/Day” means a special ability can be used X number of times and that a monster must finish a long rest to regain expended uses. For example, “1/Day” means a special ability can be used once and that the monster must finish a long rest to use it again. Recharge X–Y. The notation “Recharge X–Y” means a monster can use a special ability once and that the ability then has a random chance of recharging during each subsequent round of combat. At the start of each of the monster’s turns, roll a d6. If the roll is one of the numbers in the recharge notation, the monster regains the use of the special ability. The ability also recharges when the monster finishes a short or long rest. For example, “Recharge 5–6” means a monster can use the special ability once. Then, at the start of the monster’s turn, it regains the use of that ability if it rolls a 5 or 6 on a d6. Recharge after a Short or Long Rest. This notation means that a monster can use a special ability once and then must finish a short or long rest to use it again.

I would add "at will", but keep a normalized version of this "limited usage". Making it programmatic would not make justice to it. The data needn't be programmatic, just properly understandable and parseable. Even if it's not numbers, it's still data. Just like the dice, we keep using "3d6" and not a structure that separates 3 from 6.

ogregoire avatar Oct 31 '19 09:10 ogregoire

Here's a silly idea:

{
  "name": "Entangle",
  "url": "http://www.dnd5eapi.co/api/spells/99",
  "usage": {
    "type": "at will"
  }
}

{
  "name": "Entangle",
  "url": "http://www.dnd5eapi.co/api/spells/99",
  "usage": {
    "type": "per day",
    "times": 3
  }
}

{
  "name": "Entangle",
  "url": "http://www.dnd5eapi.co/api/spells/99",
  "usage": {
    "type": "recharge",
    "range": [5, 6]
  }
}

{
  "name": "Entangle",
  "url": "http://www.dnd5eapi.co/api/spells/99",
  "usage": {
    "type": "recharge",
    "time": "short rest"
  }
}

bagelbits avatar Oct 31 '19 22:10 bagelbits

It's not that silly at all, on the contrary: it's rather smart!

ogregoire avatar Nov 01 '19 07:11 ogregoire

3d6 is easier to serialise though :P hahaha

@bagelbits that looks like a good structure

Alex-frazer avatar Nov 01 '19 08:11 Alex-frazer

I self deprecate a lot. So final structures for now would look like this:

Spellcasting:

{
  "name": "Spellcasting",
  "desc": "The acolyte is a 1st-level spellcaster. Its spellcasting ability is Wisdom (spell save DC 12, +4 to hit with spell attacks). The acolyte has following cleric spells prepared:\n\n\u2022 Cantrips (at will): light, sacred flame, thaumaturgy\n\u2022 1st level (3 slots): bless, cure wounds, sanctuary",
  "spellcasting": {
    "level": 1,
    "ability": {
      "name": "WIS",
      "url": "http://www.dnd5eapi.co/api/ability-scores/5"
    },
    "dc": 12,
    "modifier": 4,
    "school": "cleric",
    "spells": [
      {
        "level": "cantrip",
        "spells": [
          {
            "name": "Light",
            "url": "http://www.dnd5eapi.co/api/spells/180"
          },
          {
            "name": "Sacred Flame",
            "url": "http://www.dnd5eapi.co/api/spells/250"
          },
          
          {
            "name": "Thaumaturgy",
            "url": "http://www.dnd5eapi.co/api/spells/291"
          }
          
        ]
      },
      {
        "level": 1,
        "slots":3,
        "spells": [
          {
            "name": "Bless",
            "url": "http://www.dnd5eapi.co/api/spells/29"
          },
          {
            "name": "Cure Wounds",
            "url": "http://www.dnd5eapi.co/api/spells/70"
          },
          {
            "name": "Sanctuary",
            "url": "http://www.dnd5eapi.co/api/spells/251"
          }
        ]
      }
    ]
  }
}

Innate Spellcasting

{
  "name": "Innate Spellcasting",
  "desc": "The unicorn's innate spellcasting ability is Charisma (spell save DC 14). The unicorn can innately cast the following spells, requiring no components:\n\nAt will: detect evil and good, druidcraft, pass without trace\n1\/day each: calm emotions, dispel evil and good, entangle",
  "spellcasting": {
    "ability": {
      "name": "CHA",
      "url": "http://www.dnd5eapi.co/api/ability-scores/6"
    },
    "dc": 14,
    "modifier": 0,
    "components_required": [],
    "spells": [
      {
        "name": "Detect Evil and Good",
        "url": "http://www.dnd5eapi.co/api/spells/78",
        "usage": {
          "type": "at will"
        }
      },
      {
        "name": "Druidcraft",
        "url": "http://www.dnd5eapi.co/api/spells/94",
        "usage": {
          "type": "at will"
        }
      },
      {
        "name": "Pass without Trace",
        "url": "http://www.dnd5eapi.co/api/spells/214",
        "usage": {
          "type": "at will"
        }
      },
      {
        "name": "Calm Emotions",
        "url": "http://www.dnd5eapi.co/api/spells/37",
        "usage": {
          "type": "per day",
          "times": 1
        }
      },
      {
        "name": "Dispel Evil and Good",
        "url": "http://www.dnd5eapi.co/api/spells/85",
        "usage": {
          "type": "per day",
          "times": 1
        }
      },
      {
        "name": "Entangle",
        "url": "http://www.dnd5eapi.co/api/spells/99",
        "usage": {
          "type": "per day",
          "times": 1
        }
      }
    ]
  }
}

bagelbits avatar Nov 01 '19 19:11 bagelbits