Coder Social home page Coder Social logo

Comments (65)

ogregoire avatar ogregoire commented on July 21, 2024 1

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

from 5e-database.

ogregoire avatar ogregoire commented on July 21, 2024 1

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.
  }
]

from 5e-database.

bagelbits avatar bagelbits commented on July 21, 2024 1

@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.

from 5e-database.

bagelbits avatar bagelbits commented on July 21, 2024 1

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"
  }
}

from 5e-database.

Alex-frazer avatar Alex-frazer commented on July 21, 2024 1

that makes a lot of sense.
But if doing that when you consider creatures with higher level spells, they have a number of slots per level of spell so if we are doing a sampled spell list which I'm pro, you would need a dictionary with a structure of [lvl:slots] for spell slots

from 5e-database.

bagelbits avatar bagelbits commented on July 21, 2024 1

Lol. I just realize that @Alex-frazer said that to both of us a bit ago.

from 5e-database.

ogregoire avatar ogregoire commented on July 21, 2024 1

Indeed, but my point about spells being just spells and the fact that they're cantrips, level 1 or 9 is relevant to the spell, not to the monster. So I would keep the following structure with the spells slots adapted. Here's my take with the archmage:

"spellcasting": {
	... ,
	"slots": {
		"1": 4,
		"2": 3,
		"3": 3,
		"4": 3,
		"5": 3,
		"6": 1,
		"7": 1,
		"8": 1,
		"9": 1,
	},
	"spells": [
		{
			"name": "Fire Bolt",
			"url": "..."
		},
		{
			"name": "Light",
			"url": "..."
		},
		{
			"name": "Mage Hand",
			"url": "..."
		},
		{
			"name": "Prestidigitation",
			"url": "..."
		},
		{
			"name": "Shocking Grasp",
			"url": "..."
		},
		{
			"name": "Detect Magic",
			"url": "..."
		},
		{
			"name": "Identify",
			"url": "..."
		},
		{
			"name": "Mage Armor",
			"url": "..."
		},
		{
			"name": "Magic Missile",
			"url": "..."
		},
		{
			"name": "Detect Thoughts",
			"url": "..."
		},
		{
			"name": "Mirror Image",
			"url": "..."
		},
		{
			"name": "Misty Step",
			"url": "..."
		},
		{
			"name": "Counterspell",
			"url": "..."
		},
		{
			"name": "Fly",
			"url": "..."
		},
		{
			"name": "Lightning Bolt",
			"url": "..."
		},
		{
			"name": "Banishment",
			"url": "..."
		},
		{
			"name": "Fire Shield",
			"url": "..."
		},
		{
			"name": "Stoneskin",
			"url": "..."
		},
		{
			"name": "Cone of Cold",
			"url": "..."
		},
		{
			"name": "Scrying",
			"url": "..."
		},
		{
			"name": "Wall of Force",
			"url": "..."
		},
		{
			"name": "Globe of Invulnerability",
			"url": "..."
		},
		{
			"name": "Teleport",
			"url": "..."
		},
		{
			"name": "Mind Blank",
			"url": "..."
		},
		{
			"name": "Time Stop",
			"url": "..."
		}
	]
}

from 5e-database.

adrpadua avatar adrpadua commented on July 21, 2024

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?

from 5e-database.

pwtyler avatar pwtyler commented on July 21, 2024

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.

from 5e-database.

bagelbits avatar bagelbits commented on July 21, 2024

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.

from 5e-database.

bagelbits avatar bagelbits commented on July 21, 2024

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

from 5e-database.

bagelbits avatar bagelbits commented on July 21, 2024

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"
          }
        ]
      }
    ]
  }
}

from 5e-database.

Alex-frazer avatar Alex-frazer commented on July 21, 2024

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

from 5e-database.

Alex-frazer avatar Alex-frazer commented on July 21, 2024

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)

from 5e-database.

