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

Restructuring Rules.json

未关闭
#463 13 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
TypeScript
星标
934
派生
427
平均合并
17 小时 25 分钟
30 天内合并 PR
22

描述

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

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。