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

feat: Convert spells units from strings to objects

Open tognee opened this issue 4 years ago • 20 comments

What does this do?

Convert all hardcoded english strings to usable data. Useful for possible future localization.

-1 is used to identify infinity or an unspecified amount.

When an unit is not applicable or not specific enough a _type variable is introduced (eg. range_type, duration_type)

How was it tested?

<It's not clear if I don't update this text with relevant info>

Is there a Github issue this is resolving?

<It's not clear if I don't update this text with relevant info>

Did you update the docs in the API? Please link an associated PR if applicable.

<It's not clear if I don't update this text with relevant info>

Here's a fun image for your troubles

random photo - update me

tognee avatar Dec 28 '20 13:12 tognee

drive by review

Looks like this would add a new convention for how time durations are dealt with. Would it make sense to define a new model in the API for Duration? (similar to Cost)

EDIT: on a similar note, we might want to define a model for Distance to handle the distance/range values here

ecshreve avatar Dec 28 '20 14:12 ecshreve

Why use abbreviations? Why is the abbreviation superior to the full name? This is a real question: I'm not for abbreviations nor against, but I'm genuinely questioning why you chose abbreviations instead of the full name?

ogregoire avatar Dec 30 '20 15:12 ogregoire

Other question: why not use a uniform domain like this:

{
  type: feet
  amount: 1
}
{
  type: hour
  amount: 1 // or quantity or...
  qualifier: "up to" // or "or less" or "<="
}
{
  type: "until disspelled"
}

We already know it's a duration, distance, ... because of the duration, range, distance field.

ogregoire avatar Dec 30 '20 15:12 ogregoire

Why use abbreviations? Why is the abbreviation superior to the full name? This is a real question: I'm not for abbreviations nor against, but I'm genuinely questioning why you chose abbreviations instead of the full name?

The convention was discussed some time ago on the discord server, I've used that.

tognee avatar Dec 30 '20 15:12 tognee

To be fair, I believe the singular/plural was only mentioned once on this discord server, and wasn't discussed any further than one suggestion from bunglero#2838.

The original reasoning by bunglero was that abbreviations don't need to be pluralised. He did also offer the solution of always pluralising. Personally, I disagree with the idea of using abbreviations to mitigate the issue of pluralisation; I'd be more inclined to forgo abbreviations in favour of full forms, either always singular (my preference) or always plural, for consistency.

This structure is designed to be easily digested by a computer, right? So human-readability should be a second priority, imo; we don't need to worry about the difference between 5 hour and 5 hours. If we really want to supply a grammatically valid English duration, perhaps it should be a separate field, such as a desc attribute on the Duration structure, which contains the source text from the SRD?

fergcb avatar Dec 30 '20 15:12 fergcb

Other question: why not use a uniform domain like this: ... We already know it's a duration, distance, ... because of the duration, range, distance field.

@ogregoire This is effectively what I already suggested in one of my review comments, except renaming unit to type. Something on this pattern would remove the need for the additional _type fields.

fergcb avatar Dec 30 '20 16:12 fergcb

If you need to convert feet and miles to meters having unit (or type of you want to rename it) take up something that isn't a measurement unit can be confusing

tognee avatar Dec 30 '20 16:12 tognee

If you need to convert feet and miles to meters having unit (or type of you want to rename it) take up something that isn't a measurement unit can be confusing

@tognee Why would someone be converting feet and miles into meters in D&D 5e? The game exclusively uses imperial unit names.

fergcb avatar Dec 30 '20 16:12 fergcb

Why would someone be converting feet and miles into meters in D&D 5e?

I'm italian and started playing recently, the italian (and I think also all the other countries that doesn't use the imperial system) translations of the SRD uses meters as a measurement unit by multiplying feet values by 0.3

If we want to localize the database with other languages this needs to be taken in consideration

tognee avatar Dec 30 '20 16:12 tognee

If we want to localize the database with other languages this needs to be taken in consideration

If we want to localize measurements like this in the database (note that there are no official translations of the SRD to use as a basis for decisions like this), the solution is trivial; check if the unit/type is a translatable unit (e.g. foot, mile etc.), and if it is, translate it accordingly. As it stands the special units being proposed here, like until-dispelled or instantaneous, aren't measurements of distance but of time, and therefore wouldn't need to be translated this way, anyway - units of time are far more universal than those of distance.

For example, your PR already contains the action "unit".

fergcb avatar Dec 30 '20 16:12 fergcb

Other question: why not use a uniform domain like this: ... We already know it's a duration, distance, ... because of the duration, range, distance field.

@ogregoire This is effectively what I already suggested in one of my review comments, except renaming unit to type. Something on this pattern would remove the need for the additional _type fields.

No, my take on that is to use qualifier: "up to" (or something else), rather than a boolean. With your solution, we could have at_least: true and at_most: true. Those are kind of mutually exclusive in the SRD, so it's best to have an enum or at least different values grouping those mutually exclusive ideas into one.

ogregoire avatar Dec 30 '20 16:12 ogregoire

If I understood the game correctly an action unit should be 6 seconds, I think that can be kept like that. until-dispelled can't be translated as an unit because it's based on the player actions. instantaneous can be translated to 0 seconds but I don't consider it a unit as you can't have more than 1 instantaneous.

I'm looking at the data as something that can be used to manage a game, if that's not the scope of this database then I misunderstood it.

My longterm plan is using the database to help me play games of DnD5e in my language (italian) and making data detached from english grammar can help me get there.

tognee avatar Dec 30 '20 16:12 tognee

No, my take on that is to use qualifier: "up to" (or something else), rather than a boolean. With your solution, we could have at_least: true and at_most: true.

Sure, you had two ideas going on in your suggestion. I was talking about the other, relating to the use of type.

fergcb avatar Dec 30 '20 16:12 fergcb

If I understood the game correctly an action unit should be 6 seconds, I think that can be kept like that. until-dispelled can't be translated as an unit because it's based on the player actions. instantaneous can be translated to 0 seconds but I don't consider it a unit as you can't have more than 1 instantaneous.

@tognee You're missing the point. Units of time don't have to be translated in the same way as units of distance would.

A second in English is a second in Italian, is a second in Chinese.

Unless we're translating the API into some language that measures time in flimflarks or something, introducing inconvertible "units" like instant is a non-issue.

fergcb avatar Dec 30 '20 16:12 fergcb

I was thinking of it in a logic standpoint more than a language standpoint regarding time units

tognee avatar Dec 30 '20 16:12 tognee

Other question: why not use a uniform domain like this:

{
  type: feet
  amount: 1
}
{
  type: hour
  amount: 1 // or quantity or...
  qualifier: "up to" // or "or less" or "<="
}
{
  type: "until disspelled"
}

We already know it's a duration, distance, ... because of the duration, range, distance field.

I really like the elegance of @ogregoire's suggestion. It also gives us a consistent shape. Which makes both GraphQL and Documentation easier.

bagelbits avatar Jan 03 '21 08:01 bagelbits

@tognee Have you had a chance to look at this any more? It's okay if you don't time anymore.

bagelbits avatar Jan 31 '21 10:01 bagelbits

Didn't had time due to university stuff. Might continue after the exams

tognee avatar Feb 02 '21 09:02 tognee

I found some time to finish this pull request, now it should follow the suggested format

tognee avatar Mar 04 '23 11:03 tognee

@SleeplessOne1917 atting myself here so I'll hopefully be notified when this merges and I can update the GraphQL API to support this change.

SleeplessOne1917 avatar Mar 19 '23 14:03 SleeplessOne1917