5e-bits / 5e-bits/5e-database

Restructuring Rules.json

Aberta
#463 13 comentários 0 reações 0 responsáveis Ver no GitHub
Linguagem predominante
TypeScript
Estrelas
934
Forks
427
Merge médio
17h 25min
PRs com merge (30d)
22

Descrição

### Summary

Combines `Rules.json` and `Rule-Sections.json` into a single file with self-referential links according to the following format:

```javascript
[
{
"name": "System Reference Document 5.1",
"index": "srd",
"url": "/api/rules/srd"
"children": [
{
"name": "Combat",
"index": "combat",
"url": "/api/combat"
},
// ...
},
{
"name": "Combat",
"index": "combat",
"url": "/api/rules/combat"
"desc": "...",
"parent": {
"name": "System Reference Document 5.1",
"index": "srd",
"url": "/api/srd"
},
"children": [
{
"name": "The Order of Combat",
"index": "the-order-of-combat",
"url": "/api/the-order-of-combat"
},
// ...
},
// ...
]
```

---

*Original text follows.*

Currently the rules are spread across two files, as follows:

```javascript
// 5e-SRD-Rules.json
[
{
"name": "Combat",
"index": "combat",
"desc": "# Combat\n",
"subsections": [
{
"name": "The Order of Combat",
"index": "the-order-of-combat",
"url": "/api/rule-sections/the-order-of-combat"
},
// ...
],
"url": "/api/rules/combat"
}
]

// 5e-SRD-Rule-Sections.json
[
{
"name": "The Order of Combat",
"index": "the-order-of-combat",
"desc": "## The Order of Combat\n\nA typical combat encounter is a clash between two sides, a flurry of weapon swings, feints, parries, footwork, and spellcasting. The game organizes the chaos of combat into a cycle of rounds and turns. A **round** represents about 6 seconds in the game world. During a round, each participant in a battle takes a **turn**. The order of turns is determined at the beginning of a combat encounter, when everyone rolls initiative. Once everyone has taken a turn, the fight continues to the next round if neither side has defeated the other.\n\n##### Combat Step by Step\n\n...",
"url": "/api/rule-sections/the-order-of-combat"
},
// ...
]
```

However, the current situation doesn't do a particularly good job of representing the data in either a human- or machine-readable format. For my own use case, I'd like to have much smaller text snippets for reference purposes, so that a user could search for "Bonus Actions" and see only the snippet . Most of the data from the SRD is digested into bite-sized pieces, so it's rather out of place to have these giant blobs of text in `5e-SRD-Rule-Sections.json`.

I suggest consolidating the rules down into a single file, with each heading getting its own entry.

```javascript
// 5e-SRD-Rules.json
[
{
"name": "Combat",
"index": "combat",
// no "desc" key at all as this heading continues directly into "The Order of Combat"
"subsections": [
{
"name": "The Order of Combat",
"index": "the-order-of-combat",
"url": "/api/rules/the-order-of-combat"
},
// ...
],
"url": "/api/rules/combat"
},
{
"name": "The Order of Combat",
"index": "the-order-of-combat",
// No title, includes all content to the next subheading
"desc": "A typical combat encounter is a clash between two sides, a flurry of weapon swings, feints, parries, footwork, and spellcasting. The game organizes the chaos of combat into a cycle of rounds and turns. A **round** represents about 6 seconds in the game world. During a round, each participant in a battle takes a **turn**. The order of turns is determined at the beginning of a combat encounter, when everyone rolls initiative. Once everyone has taken a turn, the fight continues to the next round if neither side has defeated the other.",
"subsections": [
{
"name": "Combat Step by Step",
"index": "combat-step-by-step",
"url": "/api/rules/combat-step-by-step"
},
// ...
],
"url": "/api/rule/the-order-of-combat"
},
{
"name": "Combat Step by Step",
"index": "combat-step-by-step",
"desc": "..."
"url": "/api/rules/combat-step-by-step"
// ...
]
```

Alternatively, a `parent_url` field could be added to the child rather than the `subsections` field on the parent. Either way, it would have to be associated with tests ensuring that there are no circular dependencies, there is only one root node, and there are no orphaned nodes. A bidirectional association is also possible for easier reading, but that would require extra test coverage to maintain consistency.

Guia de contribuição

Abrir o guia de contribuição

Direção de pesquisa

Examine the existing 5e-SRD-Rules.json and 5e-SRD-Rule-Sections.json files to understand the current data structure. The task is to merge them into a single file with a hierarchical format using parent/children or subsections. Write tests to ensure no circular dependencies, a single root node, and no orphaned nodes. Check the repository for any existing test patterns for JSON data validation.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
json, typescript
Domínio
backend-api-design, data
Tipo de issue
Refatoração
Dificuldade
3/5
Tempo estimado
1-2 dias
Status de atividade
Estagnada
Clareza
Razoavelmente clara
Facilidade para iniciantes
45/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.