bagelbits avatar bagelbits commented on July 21, 2024

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

from 5e-database.

ogregoire avatar ogregoire commented on July 21, 2024

Maybe use another semantics?

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

from 5e-database.

bagelbits avatar bagelbits commented on July 21, 2024

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.

from 5e-database.

bagelbits avatar bagelbits commented on July 21, 2024

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"
      }
    ]
  }
}

from 5e-database.

Alex-frazer avatar Alex-frazer commented on July 21, 2024

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

from 5e-database.

ogregoire avatar ogregoire commented on July 21, 2024

@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.

from 5e-database.

ogregoire avatar ogregoire commented on July 21, 2024

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

from 5e-database.

Alex-frazer avatar Alex-frazer commented on July 21, 2024

3d6 is easier to serialise though :P hahaha

@bagelbits that looks like a good structure

from 5e-database.

bagelbits avatar bagelbits commented on July 21, 2024

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
        }
      }
    ]
  }
}

from 5e-database.

bagelbits avatar bagelbits commented on July 21, 2024

If y'all are cool with that, I can put together a PR sometime soon for this and we can see how it looks.

from 5e-database.

Alex-frazer avatar Alex-frazer commented on July 21, 2024

that looks good to me

from 5e-database.

ogregoire avatar ogregoire commented on July 21, 2024

Actually, I don't like the "simple" spellcasting:

Light, Sacred Flame and Thaumaturgy are cantrips. Bless, Cure Wounds and Sanctuary are level 1 spells. There's no need to repeat it here. That's some piece of info that belongs to the spell itself, not on a monster stats.

However, the fact that there are 3 level 1 slots is interesting and should be noted in another manner, kind of like:

"spellcasting": {
  ... ,
  "slots": [3],
  "spells": [
    // Light
    // Sacred Flame
    // Thaumaturgy
    // Bless
    // Cure Wounds
    // Sanctuary
  ]
}

from 5e-database.

bagelbits avatar bagelbits commented on July 21, 2024

It's useful to give the level so that you know what level spell slots they are. Since some spells you can cast using a higher spell slot.

from 5e-database.

ogregoire avatar ogregoire commented on July 21, 2024

If you look at a more complex stats block from D&D itself (not the SRD), you can see that the text says something akin to:

Spellcasting. Blah blah blah
Cantrips (at will): List of cantrips
1st level (X slots): List of first level spells
2nd level (Y slots): List of second level spells
3rd level (Z slots): List of third level spells

Since in D&D NPCs follow the same rules as characters, an NPC can cast a level 1 spell with a level 3 slot. See SRD page 258:

A monster can cast a spell from its list at a higher level if it has the spell slot to do so. For example, a drow mage with the 3rd‑level lightning bolt spell can cast it as a 5th‑level spell by using one of its 5th‑level spell slots.

So the rules make a clear difference between spell slots and spells, even for NPCs.

Therefore it makes total sense for the stats to make the distinction between slots and spell list, just like we do for player characters. And the data should reflect that, it shouldn't reflect all the reminders that the game designers threw in the stats blocks.

This repo is about presenting the data. The data isn't what is written in the SRD, it's what is underlying. The SRD is only a human-readable representation of the data.

from 5e-database.

Alex-frazer avatar Alex-frazer commented on July 21, 2024

@ogregoire sorry so what are you suggesting

from 5e-database.

ogregoire avatar ogregoire commented on July 21, 2024

@Alex-frazer I suggest what I wrote here

from 5e-database.

bagelbits avatar bagelbits commented on July 21, 2024

Since Cantrips are also level 1 spells, you need someone to distinguish which of the spells are cantrips.

I actually like the "simple" spellcasting that I've proposed. It signifies in data what the description is trying to get across and links to relevant spells. You could pull the spell slots out into their own data shape if you really want, but I don't think using an array is a good idea, since your index will be off by one from the spell level you're talking about.

from 5e-database.

