Skip to content

Commit

Permalink
Fix split random tables
Browse files Browse the repository at this point in the history
  • Loading branch information
dprothero committed Mar 15, 2024
1 parent 686acf9 commit 335f29c
Show file tree
Hide file tree
Showing 10 changed files with 168 additions and 96 deletions.
50 changes: 32 additions & 18 deletions LGMRD.md
Original file line number Diff line number Diff line change
Expand Up @@ -1164,12 +1164,16 @@ The challenge ratings described in these templates are loose guides, so use your

Apply this template to any monster to make an elemental version of that monster. Choose from or roll on the following table to determine the type of elemental template you want to apply:

| d8 | Elemental Template | d8 | Elemental Template |
| -- | ------------------ | -- | ------------------ |
| 1 | Fire | 5 | Poison |
| 2 | Cold | 6 | Necrotic |
| 3 | Lighting | 7 | Radiant |
| 4 | Acid | 8 | Thunder |
| d8 | Elemental Template |
| -- | ------------------ |
| 1 | Fire |
| 2 | Cold |
| 3 | Lighting |
| 4 | Acid |
| 5 | Poison |
| 6 | Necrotic |
| 7 | Radiant |
| 8 | Thunder |

Then choose one or more of the following traits to customize your monster, making use of the damage type determined by the elemental template:

Expand Down Expand Up @@ -1219,18 +1223,28 @@ Some monsters can innately cast magical spells. Spell-infused monsters typically

Spell-infused creatures do not require components to cast their spells. They typically use each of their spells once, recovering the ability to do so when they finish a long rest. Roll for or choose from the table to determine which spells a creature can use. Spells that deal high damage can affect a creature's challenge rating.

| d20 | Spell | d20 | Spell |
| --- | -------------- | --- | ---------------- |
| 1 | Burning hands | 11 | Invisibility |
| 2 | Magic missile | 12 | Misty step |
| 3 | Disguise self | 13 | Scorching ray |
| 4 | Fog cloud | 14 | Shatter |
| 5 | Shield | 15 | Spirit guardians |
| 6 | Inflict wounds | 16 | Dispel magic |
| 7 | Faerie fire | 17 | Fly |
| 8 | Thunderwave | 18 | Gaseous form |
| 9 | Blur | 19 | Lightning bolt |
| 10 | Darkness | 20 | Fireball |
| d20 | Spell |
| --- | ---------------- |
| 1 | Burning hands |
| 2 | Magic missile |
| 3 | Disguise self |
| 4 | Fog cloud |
| 5 | Shield |
| 6 | Inflict wounds |
| 7 | Faerie fire |
| 8 | Thunderwave |
| 9 | Blur |
| 10 | Darkness |
| 11 | Invisibility |
| 12 | Misty step |
| 13 | Scorching ray |
| 14 | Shatter |
| 15 | Spirit guardians |
| 16 | Dispel magic |
| 17 | Fly |
| 18 | Gaseous form |
| 19 | Lightning bolt |
| 20 | Fireball |

## <a id="undeadtemplates"></a>Undead Templates

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ LGMRD is officially pronounced "Lymm Grid" and LGMMBRD "Lymm Bard".
### The Lazy GM's Resource Document

