pf2e-sage-stats 0.1.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/README.md +143 -0
- package/dist/app.js +409 -0
- package/dist/index.js +199 -0
- package/eslint.config.mjs +11 -0
- package/jest.config.ts +11 -0
- package/package.json +40 -0
- package/src/app.ts +623 -0
- package/src/index.ts +198 -0
- package/src/types.d.ts +5 -0
- package/test/app.test.ts +67 -0
- package/tsconfig.json +14 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
const commander_1 = require("commander");
|
|
17
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
18
|
+
const path_1 = __importDefault(require("path"));
|
|
19
|
+
const package_json_1 = __importDefault(require("../package.json"));
|
|
20
|
+
const app_1 = require("./app");
|
|
21
|
+
const program = new commander_1.Command(package_json_1.default.name);
|
|
22
|
+
program
|
|
23
|
+
.name(package_json_1.default.name)
|
|
24
|
+
.description(package_json_1.default.description)
|
|
25
|
+
.version(package_json_1.default.version);
|
|
26
|
+
program.command('stub')
|
|
27
|
+
.description('Generte a stat JSON template')
|
|
28
|
+
.option('-o, --output <file>', 'output json')
|
|
29
|
+
.action((option) => __awaiter(void 0, void 0, void 0, function* () {
|
|
30
|
+
if (option.output) {
|
|
31
|
+
yield promises_1.default.writeFile(option.output, (0, app_1.formatJSON)(app_1.stub), { encoding: 'utf-8' });
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
console.log((0, app_1.formatJSON)(app_1.stub));
|
|
35
|
+
}
|
|
36
|
+
}));
|
|
37
|
+
program.command('table')
|
|
38
|
+
.description('Generte a table configuration string')
|
|
39
|
+
.argument('<string>', 'table name')
|
|
40
|
+
.option('-o, --output <file>', 'output file')
|
|
41
|
+
.option('-t, --table <string>', 'table')
|
|
42
|
+
.option('-s, --season <string>', 'season')
|
|
43
|
+
.option('-c, --scenario <string>', 'scenario')
|
|
44
|
+
.option('-g, --gm <string>', 'gm')
|
|
45
|
+
.option('-p, --players <string>', 'players')
|
|
46
|
+
.action((argument, option) => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
48
|
+
if (option.output) {
|
|
49
|
+
yield promises_1.default.writeFile(option.output, (0, app_1.formatTable)(Number((_a = option.table) !== null && _a !== void 0 ? _a : 1), Number((_b = option.season) !== null && _b !== void 0 ? _b : 1), Number((_c = option.scenario) !== null && _c !== void 0 ? _c : 1), argument, (_d = option.gm) !== null && _d !== void 0 ? _d : '@lammonaaf', (_e = option.players) !== null && _e !== void 0 ? _e : '<players>'), { encoding: 'utf-8' });
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
console.log((0, app_1.formatTable)(Number((_f = option.table) !== null && _f !== void 0 ? _f : 1), Number((_g = option.season) !== null && _g !== void 0 ? _g : 1), Number((_h = option.scenario) !== null && _h !== void 0 ? _h : 1), argument, (_j = option.gm) !== null && _j !== void 0 ? _j : '@lammonaaf', (_k = option.players) !== null && _k !== void 0 ? _k : '<players>'));
|
|
53
|
+
}
|
|
54
|
+
}));
|
|
55
|
+
program.command('hp')
|
|
56
|
+
.description('Generte an hp bar')
|
|
57
|
+
.argument('<string>', 'hp/maxhp')
|
|
58
|
+
.action((argument) => __awaiter(void 0, void 0, void 0, function* () {
|
|
59
|
+
console.log((0, app_1.formatHP)(argument));
|
|
60
|
+
}));
|
|
61
|
+
program.command('flat')
|
|
62
|
+
.description('Generte a special flat npc tsv')
|
|
63
|
+
.option('-n, --name <string>', 'npc name')
|
|
64
|
+
.option('-o, --output <file>', 'output json')
|
|
65
|
+
.option('-s, --short', 'omit explosion')
|
|
66
|
+
.action((option) => __awaiter(void 0, void 0, void 0, function* () {
|
|
67
|
+
var _a, _b;
|
|
68
|
+
if (option.output) {
|
|
69
|
+
yield promises_1.default.writeFile(option.output, (0, app_1.fromatMap)((_a = option.name) !== null && _a !== void 0 ? _a : 'flat', option.short ? app_1.prediceateMap : app_1.flatMap), { encoding: 'utf-8' });
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
console.log((0, app_1.fromatMap)((_b = option.name) !== null && _b !== void 0 ? _b : 'flat', option.short ? app_1.prediceateMap : app_1.flatMap));
|
|
73
|
+
}
|
|
74
|
+
}));
|
|
75
|
+
program.command('valuename')
|
|
76
|
+
.description('Generte a special value name npc tsv')
|
|
77
|
+
.option('-n, --name <string>', 'npc name')
|
|
78
|
+
.option('-t, --tag <string>', 'name tag')
|
|
79
|
+
.option('-o, --output <file>', 'output json')
|
|
80
|
+
.action((option) => __awaiter(void 0, void 0, void 0, function* () {
|
|
81
|
+
var _a, _b, _c, _d;
|
|
82
|
+
if (option.output) {
|
|
83
|
+
yield promises_1.default.writeFile(option.output, (0, app_1.fromatMap)((_a = option.name) !== null && _a !== void 0 ? _a : 'valuename', (0, app_1.valueNameMap)((_b = option.tag) !== null && _b !== void 0 ? _b : null)), { encoding: 'utf-8' });
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
console.log((0, app_1.fromatMap)((_c = option.name) !== null && _c !== void 0 ? _c : 'valuename', (0, app_1.valueNameMap)((_d = option.tag) !== null && _d !== void 0 ? _d : null)));
|
|
87
|
+
}
|
|
88
|
+
}));
|
|
89
|
+
program.command('value')
|
|
90
|
+
.description('Generte a special value npc tsv')
|
|
91
|
+
.option('-n, --name <string>', 'npc name')
|
|
92
|
+
.option('-o, --output <file>', 'output json')
|
|
93
|
+
.action((option) => __awaiter(void 0, void 0, void 0, function* () {
|
|
94
|
+
var _a, _b;
|
|
95
|
+
if (option.output) {
|
|
96
|
+
yield promises_1.default.writeFile(option.output, (0, app_1.fromatMap)((_a = option.name) !== null && _a !== void 0 ? _a : 'value', (0, app_1.valueMap)()), { encoding: 'utf-8' });
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
console.log((0, app_1.fromatMap)((_b = option.name) !== null && _b !== void 0 ? _b : 'value', (0, app_1.valueMap)()));
|
|
100
|
+
}
|
|
101
|
+
}));
|
|
102
|
+
program.command('dicename')
|
|
103
|
+
.description('Generte a special dice npc tsv')
|
|
104
|
+
.option('-n, --name <string>', 'npc name')
|
|
105
|
+
.option('-o, --output <file>', 'output json')
|
|
106
|
+
.action((option) => __awaiter(void 0, void 0, void 0, function* () {
|
|
107
|
+
var _a, _b;
|
|
108
|
+
if (option.output) {
|
|
109
|
+
yield promises_1.default.writeFile(option.output, (0, app_1.fromatMap)((_a = option.name) !== null && _a !== void 0 ? _a : 'dicename', (0, app_1.diceNameMap)()), { encoding: 'utf-8' });
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
console.log((0, app_1.fromatMap)((_b = option.name) !== null && _b !== void 0 ? _b : 'dicename', (0, app_1.valueMap)()));
|
|
113
|
+
}
|
|
114
|
+
}));
|
|
115
|
+
program.command('dice')
|
|
116
|
+
.description('Generte a special dicemod npc tsv')
|
|
117
|
+
.option('-n, --name <string>', 'npc name')
|
|
118
|
+
.option('-o, --output <file>', 'output json')
|
|
119
|
+
.action((option) => __awaiter(void 0, void 0, void 0, function* () {
|
|
120
|
+
var _a, _b;
|
|
121
|
+
if (option.output) {
|
|
122
|
+
yield promises_1.default.writeFile(option.output, (0, app_1.fromatMap)((_a = option.name) !== null && _a !== void 0 ? _a : 'dice', (0, app_1.diceMap)()), { encoding: 'utf-8' });
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
console.log((0, app_1.fromatMap)((_b = option.name) !== null && _b !== void 0 ? _b : 'dice', (0, app_1.valueMap)()));
|
|
126
|
+
}
|
|
127
|
+
}));
|
|
128
|
+
program.command('adjustment')
|
|
129
|
+
.description('Generte a special adjustment npc tsv')
|
|
130
|
+
.option('-n, --name <string>', 'npc name')
|
|
131
|
+
.option('-o, --output <file>', 'output json')
|
|
132
|
+
.action((option) => __awaiter(void 0, void 0, void 0, function* () {
|
|
133
|
+
var _a, _b;
|
|
134
|
+
if (option.output) {
|
|
135
|
+
yield promises_1.default.writeFile(option.output, (0, app_1.fromatMap)((_a = option.name) !== null && _a !== void 0 ? _a : 'adjustment', (0, app_1.adjustmentMap)()), { encoding: 'utf-8' });
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
console.log((0, app_1.fromatMap)((_b = option.name) !== null && _b !== void 0 ? _b : 'adjustment', (0, app_1.adjustmentMap)()));
|
|
139
|
+
}
|
|
140
|
+
}));
|
|
141
|
+
program.command('statblock')
|
|
142
|
+
.description('Generte a stat JSON from Paizo creature statblock')
|
|
143
|
+
.argument('<file>', 'input text file')
|
|
144
|
+
.option('-n, --name <string>', 'creature name')
|
|
145
|
+
.option('-a, --alias <string>', 'creature alias')
|
|
146
|
+
.option('-b, --abbreviate', 'create alias from name')
|
|
147
|
+
.option('-t, --tsv', 'output directly to tsv')
|
|
148
|
+
.option('-c, --command', 'output directly to txt')
|
|
149
|
+
.option('-s, --secretDC', 'produce secret DCs (tsv only)')
|
|
150
|
+
.option('-d, --defaultSkills', 'produce values for untrained skills (tsv only)')
|
|
151
|
+
.option('-e, --desc', 'produce verbose desc fields (tsv only)')
|
|
152
|
+
.option('-o, --output <file>', 'output file name')
|
|
153
|
+
.action((argument, option) => __awaiter(void 0, void 0, void 0, function* () {
|
|
154
|
+
var _a, _b;
|
|
155
|
+
const file = yield promises_1.default.readFile(argument, { encoding: 'utf-8' });
|
|
156
|
+
const alias = (_a = option.alias) !== null && _a !== void 0 ? _a : (option.abbreviate ? null : (option.output ? path_1.default.parse(option.output).name : path_1.default.parse(argument).name));
|
|
157
|
+
const stats = (0, app_1.parseStatblock)((_b = option.name) !== null && _b !== void 0 ? _b : null, file, alias);
|
|
158
|
+
if (option.tsv) {
|
|
159
|
+
const output = option.output ? option.output : path_1.default.join(path_1.default.parse(argument).dir, stats.alias + '.tsv');
|
|
160
|
+
yield promises_1.default.writeFile(output, (0, app_1.formatTSV)(stats, option.secretDC, option.defaultSkills, option.desc), { encoding: 'utf-8' });
|
|
161
|
+
}
|
|
162
|
+
else if (option.command) {
|
|
163
|
+
const output = option.output ? option.output : path_1.default.join(path_1.default.parse(argument).dir, stats.alias + '-command.txt');
|
|
164
|
+
yield promises_1.default.writeFile(output, (0, app_1.formatCommand)(stats, option.secretDC, option.defaultSkills, option.desc), { encoding: 'utf-8' });
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
const output = option.output ? option.output : path_1.default.join(path_1.default.parse(argument).dir, stats.alias + '.json');
|
|
168
|
+
yield promises_1.default.writeFile(output, (0, app_1.formatJSON)(stats), { encoding: 'utf-8' });
|
|
169
|
+
}
|
|
170
|
+
}));
|
|
171
|
+
program.command('tsv')
|
|
172
|
+
.description('Generte a tsv file from JSON')
|
|
173
|
+
.argument('<file>', 'input json')
|
|
174
|
+
.option('-o, --output <file>', 'output tsv')
|
|
175
|
+
.option('-s, --secretDC', 'produce secret DCs')
|
|
176
|
+
.option('-r, --recallDC', 'produce recall DCs')
|
|
177
|
+
.option('-d, --defaultSkills', 'produce values for untrained skills')
|
|
178
|
+
.option('-e, --desc', 'produce verbose desc fields')
|
|
179
|
+
.action((argument, option) => __awaiter(void 0, void 0, void 0, function* () {
|
|
180
|
+
const file = yield promises_1.default.readFile(argument, { encoding: 'utf-8' });
|
|
181
|
+
const stats = (0, app_1.parseJSON)(file);
|
|
182
|
+
const output = option.output ? option.output : path_1.default.join(path_1.default.parse(argument).dir, path_1.default.parse(argument).name + '.tsv');
|
|
183
|
+
yield promises_1.default.writeFile(output, (0, app_1.formatTSV)(stats, option.secretDC, option.defaultSkills, option.recallDC, option.desc), { encoding: 'utf-8' });
|
|
184
|
+
}));
|
|
185
|
+
program.command('command')
|
|
186
|
+
.description('Generte a creation command file from JSON')
|
|
187
|
+
.argument('<file>', 'input json')
|
|
188
|
+
.option('-o, --output <file>', 'output txt')
|
|
189
|
+
.option('-s, --secretDC', 'produce secret DCs')
|
|
190
|
+
.option('-r, --recallDC', 'produce recall DCs')
|
|
191
|
+
.option('-d, --defaultSkills', 'produce values for untrained skills')
|
|
192
|
+
.option('-e, --desc', 'produce verbose desc fields')
|
|
193
|
+
.action((argument, option) => __awaiter(void 0, void 0, void 0, function* () {
|
|
194
|
+
const file = yield promises_1.default.readFile(argument, { encoding: 'utf-8' });
|
|
195
|
+
const stats = (0, app_1.parseJSON)(file);
|
|
196
|
+
const output = option.output ? option.output : path_1.default.join(path_1.default.parse(argument).dir, path_1.default.parse(argument).name + '-command.txt');
|
|
197
|
+
yield promises_1.default.writeFile(output, (0, app_1.formatCommand)(stats, option.secretDC, option.defaultSkills, option.recallDC, option.desc), { encoding: 'utf-8' });
|
|
198
|
+
}));
|
|
199
|
+
program.parse();
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import globals from "globals";
|
|
2
|
+
import pluginJs from "@eslint/js";
|
|
3
|
+
import tseslint from "typescript-eslint";
|
|
4
|
+
|
|
5
|
+
/** @type {import('eslint').Linter.Config[]} */
|
|
6
|
+
export default [
|
|
7
|
+
{files: ["src/**/*.ts"]},
|
|
8
|
+
{languageOptions: { globals: globals.browser }},
|
|
9
|
+
pluginJs.configs.recommended,
|
|
10
|
+
...tseslint.configs.recommended,
|
|
11
|
+
];
|
package/jest.config.ts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pf2e-sage-stats",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "An RPG Sage's .tsv stat generation tool",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"author": "ikariott@gmail.com",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"start": "node dist/index.js",
|
|
10
|
+
"build": "tsc",
|
|
11
|
+
"lint": "eslint src/**/*.ts",
|
|
12
|
+
"test": "jest"
|
|
13
|
+
},
|
|
14
|
+
"bin": {
|
|
15
|
+
"pf2e-sage-stats": "dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@eslint/js": "^9.17.0",
|
|
19
|
+
"@types/jest": "^29.5.14",
|
|
20
|
+
"@types/lodash": "^4.17.13",
|
|
21
|
+
"@types/pluralize": "^0.0.33",
|
|
22
|
+
"@types/tsv": "^0.2.4",
|
|
23
|
+
"eslint": "^9.17.0",
|
|
24
|
+
"globals": "^15.14.0",
|
|
25
|
+
"jest": "^29.7.0",
|
|
26
|
+
"ts-jest": "^29.2.5",
|
|
27
|
+
"ts-node": "^10.9.2",
|
|
28
|
+
"typescript": "^5.7.2",
|
|
29
|
+
"typescript-eslint": "^8.18.2"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"abbreviate": "^0.0.3",
|
|
33
|
+
"commander": "^12.1.0",
|
|
34
|
+
"dedent-js": "^1.0.1",
|
|
35
|
+
"lodash": "^4.17.21",
|
|
36
|
+
"pluralize": "^8.0.0",
|
|
37
|
+
"tsv": "^0.2.0",
|
|
38
|
+
"zod": "^3.24.1"
|
|
39
|
+
}
|
|
40
|
+
}
|