Skip to content

Commit

Permalink
v2.5.6
Browse files Browse the repository at this point in the history
  • Loading branch information
TheGiddyLimit committed Dec 9, 2024
1 parent 787b970 commit 0b750e5
Show file tree
Hide file tree
Showing 10 changed files with 97 additions and 49 deletions.
9 changes: 6 additions & 3 deletions data/adventure/adventure-uthftlh.json
Original file line number Diff line number Diff line change
Expand Up @@ -1893,7 +1893,8 @@
"{@action Utilize|XPHB}"
]
}
]
],
"id": "03e"
},
{
"type": "section",
Expand All @@ -1915,7 +1916,8 @@
"{@creature Bullywug Bog Sage|XMM}*"
]
}
]
],
"id": "03f"
},
{
"type": "section",
Expand Down Expand Up @@ -2116,7 +2118,8 @@
"{@spell Vitriolic Sphere|XPHB}"
]
}
]
],
"id": "040"
},
{
"type": "section",
Expand Down
5 changes: 5 additions & 0 deletions data/changelog.json
Original file line number Diff line number Diff line change
Expand Up @@ -2877,5 +2877,10 @@
"ver": "2.5.5",
"date": "2024-12-08",
"txt": "- Added DMG'24 loot tables to Items page \"Found On\" filter\n- Made various accessibility tweaks to the navbar\n- (Brew) Added `\"_copy\"` support for `\"subrace\"`s\n- (Brew) Fixed rendering of creature `\"tool\"` rollers and hover text; XP for non-standard CRs; initiative for `\"special\"` dexterity scores\n- (Brew) Fixed initial load crash on malformed class spell list name\n- (Brew) Fixed initial item load crash when offline\n- (Brew) Fixed \"copy existing spell list\" class/subclass spells failing to be added if more than one class/subclass applied to a single spell\n- (Fixed typos/added tags)"
},
{
"ver": "2.5.6",
"date": "2024-12-09",
"txt": "- Fixed crash when loading the Lootgen page - (Fixed typos/added tags)"
}
]
2 changes: 1 addition & 1 deletion data/races.json
Original file line number Diff line number Diff line change
Expand Up @@ -5366,7 +5366,7 @@
"type": "item",
"name": "Forest Gnome",
"entries": [
"You know the Minor {@variantrule Illusions|XPHB|Illusion} cantrip. You also always have the Speak with Animals spell prepared. You can cast it without a spell slot a number of times equal to your {@variantrule Proficiency|XPHB|Proficiency Bonus}, and you regain all expended uses when you finish a {@variantrule Long Rest|XPHB}. You can also use any spell slots you have to cast the spell."
"You know the {@spell Minor Illusion|XPHB} cantrip. You also always have the {@spell Speak with Animals|XPHB} spell prepared. You can cast it without a spell slot a number of times equal to your {@variantrule Proficiency|XPHB|Proficiency Bonus}, and you regain all expended uses when you finish a {@variantrule Long Rest|XPHB}. You can also use any spell slots you have to cast the spell."
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions js/lootgen/lootgen-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export class LootGenUi extends BaseComponent {
.flatMap(theme => {
return ["Common", "Uncommon", "Rare", "Very Rare", "Legendary"]
.map(rarity => ({
name: `${theme} Tables; ${theme} - ${rarity}`,
name: `${theme} - ${rarity}`,
type: `${theme.toLowerCase()}.${rarity.toLowerCase()}`,
theme,
rarity,
Expand Down Expand Up @@ -237,7 +237,7 @@ export class LootGenUi extends BaseComponent {
rarity,
tableEntry,
table: this._data.magicItems.find(it => it.type === type),
tag: `{@table ${theme} Tables; ${theme} - ${rarity}|XDMG|${theme} - ${rarity}}`,
tag: `{@table ${theme} - ${rarity}|XDMG|${theme} - ${rarity}}`,
};
}),
...tablesMagicItemsDmg.map(({type, tableEntry}) => {
Expand Down
2 changes: 1 addition & 1 deletion js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// in deployment, `IS_DEPLOYED = "<version number>";` should be set below.
globalThis.IS_DEPLOYED = undefined;
globalThis.VERSION_NUMBER = /* 5ETOOLS_VERSION__OPEN */"2.5.5"/* 5ETOOLS_VERSION__CLOSE */;
globalThis.VERSION_NUMBER = /* 5ETOOLS_VERSION__OPEN */"2.5.6"/* 5ETOOLS_VERSION__CLOSE */;
globalThis.DEPLOYED_IMG_ROOT = undefined;
// for the roll20 script to set
globalThis.IS_VTT = false;
Expand Down
77 changes: 53 additions & 24 deletions node/tag-adventure-book-areas.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import fs from "fs";
import * as ut from "./util.js";
import "../js/parser.js";
import "../js/utils.js";
import "../js/render.js";
import {Command} from "commander";
import {getAllJson} from "./util-json-files.js";
import {writeJsonSync} from "5etools-utils/lib/UtilFs.js";

class AreaTagger {
constructor (filePath) {
this._filePath = filePath;
this._data = ut.readJson(filePath);
constructor (json) {
this._json = json;

this._maxTag = 0;
this._existingTags = null;
Expand All @@ -25,7 +26,7 @@ class AreaTagger {
}

_doPopulateExistingTags () {
const map = Renderer.adventureBook.getEntryIdLookup(this._data.data, "populateExistingIds");
const map = Renderer.adventureBook.getEntryIdLookup(this._json.data);
this._existingTags = new Set(Object.keys(map));
}

Expand All @@ -52,34 +53,62 @@ class AreaTagger {
},
};

this._data.data.forEach(chap => MiscUtil.getWalker().walk(chap, handlers));
}

_doWrite () {
const outStr = CleanUtil.getCleanJson(this._data);
fs.writeFileSync(this._filePath, outStr, "utf-8");
this._json.data.forEach(chap => MiscUtil.getWalker().walk(chap, handlers));
}

run () {
this._doPopulateExistingTags();
this._addNewTags();
this._doWrite();
}
}

const program = new Command()
.option("--file <file...>", `Input files`)
.option("--dir <dir...>", `Input directories`)
;

program.parse(process.argv);
const params = program.opts();

const dirs = [...(params.dir || [])];
const files = [...(params.file || [])];

// If no options specified, use default selection
if (!dirs.length && !files.length) {
[
{
index: ut.readJson("./data/adventures.json"),
type: "adventure",
},
{
index: ut.readJson("./data/books.json"),
type: "book",
},
]
.forEach(({index, type}) => {
index[type]
.forEach(meta => {
files.push(`./data/${type}/${type}-${meta.id.toLowerCase()}.json`);
});
});
}

console.log(`Running area tagging pass...`);
const adventureIndex = ut.readJson("./data/adventures.json");
const bookIndex = ut.readJson("./data/books.json");

const doPass = (arr, type) => {
arr.forEach(meta => {
const areaTagger = new AreaTagger(`./data/${type}/${type}-${meta.id.toLowerCase()}.json`);
areaTagger.run();
console.log(`\tTagged ${meta.id}...`);
});
};

doPass(adventureIndex.adventure, "adventure");
doPass(bookIndex.book, "book");
getAllJson({dirs, files})
.forEach(({path, json}) => {
if (json.data) {
new AreaTagger(json).run();
} else {
(json.adventureData || [])
.forEach(corpus => new AreaTagger(corpus).run());
(json.bookData || [])
.forEach(corpus => new AreaTagger(corpus).run());
}

writeJsonSync(path, json, {isClean: true});

console.log(`\tTagged "${path}"...`);
});

console.log(`Area tagging complete.`);
17 changes: 2 additions & 15 deletions node/tag-image-dimensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,8 @@ import "../js/utils.js";
import probe from "probe-image-size";
import {ObjectWalker} from "5etools-utils";
import {Command} from "commander";
import * as ut from "./util.js";
import {readJsonSync} from "5etools-utils/lib/UtilFs.js";

function addDir (allFiles, dir) {
ut.listFiles({dir})
.filter(file => file.toLowerCase().endsWith(".json"))
.forEach(filePath => addFile(allFiles, filePath));
}

function addFile (allFiles, path) {
const json = readJsonSync(path);
allFiles.push({json, path});
}
import {getAllJson} from "./util-json-files.js";

function getFileProbeTarget (path) {
const target = fs.createReadStream(path);
Expand Down Expand Up @@ -93,9 +82,7 @@ async function main (
) {
const tStart = Date.now();

const allFiles = [];
dirs.forEach(dir => addDir(allFiles, dir));
files.forEach(file => addFile(allFiles, file));
const allFiles = getAllJson({dirs, files});
console.log(`Running on ${allFiles.length} JSON file${allFiles.length === 1 ? "" : "s"}...`);

const imageEntries = [];
Expand Down
24 changes: 24 additions & 0 deletions node/util-json-files.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import * as ut from "./util.js";
import {readJsonSync} from "5etools-utils/lib/UtilFs.js";

const _getAllJson_addFile = (allFiles, path) => {
allFiles.push(path);
};

const _getAllJson_addDir = (allFiles, dir) => {
ut.listFiles({dir})
.filter(file => file.toLowerCase().endsWith(".json"))
.forEach(filePath => _getAllJson_addFile(allFiles, filePath));
};

export const getAllJson = ({files, dirs}) => {
return getAllJsonFiles({files, dirs})
.map(file => ({json: readJsonSync(file), path: file}));
};

export const getAllJsonFiles = ({files, dirs}) => {
const allFiles = [];
dirs.forEach(dir => _getAllJson_addDir(allFiles, dir));
files.forEach(file => _getAllJson_addFile(allFiles, file));
return allFiles;
};
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "5etools",
"author": "TheGiddyLimit",
"version": "2.5.5",
"version": "2.5.6",
"license": "MIT",
"description": "A site dedicated to making playing games with your friends as easy as possible.",
"type": "module",
Expand Down

0 comments on commit 0b750e5

Please sign in to comment.