- [HTML](https://github.com/crit-tech/LGMRD/blob/main/LGMRD.html) **Updated: <span id="html-last-updated">Thu, 08 Feb 2024 02:14:22 GMT</span>**
- [All-in-one Markdown](https://github.com/crit-tech/LGMRD/blob/main/LGMRD.md) **Updated: <span id="markdown-last-updated">Sun, 10 Mar 2024 23:21:26 GMT</span>**
- [Separate Markdown](https://github.com/crit-tech/LGMRD/tree/main/markdown_separate) files **Updated: <span id="markdown_separate-last-updated">Fri, 15 Mar 2024 00:39:57 GMT</span>**
- [Markdown for Obsidian](https://github.com/crit-tech/LGMRD/tree/main/markdown_obsidian) **Updated: <span id="markdown_obsidian-last-updated">Fri, 15 Mar 2024 00:39:58 GMT</span>**
- [All-in-one Markdown](https://github.com/crit-tech/LGMRD/blob/main/LGMRD.md) **Updated: <span id="markdown-last-updated">Fri, 15 Mar 2024 02:06:34 GMT</span>**
- [Separate Markdown](https://github.com/crit-tech/LGMRD/tree/main/markdown_separate) files **Updated: <span id="markdown_separate-last-updated">Fri, 15 Mar 2024 02:11:52 GMT</span>**
- [Markdown for Obsidian](https://github.com/crit-tech/LGMRD/tree/main/markdown_obsidian) **Updated: <span id="markdown_obsidian-last-updated">Fri, 15 Mar 2024 02:11:53 GMT</span>**
- [JSON](https://github.com/crit-tech/LGMRD/blob/main/LGMRD.json) **Updated: <span id="json-last-updated">Fri, 15 Mar 2024 00:39:58 GMT</span>**
- [NPM](https://www.npmjs.com/package/@crit-tech/lgmrd) **Updated: <span id="json-last-updated">Fri, 15 Mar 2024 00:39:58 GMT</span>**
- [PDF](https://github.com/crit-tech/LGMRD/blob/main/LGMRD.pdf) **Updated: <span id="pdf-last-updated">Thu, 08 Feb 2024 02:14:24 GMT</span>**
Expand Down
54 changes: 32 additions & 22 deletions markdown_obsidian/21 - Monster Templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@ The challenge ratings described in these templates are loose guides, so use your

Apply this template to any monster to make an elemental version of that monster. Choose from or roll on the following table to determine the type of elemental template you want to apply:

**Elemental Template: **`dice: [[21 - Monster Templates#^elemental-monsters]]|Elemental Template`
**d8: **`dice: [[21 - Monster Templates#^elemental-monsters]]|d8`
**Elemental Template: **`dice: [[21 - Monster Templates#^elemental-monsters]]|Elemental Template`

| d8 | Elemental Template | d8 | Elemental Template |
| -- | ------------------ | -- | ------------------ |
| 1 | Fire | 5 | Poison |
| 2 | Cold | 6 | Necrotic |
| 3 | Lighting | 7 | Radiant |
| 4 | Acid | 8 | Thunder |
| d8 | Elemental Template |
| -- | ------------------ |
| 1 | Fire |
| 2 | Cold |
| 3 | Lighting |
| 4 | Acid |
| 5 | Poison |
| 6 | Necrotic |
| 7 | Radiant |
| 8 | Thunder |

^elemental-monsters

Expand Down Expand Up @@ -69,21 +71,29 @@ Some monsters can innately cast magical spells. Spell-infused monsters typically

Spell-infused creatures do not require components to cast their spells. They typically use each of their spells once, recovering the ability to do so when they finish a long rest. Roll for or choose from the table to determine which spells a creature can use. Spells that deal high damage can affect a creature's challenge rating.

**Spell: **`dice: [[21 - Monster Templates#^spell-infused-monsters]]|Spell`
**d20: **`dice: [[21 - Monster Templates#^spell-infused-monsters]]|d20`
**Spell: **`dice: [[21 - Monster Templates#^spell-infused-monsters]]|Spell`

| d20 | Spell | d20 | Spell |
| --- | -------------- | --- | ---------------- |
| 1 | Burning hands | 11 | Invisibility |
| 2 | Magic missile | 12 | Misty step |
| 3 | Disguise self | 13 | Scorching ray |
| 4 | Fog cloud | 14 | Shatter |
| 5 | Shield | 15 | Spirit guardians |
| 6 | Inflict wounds | 16 | Dispel magic |
| 7 | Faerie fire | 17 | Fly |
| 8 | Thunderwave | 18 | Gaseous form |
| 9 | Blur | 19 | Lightning bolt |
| 10 | Darkness | 20 | Fireball |
| d20 | Spell |
| --- | ---------------- |
| 1 | Burning hands |
| 2 | Magic missile |
| 3 | Disguise self |
| 4 | Fog cloud |
| 5 | Shield |
| 6 | Inflict wounds |
| 7 | Faerie fire |
| 8 | Thunderwave |
| 9 | Blur |
| 10 | Darkness |
| 11 | Invisibility |
| 12 | Misty step |
| 13 | Scorching ray |
| 14 | Shatter |
| 15 | Spirit guardians |
| 16 | Dispel magic |
| 17 | Fly |
| 18 | Gaseous form |
| 19 | Lightning bolt |
| 20 | Fireball |

^spell-infused-monsters
50 changes: 32 additions & 18 deletions markdown_separate/21-monstertemplates.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ The challenge ratings described in these templates are loose guides, so use your

Apply this template to any monster to make an elemental version of that monster. Choose from or roll on the following table to determine the type of elemental template you want to apply:

| d8 | Elemental Template | d8 | Elemental Template |
| -- | ------------------ | -- | ------------------ |
| 1 | Fire | 5 | Poison |
| 2 | Cold | 6 | Necrotic |
| 3 | Lighting | 7 | Radiant |
| 4 | Acid | 8 | Thunder |
| d8 | Elemental Template |
| -- | ------------------ |
| 1 | Fire |
| 2 | Cold |
| 3 | Lighting |
| 4 | Acid |
| 5 | Poison |
| 6 | Necrotic |
| 7 | Radiant |
| 8 | Thunder |

Then choose one or more of the following traits to customize your monster, making use of the damage type determined by the elemental template:

Expand Down Expand Up @@ -65,15 +69,25 @@ Some monsters can innately cast magical spells. Spell-infused monsters typically

Spell-infused creatures do not require components to cast their spells. They typically use each of their spells once, recovering the ability to do so when they finish a long rest. Roll for or choose from the table to determine which spells a creature can use. Spells that deal high damage can affect a creature's challenge rating.

| d20 | Spell | d20 | Spell |
| --- | -------------- | --- | ---------------- |
| 1 | Burning hands | 11 | Invisibility |
| 2 | Magic missile | 12 | Misty step |
| 3 | Disguise self | 13 | Scorching ray |
| 4 | Fog cloud | 14 | Shatter |
| 5 | Shield | 15 | Spirit guardians |
| 6 | Inflict wounds | 16 | Dispel magic |
| 7 | Faerie fire | 17 | Fly |
| 8 | Thunderwave | 18 | Gaseous form |
| 9 | Blur | 19 | Lightning bolt |
| 10 | Darkness | 20 | Fireball |
| d20 | Spell |
| --- | ---------------- |
| 1 | Burning hands |
| 2 | Magic missile |
| 3 | Disguise self |
| 4 | Fog cloud |
| 5 | Shield |
| 6 | Inflict wounds |
| 7 | Faerie fire |
| 8 | Thunderwave |
| 9 | Blur |
| 10 | Darkness |
| 11 | Invisibility |
| 12 | Misty step |
| 13 | Scorching ray |
| 14 | Shatter |
| 15 | Spirit guardians |
| 16 | Dispel magic |
| 17 | Fly |
| 18 | Gaseous form |
| 19 | Lightning bolt |
| 20 | Fireball |
6 changes: 3 additions & 3 deletions metadata/updates.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"markdown": "2024-03-10T23:21:26.543Z",
"markdown_separate": "2024-03-15T00:39:57.825Z",
"markdown": "2024-03-15T02:06:34.682Z",
"markdown_separate": "2024-03-15T02:11:52.524Z",
"json": "2024-03-15T00:39:58.871Z",
"html": "2024-02-08T02:14:22.742Z",
"pdf": "2024-02-08T02:14:24.868Z",
Expand All @@ -11,6 +11,6 @@
"mb-markdown": "2024-03-10T23:21:27.774Z",
"mb-markdown_separate": "2024-03-15T00:40:01.262Z",
"mb-json": "2024-03-15T00:40:01.862Z",
"markdown_obsidian": "2024-03-15T00:39:58.360Z",
"markdown_obsidian": "2024-03-15T02:11:53.171Z",
"mb-markdown_obsidian": "2024-03-15T00:40:01.661Z"
}
15 changes: 4 additions & 11 deletions src/formats/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,11 @@ import { defaultHandlers, State } from "hast-util-to-mdast";
import remarkGfm from "remark-gfm";
import remarkStringify from "remark-stringify";
import { Heading as MarkdownHeading } from "mdast";
import { Root } from "mdast";

import getHtmlPlugin from "../utils/html.js";
import removePosition from "../utils/removePosition.js";
import { DocType, OUTPUT_PATH } from "../utils/constants.js";

function getMarkdownPlugin(callback: (tree: Root) => void) {
return () => {
return (tree: Root) => {
callback(tree);
};
};
}
import { getMarkdownPlugin, columnSmasherPlugin } from "../utils/markdown.js";

function getHeadingHandler(tagName: string) {
return (state: State, node: any) => {
Expand Down Expand Up @@ -57,7 +49,7 @@ export async function convertToMarkdown(
);
});

const markdownPlugin = getMarkdownPlugin((tree) => {
const saveSyntaxTreePlugin = getMarkdownPlugin((tree) => {
const treeCopy = removePosition(tree);
fs.writeFileSync(
path.join(OUTPUT_PATH, "metadata", `${docType}_mdast.json`),
Expand All @@ -77,7 +69,8 @@ export async function convertToMarkdown(
.use(htmlPlugin)
.use(rehypeRemark, rehypeRemarkOptions)
.use(remarkGfm)
.use(markdownPlugin)
.use(saveSyntaxTreePlugin)
.use(columnSmasherPlugin)
.use(remarkStringify)
.process(html);

Expand Down
4 changes: 2 additions & 2 deletions src/formats/markdownObsidian.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
TODO:
- [X] Both - Order the pages by the order they appear in the book
- [ ] Both - Change detection not working (thinks it's new each time)
- [ ] LGMRD - Monster templates (has two-column tables)
- [X] Both - Change detection not working (thinks it's new each time)
- [X] LGMRD - Monster templates (has two-column tables)
- [ ] LGMRD - Random items / Potions of healing - has table rows with ranges
- [ ] LGMMBRD - General purpose statblocks
- [ ] LGMMBRD - Monsters by Adventure Location has broken tables (also for regular markdown)
Expand Down
6 changes: 5 additions & 1 deletion src/formats/markdownSeparate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ import { visit } from "unist-util-visit";

import { rehypeRemarkOptions } from "./markdown.js";
import { DocType, MARKDOWN_SEPARATE_PATHS } from "../utils/constants.js";
import { getAndDeletePreviousMarkdown } from "../utils/markdown.js";
import {
getAndDeletePreviousMarkdown,
columnSmasherPlugin,
} from "../utils/markdown.js";

interface Section {
sectionName: string;
Expand Down Expand Up @@ -59,6 +62,7 @@ export async function convertToMarkdownSeparate(
.use(rehypeParse)
.use(rehypeRemark, rehypeRemarkOptions)
.use(remarkGfm)
.use(columnSmasherPlugin)
.use(sectionCapturePlugin)
.use(remarkStringify)
.process(html);
Expand Down
36 changes: 18 additions & 18 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ async function createOutput(docType: DocType) {
logUpdate(docType, "html");
}

if (
html !== prevHtml ||
!fs.existsSync(path.join(OUTPUT_PATH, `${docType}.pdf`))
) {
await convertToPdf(docType, html);
logUpdate(docType, "pdf");
}
// if (
// html !== prevHtml ||
// !fs.existsSync(path.join(OUTPUT_PATH, `${docType}.pdf`))
// ) {
// await convertToPdf(docType, html);
// logUpdate(docType, "pdf");
// }

const epubPath = path.join(OUTPUT_PATH, `${docType}.epub`);
if (html !== prevHtml || !fs.existsSync(epubPath)) {
await convertToEpub(docType, filePath, epubPath);
logUpdate(docType, "epub");
}
// const epubPath = path.join(OUTPUT_PATH, `${docType}.epub`);
// if (html !== prevHtml || !fs.existsSync(epubPath)) {
// await convertToEpub(docType, filePath, epubPath);
// logUpdate(docType, "epub");
// }

const markdownUpdated = await convertToMarkdown(docType, html);
if (markdownUpdated) {
Expand All @@ -60,17 +60,17 @@ async function createOutput(docType: DocType) {
logUpdate(docType, "markdown_obsidian");
}

const jsonUpdated = await convertToJson(docType);
if (jsonUpdated) {
logUpdate(docType, "json");
}
// const jsonUpdated = await convertToJson(docType);
// if (jsonUpdated) {
// logUpdate(docType, "json");
// }

await publishJsonPackage(docType);
// await publishJsonPackage(docType);
}

async function run() {
await createOutput("LGMRD");
await createOutput("5e_Monster_Builder");
// await createOutput("5e_Monster_Builder");
}

run();
Loading

0 comments on commit 335f29c

Please sign in to comment.