ogregoire avatar ogregoire commented on July 21, 2024

Since Cantrips are also level 1 spells, you need someone to distinguish which of the spells are cantrips.

Uh? No, they're not! Where is the rule that they're also level 1 spells? "Light" is always a cantrip: it's never considered as a levelled spell anywhere, for instance. It's sometimes a spell that's given as innate spellcasting for some races or classes, but even then it says cantrip and not level 1 spell.

Edit: after checking, the SRD p. 100 says that cantrips are actually level 0 spells. And it is confirmed at page 101.

since your index will be off by one from the spell level you're talking about.

That is not true: it totally depends on the language you're using to read the data. But yeah, to avoid confusion, it might be better to have an explicit mapping for slots. That's the only change I'd make from my proposal: describe slots using an object instead of an array.

from 5e-database.

bagelbits avatar bagelbits commented on July 21, 2024

Sorry. I also misread what I was reading regarding Cantrips. You're right about them being Level 0 spells.

from 5e-database.

bagelbits avatar bagelbits commented on July 21, 2024

So:

{
  "slots": {
    "1": 4,
    "2": 3,
    "3": 3,
    "4": 3,
    "5": 1,
  }
}

from 5e-database.

bagelbits avatar bagelbits commented on July 21, 2024

So, my take on the shape of:

{
  "name": "Time Stop",
  "url": "..."
}

is for details that are immediately relevant to the reference be included. Otherwise, from a pure data linking stand point, name doesn't give you anything, besides being useful for cross checking. You really only need the url, but this just feels weird:

{
  "spells": [
    {
      "url": "..."
    }
  ]
}

Unless I've missed my mark.

from 5e-database.

benjaminapetersen avatar benjaminapetersen commented on July 21, 2024

Looks like a good direction!

from 5e-database.

benjaminapetersen avatar benjaminapetersen commented on July 21, 2024

May want to call consider dropping "per day" as a string and doing:

Name: FooSpell
Count: 1
PerDay: true // Boolean

from 5e-database.

ogregoire avatar ogregoire commented on July 21, 2024

The object "usage" is kind of mandatory, plus using "type": "per day" is clearer than using "per_day": true, "at_will": false, "recharge": false. If you don't have the type, you could have something like "per_day": true, "at_will":true and it be both valid and way harder to enforce.

So let's just stick to "type": "per day".

from 5e-database.

benjaminapetersen avatar benjaminapetersen commented on July 21, 2024

Iits readable, but not programmatically useful. if you were going to use this in a programmatic way, you are then using string checks as booleans. Continuing the idea that description should keep prose text, the "once per day" can live there, but if going through the trouble to split out data, I'd suggest doing the bool:

Name: Spell Name
URL: http://api....
Usage:
   Description: prose text in human readable form once per day etc etc
   Count: 1
   PerDay: true
   AtWill: false
   Recharge: false

from 5e-database.

ogregoire avatar ogregoire commented on July 21, 2024

The type is usually some well known representation. An implementation will check the value of type and then it will know which values to extract.

With booleans, if we missed one type, "foo", we will be required to check all the value and add
"foo": false everywhere.

Using a type is both generic enough and powerful.

Finally, we already use the type mechanism at several places in the API, such as in 5e-SRD-Classes.json, 5e-SRD-Equipment.json (under the name "equipment_category"), 5e-SRD-Proficiencies.json, and probably others, I haven't checked more.

So I guess, we have a strong case to keep using a descriptive type instead of booleans.

from 5e-database.

benjaminapetersen avatar benjaminapetersen commented on July 21, 2024

Works for me. Consistency is always a good argument.

from 5e-database.

bagelbits avatar bagelbits commented on July 21, 2024

Back on Simple Spellcasting, I still think it makes sense to group the spells by level. Even though the level is part of the spell data. Typically, how the data would be presented, you'd want to group by level every time anyways. I could think of two different shapes for this:

