Coder Social home page Coder Social logo

Can some values be null? about 5e-database HOT 13 CLOSED

5e-bits avatar 5e-bits commented on July 21, 2024
Can some values be null?

from 5e-database.

Comments (13)

bagelbits avatar bagelbits commented on July 21, 2024

Technically four options if you count:

 {
 	"index": 12,
 	"name": "Deep Speech",
 	"type": "Exotic",
 	"typical_speakers": ["Aboleths", "Cloakers"],
 	"script": "",
 	"url": "http://www.dnd5eapi.co/api/languages/12"
 }

I'd honestly be fine with either that or null. Though, it looks like we're not consistent on either approach. It might be worth considering?

from 5e-database.

bagelbits avatar bagelbits commented on July 21, 2024

I think in this case, null makes more sense than "". But it is probably worth looking into the inconsistent usage elsewhere.

from 5e-database.

bagelbits avatar bagelbits commented on July 21, 2024

@ogregoire I'll throw up a quick PR for the Languages. But I ran into two other cases where we use "" instead of null.

Case 1:

{
  "level_acquired": 7,
  "spell_acquisition_method": {
    "name": "level",
    "url": ""
  },
  "prerequisites": [],
  "spell": {
    "url": "http://www.dnd5eapi.co/api/spells/71",
    "name": "Death Ward"
  }
}

spell_acquisition_method has a url but that doesn't exist because we don't have it. It probably makes more sense to drop the field entirely?

Case 2:

	"subtype": "",
	"alignment": "lawful evil",
	"armor_class": 17,
	"hit_points": 135,
	"hit_dice": "18d10",
	"speed": "10 ft., swim 40 ft.",
	"strength": 21,
	"dexterity": 9,
	"constitution": 15,
	"intelligence": 18,
	"wisdom": 15,
	"charisma": 18,
	"constitution_save": 6,
	"intelligence_save": 8,
	"wisdom_save": 6,
	"history": 12,
	"perception": 10,
	"damage_vulnerabilities": "",
	"damage_resistances": "",
	"damage_immunities": "",
	"condition_immunities": "",

subtype, damage_vulnerabilities, damage_resistances, damage_immunities, and condition_immunities are often set to "". I wonder if it makes more sense to convert the values to null?

What do you think? I'd like another opinion.

from 5e-database.

bagelbits avatar bagelbits commented on July 21, 2024

Hmmm. I guess for Case 2, the fields with input look like this:

"subtype": "human",
"damage_vulnerabilities": "fire",
"damage_resistances": "necrotic",
"damage_immunities": "lightning, poison",
"condition_immunities": "charmed, exhaustion, frightened, paralyzed, poisoned",

Which raises some other questions that I don't really want to answer right now.

from 5e-database.

ogregoire avatar ogregoire commented on July 21, 2024

For the case 2, I believe that for vulnerabilities, resistances and immunities, lists (and therefore empty lists) should be used instead of "".

The field "spell_acquisition_method" doesn't make any sense as it says how one gets a specific spell. It should better be in a level object that says "new_spells" or something similar, with the prerequisistes written there if need be.

This only leaves the "subtype" field, which in my view can be null (or absent) if the value isn't applicable.

The last two instances of "" are in the "Scrying" spell "desc" field. That field can easily be rewritten.

Going the route of having optional fields would probably require a kind of JSON Schema and JSONschema.net to keep consistency and making it easier to read and parse. Each file would have its schema, in that case.

from 5e-database.

bagelbits avatar bagelbits commented on July 21, 2024

For the case 2, I believe that for vulnerabilities, resistances and immunities, lists (and therefore empty lists) should be used instead of "".

That's how I was feeling as well.

The field "spell_acquisition_method" doesn't make any sense as it says how one gets a specific spell. It should better be in a level object that says "new_spells" or something similar, with the prerequisistes written there if need be.

This will probably need a bit more refinement to get right but if you want to take a stab at it, I'd love to see what you're thinking.

This only leaves the "subtype" field, which in my view can be null (or absent) if the value isn't applicable.

I agree!

The last two instances of "" are in the "Scrying" spell "desc" field. That field can easily be rewritten.

Yeah. Should be pretty simple

Going the route of having optional fields would probably require a kind of JSON Schema and JSONschema.net to keep consistency and making it easier to read and parse. Each file would have its schema, in that case.

We could probably go that route but I'm not married to that idea yet. Maybe in V2. 😅

from 5e-database.

bagelbits avatar bagelbits commented on July 21, 2024

I didn't try to do these yet:

	"damage_vulnerabilities": "",
	"damage_resistances": "",
	"damage_immunities": "",
	"condition_immunities": "",

Because there are some interesting choices on wording for some of those properties.

from 5e-database.

bagelbits avatar bagelbits commented on July 21, 2024

I'm also wondering if we should do something similar for senses and languages in monsters.

from 5e-database.

bagelbits avatar bagelbits commented on July 21, 2024

@ogregoire Yeah. I'm not sure what to do with something like this:

"damage_resistances": "bludgeoning, piercing, and slashing from nonmagical weapons",

I'm not sure if it makes sense to do one of these three things:

#1
"damage_resistances": ["bludgeoning, piercing, and slashing from nonmagical weapons"],
#2
"damage_resistances": ["bludgeoning from nonmagical weapons", "piercing from nonmagical weapons", "slashing from nonmagical weapons"]
#3
"damage_resistances": ["nonmagical bludgeoning", "nonmagical piercing, "nonmagical slashing"],

I'm leaning towards the first one just to keep it consistent with the SRD text but I could be convinced otherwise.

from 5e-database.

bagelbits avatar bagelbits commented on July 21, 2024

Even better:

bludgeoning, piercing, and slashing from nonmagical weapons that aren't silvered

😂

from 5e-database.

bagelbits avatar bagelbits commented on July 21, 2024

Oh wow:

"piercing and slashing from nonmagical weapons that aren't adamantine"

Yeah, I'm just going to go with the first one for now.

from 5e-database.

ogregoire avatar ogregoire commented on July 21, 2024

The basic idea was to cleanup which is now done.

from 5e-database.

bagelbits avatar bagelbits commented on July 21, 2024

Thank you for your help!

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.