pf2e-sage-stats 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.d.ts +1 -0
- package/dist/app.js +29 -1
- package/dist/index.js +10 -0
- package/package.json +1 -1
package/dist/app.d.ts
CHANGED
|
@@ -718,6 +718,7 @@ export declare const parseStatblock: (name: string | null, _statblock: string, a
|
|
|
718
718
|
export declare const flatten: (stats: Schema, secretDC?: boolean, defaultSkills?: boolean) => Record<string, string | number>;
|
|
719
719
|
export declare const formatTSV: (stats: Schema, secretDC?: boolean, defaultSkills?: boolean) => string;
|
|
720
720
|
export declare const formatCommand: (stats: Schema, secretDC?: boolean, defaultSkills?: boolean) => string;
|
|
721
|
+
export declare const transposeSkills: (tsv: string) => string;
|
|
721
722
|
export declare const formatTable: (table: string, season: string, scenario: string, _name: string, gm: string, players: string, category: string, gmCharName?: string) => string;
|
|
722
723
|
export declare const formatHP: (arg: string) => string;
|
|
723
724
|
export declare const newtracker: (status: string, desc: {
|
package/dist/app.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.sortFolder = exports.applyTrackerCommands = exports.parseTrackerCommands = exports.formatTracker = exports.newtracker = exports.formatHP = exports.formatTable = exports.formatCommand = exports.formatTSV = exports.flatten = exports.parseStatblock = exports.parseTracker = exports.parseJSON = exports.formatJSON = exports.fromatMap = exports.diceMap = exports.flatMap = exports.trackerSchema = exports.charSchema = exports.stub = void 0;
|
|
6
|
+
exports.sortFolder = exports.applyTrackerCommands = exports.parseTrackerCommands = exports.formatTracker = exports.newtracker = exports.formatHP = exports.formatTable = exports.transposeSkills = exports.formatCommand = exports.formatTSV = exports.flatten = exports.parseStatblock = exports.parseTracker = exports.parseJSON = exports.formatJSON = exports.fromatMap = exports.diceMap = exports.flatMap = exports.trackerSchema = exports.charSchema = exports.stub = void 0;
|
|
7
7
|
const zod_1 = __importDefault(require("zod"));
|
|
8
8
|
const tsv_1 = require("tsv");
|
|
9
9
|
const promises_1 = require("fs/promises");
|
|
@@ -583,6 +583,34 @@ const formatTSV = (stats, secretDC = false, defaultSkills = false) => (tsv_1.TSV
|
|
|
583
583
|
exports.formatTSV = formatTSV;
|
|
584
584
|
const formatCommand = (stats, secretDC = false, defaultSkills = false) => (Object.entries((0, exports.flatten)(stats, secretDC, defaultSkills)).map(([k, v]) => `${k}="${v}"`).join(' '));
|
|
585
585
|
exports.formatCommand = formatCommand;
|
|
586
|
+
const transposeSkills = (tsv) => {
|
|
587
|
+
const entries = tsv_1.TSV.parse(tsv);
|
|
588
|
+
const skills = entries.map((entry) => {
|
|
589
|
+
const skillKeys = ['perception', 'acrobatics', 'arcana', 'athletics', 'crafting', 'deception', 'diplomacy', 'intimidation', 'medicine', 'nature', 'occultism', 'performance', 'religion', 'society', 'stealth', 'survival', 'thievery', 'piloting', 'computers', 'perfomance'];
|
|
590
|
+
const skills = skillKeys.map((key) => entry[key] ? { name: (0, lodash_1.capitalize)(key), mod: parseInt(entry[key]) } : null).filter((x) => !!x);
|
|
591
|
+
const loreKeys = (0, lodash_1.keys)(entry).filter((k) => k.startsWith('lore.') && !k.endsWith('.name') && !k.endsWith('.info'));
|
|
592
|
+
const lores = loreKeys.map((key) => entry[key] && entry[`${key}.name`] ? { name: entry[`${key}.name`] + " Lore", mod: parseInt(entry[key]) } : null).filter((x) => !!x);
|
|
593
|
+
return { name: entry.name, skills: [...skills, ...lores] };
|
|
594
|
+
});
|
|
595
|
+
const k = (0, lodash_1.uniq)(skills.flatMap((s) => s.skills.map(({ name }) => name))).sort((a, b) => {
|
|
596
|
+
const aEndsWithLore = a.endsWith("Lore");
|
|
597
|
+
const bEndsWithLore = b.endsWith("Lore");
|
|
598
|
+
if (aEndsWithLore !== bEndsWithLore) {
|
|
599
|
+
return aEndsWithLore ? 1 : -1;
|
|
600
|
+
}
|
|
601
|
+
return a.localeCompare(b);
|
|
602
|
+
});
|
|
603
|
+
const data = k.map((kk) => [
|
|
604
|
+
['Skill', kk],
|
|
605
|
+
...skills.map((s) => { var _a, _b, _c, _d; return [s.name, ((_d = (_b = (_a = s.skills.find((ss) => ss.name === kk)) === null || _a === void 0 ? void 0 : _a.mod) !== null && _b !== void 0 ? _b : (_c = s.skills.find((ss) => ss.name === 'Other Lore')) === null || _c === void 0 ? void 0 : _c.mod) !== null && _d !== void 0 ? _d : 0)]; })
|
|
606
|
+
].reduce((p, [key, value]) => { p[key] = value; return p; }, {}));
|
|
607
|
+
return [
|
|
608
|
+
'| ' + (0, lodash_1.keys)(data[0]).join(' | ') + ' |',
|
|
609
|
+
'| ' + (0, lodash_1.keys)(data[0]).map(() => '---').join(' | ') + ' |',
|
|
610
|
+
...data.map((d) => '| ' + (0, lodash_1.values)(d).join(' | ') + ' |')
|
|
611
|
+
].join('\n');
|
|
612
|
+
};
|
|
613
|
+
exports.transposeSkills = transposeSkills;
|
|
586
614
|
const formatTable = (table, season, scenario, _name, gm, players, category, gmCharName) => {
|
|
587
615
|
const name = _name.replace(/[\s-_]/g, ' ').replace(/[^a-zA-Z0-9 ]/g, '');
|
|
588
616
|
const gameName = `PF2 T${table} S${season} ${String(scenario).padStart(2, '0')} ${name}`;
|
package/dist/index.js
CHANGED
|
@@ -137,6 +137,16 @@ program.command('command')
|
|
|
137
137
|
const output = option.output ? option.output : path_1.default.join(path_1.default.parse(argument).dir, path_1.default.parse(argument).name + '-command.txt');
|
|
138
138
|
await promises_1.default.writeFile(output, (0, app_1.formatCommand)(stats, option.secretDC, option.defaultSkills), { encoding: 'utf-8' });
|
|
139
139
|
});
|
|
140
|
+
program.command('skills')
|
|
141
|
+
.description('Generte skills summary from party data')
|
|
142
|
+
.argument('<file>', 'input tsv')
|
|
143
|
+
.option('-o, --output <file>', 'output .md')
|
|
144
|
+
.action(async (argument, option) => {
|
|
145
|
+
const file = await promises_1.default.readFile(argument, { encoding: 'utf-8' });
|
|
146
|
+
const tr = (0, app_1.transposeSkills)(file);
|
|
147
|
+
const output = option.output ? option.output : path_1.default.join(path_1.default.parse(argument).dir, path_1.default.parse(argument).name + '.md');
|
|
148
|
+
await promises_1.default.writeFile(output, tr, { encoding: 'utf-8' });
|
|
149
|
+
});
|
|
140
150
|
program.command('newtracker')
|
|
141
151
|
.argument('<file>', 'input text file')
|
|
142
152
|
.option('-o, --output <file>', 'output file name')
|