{
  "slots": {
    "1": 3
  },
  "spells_by_level": [
    {
      "level": 0,
      "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,
      "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"
        }
      ]
    }
  ]
}
{
  "slots": {
    "1": 3
  },
  "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"
      }
    ],
    [
      {
        "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"
      }
    ]
  ]
}

from 5e-database.

Alex-frazer avatar Alex-frazer commented on July 21, 2024

In the first one if your going to split spells by level why store the slots in a separate section, while looking at spells for that level also get the number of slots and make it easy objects. otherwise your doing 2 searches to find spell slots and an unconnected number of slots.

For the second way if you just split it into arrays without keys, it may as well be one array of spells. (since you can't guarantee that the arrays are for each slot level, so why split it all)

Personal preference is the second as spells aren't linked to number of slots

from 5e-database.

benjaminapetersen avatar benjaminapetersen commented on July 21, 2024

It may also be interesting considering an object, for access purposes. Its trivial to access .spells.level1 than to write a search function search(spells, "lvl1"). Since there are exactly 9 levels of spells (and cantrips) holding spells in an array instead of an objects is a bit more clunkly for the user & likely less efficient performance.

That said, a user can transform the data in any way they like once consumed.

from 5e-database.

ogregoire avatar ogregoire commented on July 21, 2024

@benjaminapetersen Indeed, it's easier to find by level the way you showed, but it's harder to get by name or by any property other than level.

from 5e-database.

bagelbits avatar bagelbits commented on July 21, 2024

Okay. Than I guess just go with @ogregoire proposal for Regular Spellcasting.

from 5e-database.

benjaminapetersen avatar benjaminapetersen commented on July 21, 2024

If meaning this comment proposal, agree, it makes sense (provided the spell lvl is contained in each spell object in the array for cross reference to slot).

from 5e-database.

bagelbits avatar bagelbits commented on July 21, 2024

@benjaminapetersen Are you saying the spell object should look like this?

      {
        "name": "Light",
        "level": 0,
        "url": "http://www.dnd5eapi.co/api/spells/180"
      }

Also, technically, there are 10 levels since cantrips count as spell level 0.

from 5e-database.

benjaminapetersen avatar benjaminapetersen commented on July 21, 2024

Correct. 10 levels (cantrips are lvl 0)
Something like that. What might be sensible is a uid. Simple count, start with 1. Lookup by id is pretty common. The id is prob the number at the end of url:"http://www.dnd5eapi.co/api/spells/180".

from 5e-database.

bagelbits avatar bagelbits commented on July 21, 2024

It is. I don't think the uid is necessary since the url is where you would fetch the additional data. (Assuming that API ever updates with all the changes we've made.

from 5e-database.

bagelbits avatar bagelbits commented on July 21, 2024

@benjaminapetersen Can you give a full example of what you're thinking?

from 5e-database.

benjaminapetersen avatar benjaminapetersen commented on July 21, 2024
{
        "name": "Light",
        "level": 0,
        "uid": 180,
        "url": "http://www.dnd5eapi.co/api/spells/180"
      }

uid matching the url id. Convenience for those who may consume these resources to build out other tools. uid is pretty common for cross-references across data sets.

from 5e-database.

ogregoire avatar ogregoire commented on July 21, 2024
{
        "name": "Light",
        "level": 0,
        "uid": 180,
        "url": "http://www.dnd5eapi.co/api/spells/180"
      }

uid matching the url id. Convenience for those who may consume these resources to build out other tools. uid is pretty common for cross-references across data sets.

What does the uid fulfill that the URL does not? Why can't the URL be the identifier? Plus, if you use uid, the first spell will have uid=1; what will be the uid of the first proficiency if we continue that road? Will it be 1 too? Then the uid isn't really unique, is it?

from 5e-database.

benjaminapetersen avatar benjaminapetersen commented on July 21, 2024

The url could be used as a uid, correct, as it contains the "namespace" of spells.
in that sense id is better than uid, since there is no enforced counter across object types like a database might impose.

Having this aside form a url makes sense if the json files are consumed in a separate application rather than relying on http://www.dnd5eapi.co to serve. Seems these can be used conveniently either way.

Example could be consuming https://github.com/adrpadua/5e-database as a dependency via yarn install, npm install etc and then directly referencing the files & eliminating cross domain network calls.

from 5e-database.

benjaminapetersen avatar benjaminapetersen commented on July 21, 2024

Not a big deal, if someone is to import this into a database, the id/uid would likely be generated at that time!

from 5e-database.

bagelbits avatar bagelbits commented on July 21, 2024

I mean, if we wanted to have it be a bit more segregated from the API that is mostly defunct, we could drop http://www.dnd5eapi.co from all urls. But that is a separate discussion for another issue.

Anyways, I like that shape for the spell, I'm probably going to start a PR soon and do some of this work. Though I may split it into two PRs. One for Innate Spellcasting and one for Spellcasting. I'll tag you all when I get it up and running.

from 5e-database.

benjaminapetersen avatar benjaminapetersen commented on July 21, 2024

Agree, I would typically not include the base domain within the data itself. That is usually up in the app config layer.

Nice!

from 5e-database.

bagelbits avatar bagelbits commented on July 21, 2024

As an aside, I wonder for spells, whether it is worth exposing data for when a spell can be cast at a higher level.

from 5e-database.

ogregoire avatar ogregoire commented on July 21, 2024

That's part of the spell itself, not part of the spell list on monsters...

from 5e-database.

benjaminapetersen avatar benjaminapetersen commented on July 21, 2024

@bagelbits example https://github.com/adrpadua/5e-database/blob/master/5e-SRD-Spells.json#L8750

from 5e-database.

bagelbits avatar bagelbits commented on July 21, 2024

Sorry about that. Holidays happened. I finished the Innate Spellcasting PR. Haven't gotten to the Classic Spellcasting PR yet.

from 5e-database.

ogregoire avatar ogregoire commented on July 21, 2024

That's an excellent job! Congrats :-)

from 5e-database.

bagelbits avatar bagelbits commented on July 21, 2024

Cool. Now I'm trying to remember what exactly agreed on for Classic Spellcasting. I think it was this:

{
  "spellcasting": {
    "level": 1,
    "ability": {
      "name": "WIS",
      "url": "http://www.dnd5eapi.co/api/ability-scores/5"
    },
    "dc": 12,
    "modifier": 4,
    "school": "cleric",
    "slots": {
      "1": 3
    },
    "spells": [
      {
        "name": "Light",
        "level": 0,
        "url": "http://www.dnd5eapi.co/api/spells/180"
      },
      {
        "name": "Sacred Flame",
        "level": 0,
        "url": "http://www.dnd5eapi.co/api/spells/250"
      },
      {
        "name": "Thaumaturgy",
        "level": 0,
        "url": "http://www.dnd5eapi.co/api/spells/291"
      },
      {
        "name": "Bless",
        "level": 1,
        "url": "http://www.dnd5eapi.co/api/spells/29"
      },
      {
        "name": "Cure Wounds",
        "level": 1,
        "url": "http://www.dnd5eapi.co/api/spells/70"
      },
      {
        "name": "Sanctuary",
        "level": 1,
        "url": "http://www.dnd5eapi.co/api/spells/251"
      }
    ]
  }
}

I'm including the level as it drops what would be a common lookup pattern for figuring out what slots are being used.

from 5e-database.

bagelbits avatar bagelbits commented on July 21, 2024

@ogregoire @Alex-frazer @benjaminapetersen PR is up for the other half of this work.

from 5e-database.

bagelbits avatar bagelbits commented on July 21, 2024

Okay. I think is in a good state now. I'm open to other suggestions to improve it but I'll close this out.

from 5e-database.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.