pf2e-sage-stats 0.1.1 → 0.2.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 +34 -79
- package/dist/app.js +171 -77
- package/dist/index.js +13 -65
- package/package.json +1 -1
- package/src/app.ts +176 -155
- package/src/index.ts +15 -62
package/dist/app.js
CHANGED
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
13
|
};
|
|
5
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.formatHP = exports.formatTable = exports.formatCommand = exports.formatTSV = exports.flatten = exports.parseStatblock = exports.parseJSON = exports.formatJSON = exports.fromatMap = exports.adjustmentMap = exports.
|
|
15
|
+
exports.sortFolder = exports.formatHP = exports.formatTable = exports.formatCommand = exports.formatTSV = exports.flatten = exports.parseStatblock = exports.parseJSON = exports.formatJSON = exports.fromatMap = exports.adjustmentMap = exports.prediceateMap = exports.stub = void 0;
|
|
7
16
|
const zod_1 = __importDefault(require("zod"));
|
|
8
17
|
const tsv_1 = require("tsv");
|
|
9
18
|
const lodash_1 = require("lodash");
|
|
10
19
|
const dedent_js_1 = __importDefault(require("dedent-js"));
|
|
11
20
|
const abbreviate_1 = __importDefault(require("abbreviate"));
|
|
12
21
|
const pluralize_1 = __importDefault(require("pluralize"));
|
|
22
|
+
const promises_1 = require("fs/promises");
|
|
13
23
|
const schema = zod_1.default.object({
|
|
14
24
|
name: zod_1.default.string(),
|
|
15
25
|
alias: zod_1.default.string().optional(),
|
|
@@ -30,6 +40,8 @@ const schema = zod_1.default.object({
|
|
|
30
40
|
}).default({}),
|
|
31
41
|
ac: zod_1.default.coerce.number().default(10),
|
|
32
42
|
perception: zod_1.default.coerce.number().default(0),
|
|
43
|
+
perceptionInfo: zod_1.default.array(zod_1.default.string()).default([]),
|
|
44
|
+
initiativeInfo: zod_1.default.array(zod_1.default.string()).default([]),
|
|
33
45
|
skills: zod_1.default.object({
|
|
34
46
|
acrobatics: zod_1.default.coerce.number().optional(),
|
|
35
47
|
arcana: zod_1.default.coerce.number().optional(),
|
|
@@ -41,7 +53,7 @@ const schema = zod_1.default.object({
|
|
|
41
53
|
medicine: zod_1.default.coerce.number().optional(),
|
|
42
54
|
nature: zod_1.default.coerce.number().optional(),
|
|
43
55
|
occultism: zod_1.default.coerce.number().optional(),
|
|
44
|
-
|
|
56
|
+
performance: zod_1.default.coerce.number().optional(),
|
|
45
57
|
religion: zod_1.default.coerce.number().optional(),
|
|
46
58
|
society: zod_1.default.coerce.number().optional(),
|
|
47
59
|
stealth: zod_1.default.coerce.number().optional(),
|
|
@@ -55,12 +67,12 @@ const schema = zod_1.default.object({
|
|
|
55
67
|
melee: zod_1.default.record(zod_1.default.string(), zod_1.default.object({
|
|
56
68
|
mod: zod_1.default.coerce.number().default(0),
|
|
57
69
|
desc: zod_1.default.string(),
|
|
58
|
-
damage: zod_1.default.string(),
|
|
70
|
+
damage: zod_1.default.string().optional(),
|
|
59
71
|
})).default({}),
|
|
60
72
|
ranged: zod_1.default.record(zod_1.default.string(), zod_1.default.object({
|
|
61
73
|
mod: zod_1.default.coerce.number().default(0),
|
|
62
74
|
desc: zod_1.default.string(),
|
|
63
|
-
damage: zod_1.default.string(),
|
|
75
|
+
damage: zod_1.default.string().optional(),
|
|
64
76
|
})).default({}),
|
|
65
77
|
spells: zod_1.default.object({
|
|
66
78
|
attack: zod_1.default.coerce.number().optional(),
|
|
@@ -69,7 +81,42 @@ const schema = zod_1.default.object({
|
|
|
69
81
|
extra: zod_1.default.record(zod_1.default.string(), zod_1.default.coerce.number()).default({}),
|
|
70
82
|
extraDCs: zod_1.default.record(zod_1.default.string(), zod_1.default.coerce.number()).default({}),
|
|
71
83
|
extraDice: zod_1.default.record(zod_1.default.string(), zod_1.default.coerce.string()).default({}),
|
|
72
|
-
|
|
84
|
+
classDC: zod_1.default.coerce.number().default(10),
|
|
85
|
+
untrained: zod_1.default.coerce.number().default(0),
|
|
86
|
+
bump: zod_1.default.object({
|
|
87
|
+
default: zod_1.default.coerce.number().default(0),
|
|
88
|
+
attack: zod_1.default.coerce.number().optional(),
|
|
89
|
+
ac: zod_1.default.coerce.number().optional(),
|
|
90
|
+
saves: zod_1.default.coerce.number().optional(),
|
|
91
|
+
skills: zod_1.default.coerce.number().optional(),
|
|
92
|
+
spells: zod_1.default.coerce.number().optional(),
|
|
93
|
+
perception: zod_1.default.coerce.number().optional(),
|
|
94
|
+
hp: zod_1.default.coerce.number().optional(),
|
|
95
|
+
}).default({ default: 0 }),
|
|
96
|
+
bullwark: zod_1.default.coerce.number().default(0),
|
|
97
|
+
saveInfo: zod_1.default.object({
|
|
98
|
+
fortitude: zod_1.default.array(zod_1.default.string()).default([]),
|
|
99
|
+
reflex: zod_1.default.array(zod_1.default.string()).default([]),
|
|
100
|
+
will: zod_1.default.array(zod_1.default.string()).default([]),
|
|
101
|
+
}).default({}),
|
|
102
|
+
skillInfo: zod_1.default.object({
|
|
103
|
+
acrobatics: zod_1.default.array(zod_1.default.string()).optional(),
|
|
104
|
+
arcana: zod_1.default.array(zod_1.default.string()).optional(),
|
|
105
|
+
athletics: zod_1.default.array(zod_1.default.string()).optional(),
|
|
106
|
+
crafting: zod_1.default.array(zod_1.default.string()).optional(),
|
|
107
|
+
deception: zod_1.default.array(zod_1.default.string()).optional(),
|
|
108
|
+
diplomacy: zod_1.default.array(zod_1.default.string()).optional(),
|
|
109
|
+
intimidation: zod_1.default.array(zod_1.default.string()).optional(),
|
|
110
|
+
medicine: zod_1.default.array(zod_1.default.string()).optional(),
|
|
111
|
+
nature: zod_1.default.array(zod_1.default.string()).optional(),
|
|
112
|
+
occultism: zod_1.default.array(zod_1.default.string()).optional(),
|
|
113
|
+
performance: zod_1.default.array(zod_1.default.string()).optional(),
|
|
114
|
+
religion: zod_1.default.array(zod_1.default.string()).optional(),
|
|
115
|
+
society: zod_1.default.array(zod_1.default.string()).optional(),
|
|
116
|
+
stealth: zod_1.default.array(zod_1.default.string()).optional(),
|
|
117
|
+
survival: zod_1.default.array(zod_1.default.string()).optional(),
|
|
118
|
+
thievery: zod_1.default.array(zod_1.default.string()).optional(),
|
|
119
|
+
}).default({}),
|
|
73
120
|
});
|
|
74
121
|
exports.stub = {
|
|
75
122
|
name: 'name',
|
|
@@ -91,6 +138,8 @@ exports.stub = {
|
|
|
91
138
|
},
|
|
92
139
|
ac: 10,
|
|
93
140
|
perception: 0,
|
|
141
|
+
perceptionInfo: [],
|
|
142
|
+
initiativeInfo: [],
|
|
94
143
|
skills: {
|
|
95
144
|
acrobatics: 0,
|
|
96
145
|
arcana: 0,
|
|
@@ -102,7 +151,7 @@ exports.stub = {
|
|
|
102
151
|
medicine: 0,
|
|
103
152
|
nature: 0,
|
|
104
153
|
occultism: 0,
|
|
105
|
-
|
|
154
|
+
performance: 0,
|
|
106
155
|
religion: 0,
|
|
107
156
|
society: 0,
|
|
108
157
|
stealth: 0,
|
|
@@ -118,35 +167,25 @@ exports.stub = {
|
|
|
118
167
|
extra: {},
|
|
119
168
|
extraDCs: {},
|
|
120
169
|
extraDice: {},
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
170
|
+
classDC: 10,
|
|
171
|
+
untrained: 0,
|
|
172
|
+
bump: { default: 0 },
|
|
173
|
+
bullwark: 0,
|
|
174
|
+
saveInfo: {
|
|
175
|
+
fortitude: [],
|
|
176
|
+
reflex: [],
|
|
177
|
+
will: [],
|
|
178
|
+
},
|
|
179
|
+
skillInfo: {},
|
|
131
180
|
};
|
|
132
|
-
exports.prediceateMap = Object.assign(Object.assign({}, ([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20].map((v) => ([`${v}`, `d20 >= ${v} flat;`])).reduce((p, [k, v]) => { p[k] = v; return p; }, {}))), { c: 'd20 >= 5 flat;', concealed: 'd20 >= 5 flat;', h: 'd20 >= 11 flat;', hidden: 'd20 >= 11 flat;'
|
|
133
|
-
exports.flatMap = Object.entries(exports.prediceateMap).flatMap(([k, v]) => Object.entries(formatMap).map(([fk, fv]) => ([`${fk}_${k}`, `${fv} ${v}`]))).reduce((p, [k, v]) => { p[k] = v; return p; }, {});
|
|
134
|
-
const valueNameMap = (tag) => (Object.assign(Object.assign(Object.assign(Object.assign({}, ([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20].map((v) => ([`+${v}`, tag ? ` ⟮+${v} ${tag}⟯` : ` ⟮+${v}⟯`])).reduce((p, [k, v]) => { p[k] = v; return p; }, {}))), ([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20].map((v) => ([`${v}`, tag ? ` ⟮+${v} ${tag}⟯` : ` ⟮+${v}⟯`])).reduce((p, [k, v]) => { p[k] = v; return p; }, {}))), ([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20].map((v) => ([`-${v}`, tag ? ` ⟮-${v} ${tag}⟯` : ` ⟮-${v}⟯`])).reduce((p, [k, v]) => { p[k] = v; return p; }, {}))), { '+0': '', '0': '' }));
|
|
135
|
-
exports.valueNameMap = valueNameMap;
|
|
136
|
-
const valueMap = () => (Object.assign(Object.assign(Object.assign(Object.assign({}, ([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20].map((v) => ([`+${v}`, `+${v}`])).reduce((p, [k, v]) => { p[k] = v; return p; }, {}))), ([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20].map((v) => ([`${v}`, `+${v}`])).reduce((p, [k, v]) => { p[k] = v; return p; }, {}))), ([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20].map((v) => ([`-${v}`, `-${v}`])).reduce((p, [k, v]) => { p[k] = v; return p; }, {}))), { '+0': '+0', '0': '+0' }));
|
|
137
|
-
exports.valueMap = valueMap;
|
|
138
|
-
const diceNameMap = () => (Object.assign(Object.assign({}, ([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20].map((v) => ([`(${v})`, ` ⟮take ${v}⟯`])).reduce((p, [k, v]) => { p[k] = v; return p; }, {}))), { '1': '', '+1': '', '-1': '', '2': ' ⟮fortune⟯', '+2': ' ⟮fortune⟯', '-2': ' ⟮misfortune⟯', 'a': ' ⟮fortune⟯', 'adv': ' ⟮fortune⟯', 'advantage': ' ⟮fortune⟯', 'd': ' ⟮misfortune⟯', 'dis': ' ⟮misfortune⟯', 'disadvantage': ' ⟮misfortune⟯', 'f': ' ⟮fortune⟯', 'for': ' ⟮fortune⟯', 'fortune': ' ⟮fortune⟯', 'm': ' ⟮misfortune⟯', 'mis': ' ⟮misfortune⟯', 'misfortune': ' ⟮misfortune⟯' }));
|
|
139
|
-
exports.diceNameMap = diceNameMap;
|
|
140
|
-
const diceMap = () => (Object.assign(Object.assign({}, ([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20].map((v) => ([`(${v})`, `(${v})`])).reduce((p, [k, v]) => { p[k] = v; return p; }, {}))), { '1': '1', '+1': '1', '-1': '1', '2': '+2', '+2': '+2', '-2': '-2', 'a': '+2', 'adv': '+2', 'advantage': '+2', 'd': '-2', 'dis': '-2', 'disadvantage': '-2', 'f': '+2', 'for': '+2', 'fortune': '+2', 'm': '-2', 'mis': '-2', 'misfortune': '-2' }));
|
|
141
|
-
exports.diceMap = diceMap;
|
|
181
|
+
exports.prediceateMap = Object.assign(Object.assign({}, ([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20].map((v) => ([`${v}`, `d20 >= ${v} flat;`])).reduce((p, [k, v]) => { p[k] = v; return p; }, {}))), { c: 'd20 >= 5 flat;', concealed: 'd20 >= 5 flat;', h: 'd20 >= 11 flat;', hidden: 'd20 >= 11 flat;' });
|
|
142
182
|
const adjustmentMap = () => ({
|
|
143
|
-
'incredibly-easy': '
|
|
144
|
-
'very-easy': '
|
|
145
|
-
'easy': '
|
|
146
|
-
'
|
|
147
|
-
'hard': '
|
|
148
|
-
'
|
|
149
|
-
'incredibly-hard': ' ⟮Incredibly Hard⟯',
|
|
183
|
+
'incredibly-easy': '`(Incredibly Easy)`',
|
|
184
|
+
'very-easy': '`(Very Easy)`',
|
|
185
|
+
'easy': '`(Easy)`',
|
|
186
|
+
'hard': '`(Hard)`',
|
|
187
|
+
'very-hard': '`(Very Easy)`',
|
|
188
|
+
'incredibly-hard': '`(Incredibly Hard)`',
|
|
150
189
|
});
|
|
151
190
|
exports.adjustmentMap = adjustmentMap;
|
|
152
191
|
const fromatMap = (name, map) => {
|
|
@@ -216,14 +255,18 @@ const locateStrikes = (statblock, alias) => {
|
|
|
216
255
|
const [, , name, , attack, traits, , dice] = matches;
|
|
217
256
|
if (name && attack && dice) {
|
|
218
257
|
const _name = name.toLowerCase()
|
|
219
|
-
.replace(/\s+/g, ' ')
|
|
220
258
|
.replace(/\+\d/g, '')
|
|
221
259
|
.replace(/Weapon\s+Striking(\s+\((Greater|Major)\))?/gi, '')
|
|
260
|
+
.replace(/((Greater|Major)\s+)?Striking/gi, '')
|
|
222
261
|
.replace(/\(Agile\)/gi, '')
|
|
262
|
+
.replace(/\(Finesse\)/gi, '')
|
|
223
263
|
.replace(/\(\+\)/gi, '')
|
|
264
|
+
.replace(/\(\)/gi, '')
|
|
265
|
+
.replace(/\s+/g, ' ')
|
|
224
266
|
.trim();
|
|
225
267
|
const bps = /(?<=[^\w']|^)[BbPpSs](?=[^\w]|$)/g;
|
|
226
268
|
let _traits = traits && traits.toLowerCase()
|
|
269
|
+
.replace(/\(\)/gi, '')
|
|
227
270
|
.replace(/\s+/g, ' ')
|
|
228
271
|
.replace(bps, (m) => m.toUpperCase())
|
|
229
272
|
.replace(/1d/, 'd')
|
|
@@ -231,6 +274,9 @@ const locateStrikes = (statblock, alias) => {
|
|
|
231
274
|
const _dice = dice
|
|
232
275
|
.replace(/\s+/g, ' ')
|
|
233
276
|
.replace(bps, (m) => { var _a; return ((_a = { b: 'bludgeoning', p: 'piercing', s: 'slashing' }[m.toLowerCase()]) !== null && _a !== void 0 ? _a : m); })
|
|
277
|
+
.replace(/Fire/, 'fire')
|
|
278
|
+
.replace(/Cold/, 'cold')
|
|
279
|
+
.replace(/Electricity/, 'electricity')
|
|
234
280
|
.trim();
|
|
235
281
|
const twoHand = _traits.match(/(two-hand|two-handed)\s+(d\d+)/);
|
|
236
282
|
if (twoHand && twoHand[2]) {
|
|
@@ -277,28 +323,34 @@ const locateSpells = (statblock) => {
|
|
|
277
323
|
const parseStatblock = (name, _statblock, alias) => {
|
|
278
324
|
var _a;
|
|
279
325
|
const defaults = schema.parse({ name: name !== null && name !== void 0 ? name : 'Unknown' });
|
|
326
|
+
const improvisation = _statblock.match(/Untrained\s+Improvisation/);
|
|
327
|
+
const plate = _statblock.match(/Full\s+Plate/);
|
|
280
328
|
const statblock = _statblock
|
|
281
329
|
.replace(/^Items.*$/m, '')
|
|
330
|
+
.replace('', '')
|
|
282
331
|
.replace(/–/g, '-') + '\n';
|
|
283
|
-
const improvisation = !!statblock.match(/Untrained\s+Improvisation/);
|
|
284
332
|
const basic = locateName(statblock);
|
|
285
|
-
|
|
333
|
+
const result = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, defaults), basic), (name && { name: name })), { alias: alias !== null && alias !== void 0 ? alias : (0, abbreviate_1.default)((_a = name !== null && name !== void 0 ? name : basic === null || basic === void 0 ? void 0 : basic.name) !== null && _a !== void 0 ? _a : defaults.name, { length: 3 }).toLowerCase() }), locateInt('perception', statblock)), locateInt('ac', statblock, null, false, 'AC')), locateInt('maxhp', statblock, null, false, 'HP')), { attributes: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, defaults.attributes), locateInt('strength', statblock, null, true, 'Str')), locateInt('dexterity', statblock, null, true, 'Dex')), locateInt('constitution', statblock, null, true, 'Con')), locateInt('intelligence', statblock, null, true, 'Int')), locateInt('wisdom', statblock, null, true, 'Wis')), locateInt('charisma', statblock, null, true, 'Cha')), saves: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, defaults.saves), locateInt('fortitude', statblock, null, true, 'Fortitude')), locateInt('reflex', statblock, null, true, 'Reflex')), locateInt('fortitude', statblock, null, true, 'Fort')), locateInt('reflex', statblock, null, true, 'Ref')), locateInt('will', statblock, null, true, 'Will')), skills: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, defaults.skills), locateInt('acrobatics', statblock, 'Skills')), locateInt('arcana', statblock, 'Skills')), locateInt('athletics', statblock, 'Skills')), locateInt('crafting', statblock, 'Skills')), locateInt('deception', statblock, 'Skills')), locateInt('diplomacy', statblock, 'Skills')), locateInt('intimidation', statblock, 'Skills')), locateInt('medicine', statblock, 'Skills')), locateInt('nature', statblock, 'Skills')), locateInt('occultism', statblock, 'Skills')), locateInt('performance', statblock, 'Skills')), locateInt('religion', statblock, 'Skills')), locateInt('society', statblock, 'Skills')), locateInt('stealth', statblock, 'Skills')), locateInt('survival', statblock, 'Skills')), locateInt('thievery', statblock, 'Skills')), lores: Object.assign(Object.assign({}, locateInts(statblock, 'Skills', 'Lore')), locateIntsAfter(statblock, 'Lore:')), melee: Object.assign({}, locateStrikes(statblock, 'Melee')), ranged: Object.assign({}, locateStrikes(statblock, 'Ranged')), spells: Object.assign({}, locateSpells(statblock)), extra: {}, extraDCs: Object.assign({}, locateInt('stealth', statblock, null, false, 'Stealth DC')), extraDice: {} });
|
|
334
|
+
result.untrained = improvisation ? (result.level >= 7 ? result.level : result.level >= 5 ? result.level - 1 : result.level - 2) : 0;
|
|
335
|
+
result.bullwark = plate ? Math.max(3 - result.attributes.dexterity, 0) : 0;
|
|
336
|
+
return result;
|
|
286
337
|
};
|
|
287
338
|
exports.parseStatblock = parseStatblock;
|
|
288
|
-
const dc2DC = (secret) => ([key, value]) => [`dc.${key}`, secret ? `||${value}||` : `${value}`];
|
|
289
|
-
const mod2DC = (secret) => ([key, value]) => [`dc.${key}`, secret ? `||${10 + value}||` : `${10 + value}`];
|
|
290
|
-
const
|
|
339
|
+
const dc2DC = (secret, bump) => ([key, value]) => [`dc.${key}`, secret ? `||${value + bump}||` : `${value + bump}`];
|
|
340
|
+
const mod2DC = (secret, bump) => ([key, value]) => [`dc.${key}`, secret ? `||${10 + value + bump}||` : `${10 + value + bump}`];
|
|
341
|
+
const toLoreMod = ([key, value]) => [`lore.${key}`, value.mod];
|
|
342
|
+
const toLoreName = ([key, value]) => [`lore.${key}.name`, value.name];
|
|
291
343
|
const toMelee = ([key, value]) => [
|
|
292
344
|
[`melee.${key}`, value.mod],
|
|
293
345
|
[`melee.${key}.desc`, value.desc],
|
|
294
|
-
[`melee.${key}.damage`, value.damage],
|
|
346
|
+
...(value.damage ? [[`melee.${key}.damage`, value.damage]] : []),
|
|
295
347
|
];
|
|
296
348
|
const toRanged = ([key, value]) => [
|
|
297
349
|
[`ranged.${key}`, value.mod],
|
|
298
350
|
[`ranged.${key}.desc`, value.desc],
|
|
299
|
-
[`ranged.${key}.damage`, value.damage],
|
|
351
|
+
...(value.damage ? [[`ranged.${key}.damage`, value.damage]] : []),
|
|
300
352
|
];
|
|
301
|
-
const recallDCs = (level, secret) => ((value) => [
|
|
353
|
+
const recallDCs = (level, secret, bump) => ((value) => [
|
|
302
354
|
['dc.recall.incredibly-easy', secret ? `||${value - 10}||` : `${value - 10}`],
|
|
303
355
|
['dc.recall.very-easy', secret ? `||${value - 5}||` : `${value - 5}`],
|
|
304
356
|
['dc.recall.easy', secret ? `||${value - 2}||` : `${value - 2}`],
|
|
@@ -307,73 +359,99 @@ const recallDCs = (level, secret) => ((value) => [
|
|
|
307
359
|
['dc.recall.hard', secret ? `||${value + 2}||` : `${value + 2}`],
|
|
308
360
|
['dc.recall.very-hard', secret ? `||${value + 5}||` : `${value + 5}`],
|
|
309
361
|
['dc.recall.incredibly-hard', secret ? `||${value + 10}||` : `${value + 10}`],
|
|
310
|
-
])(dcByLevel[Math.max(Math.min(level + 1, dcByLevel.length - 1), 0)]);
|
|
311
|
-
const flatten = (stats, secretDC = false, defaultSkills = false, recallDC = false
|
|
312
|
-
|
|
313
|
-
const
|
|
314
|
-
|
|
362
|
+
])(dcByLevel[Math.max(Math.min(level + 1, dcByLevel.length - 1), 0)] + bump);
|
|
363
|
+
const flatten = (stats, secretDC = false, defaultSkills = false, recallDC = false) => {
|
|
364
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
365
|
+
const untrained = stats.untrained;
|
|
366
|
+
const skills = defaultSkills ? Object.assign({ acrobatics: untrained + stats.attributes.dexterity, arcana: untrained + stats.attributes.intelligence, athletics: untrained + stats.attributes.strength, crafting: untrained + stats.attributes.intelligence, deception: untrained + stats.attributes.charisma, diplomacy: untrained + stats.attributes.charisma, intimidation: untrained + stats.attributes.charisma, medicine: untrained + stats.attributes.wisdom, nature: untrained + stats.attributes.wisdom, occultism: untrained + stats.attributes.intelligence, performance: untrained + stats.attributes.charisma, religion: untrained + stats.attributes.wisdom, society: untrained + stats.attributes.intelligence, stealth: untrained + stats.attributes.dexterity, survival: untrained + stats.attributes.wisdom, thievery: untrained + stats.attributes.dexterity }, stats.skills) : stats.skills;
|
|
367
|
+
let melee = (0, lodash_1.entries)(stats.melee).map(([k, v]) => {
|
|
368
|
+
var _a;
|
|
369
|
+
return [k, {
|
|
370
|
+
mod: v.mod + ((_a = stats.bump.attack) !== null && _a !== void 0 ? _a : stats.bump.default),
|
|
371
|
+
desc: v.desc,
|
|
372
|
+
damage: stats.bump.default > 0 ? `${v.damage} +${stats.bump.default}` : v.damage,
|
|
373
|
+
}];
|
|
374
|
+
});
|
|
315
375
|
if (melee.length > 0) {
|
|
316
376
|
melee = [
|
|
317
377
|
['default', melee[0][1]],
|
|
318
378
|
...melee,
|
|
319
379
|
];
|
|
320
380
|
}
|
|
321
|
-
let ranged = (0, lodash_1.entries)(stats.ranged)
|
|
381
|
+
let ranged = (0, lodash_1.entries)(stats.ranged).map(([k, v]) => {
|
|
382
|
+
var _a;
|
|
383
|
+
return [k, {
|
|
384
|
+
mod: v.mod + ((_a = stats.bump.attack) !== null && _a !== void 0 ? _a : stats.bump.default),
|
|
385
|
+
desc: v.desc,
|
|
386
|
+
damage: v.damage && stats.bump.default > 0 ? `${v.damage} +${stats.bump.default}` : v.damage,
|
|
387
|
+
}];
|
|
388
|
+
});
|
|
322
389
|
if (ranged.length > 0) {
|
|
323
390
|
ranged = [
|
|
324
391
|
['default', ranged[0][1]],
|
|
325
392
|
...ranged,
|
|
326
393
|
];
|
|
327
394
|
}
|
|
395
|
+
const maxhp = stats.bump.default > 0 ? (stats.bump.hp ? (stats.bump.hp + stats.maxhp) : Math.max(Math.floor(stats.maxhp * 1.1), stats.maxhp + 10)) : stats.maxhp;
|
|
396
|
+
const saveInfo = Object.assign(Object.assign({}, stats.saveInfo), { reflex: stats.bullwark > 0 ? [...stats.saveInfo.reflex, `+${stats.bullwark} more vs damage`] : stats.saveInfo.reflex });
|
|
397
|
+
const untrainedSkillInfo = (0, lodash_1.entries)((0, lodash_1.mapValues)((0, lodash_1.groupBy)((0, lodash_1.difference)((0, lodash_1.keys)(skills), (0, lodash_1.keys)(stats.skills)), (k) => k), () => ['untrained']));
|
|
398
|
+
const specifiedSkillInfo = (0, lodash_1.entries)(stats.skillInfo);
|
|
399
|
+
const skillInfo = (0, lodash_1.mapValues)((0, lodash_1.groupBy)([...untrainedSkillInfo, ...specifiedSkillInfo], ([k]) => k), (list) => list.reduce((p, [, v]) => [...p, ...v], []));
|
|
328
400
|
return [
|
|
329
401
|
['name', stats.name],
|
|
330
402
|
...(stats.alias ? [['alias', stats.alias]] : []),
|
|
331
403
|
['gamesystem', 'pf2e'],
|
|
332
404
|
['level', stats.level],
|
|
333
405
|
['lvl', stats.level],
|
|
334
|
-
['
|
|
406
|
+
['hp', maxhp],
|
|
407
|
+
['maxhp', maxhp],
|
|
335
408
|
...(0, lodash_1.entries)(stats.attributes),
|
|
336
409
|
...(0, lodash_1.entries)(stats.attributes).map(([key, value]) => [key.substring(0, 3), value]),
|
|
337
|
-
['ac', secretDC ? `||${stats.ac}||` : stats.ac],
|
|
338
|
-
...(0, lodash_1.entries)(stats.saves),
|
|
339
|
-
['fort', stats.saves.fortitude],
|
|
340
|
-
['ref', stats.saves.reflex],
|
|
341
|
-
['perception', stats.perception],
|
|
342
|
-
...(0, lodash_1.entries)(skills),
|
|
343
|
-
...(0, lodash_1.entries)(stats.lores).
|
|
344
|
-
...(
|
|
345
|
-
...(0, lodash_1.entries)(stats.saves).map(([key]) => [`${key}.desc`, `${(0, lodash_1.capitalize)(key)} Save`]),
|
|
346
|
-
['fort.desc', 'Fortitude Save'],
|
|
347
|
-
['ref.desc', 'Reflex Save'],
|
|
348
|
-
['perception.desc', 'Perception Check'],
|
|
349
|
-
...(0, lodash_1.entries)(skills).map(([key]) => [`${key}.desc`, `${(0, lodash_1.capitalize)(key)} Check`]),
|
|
350
|
-
...(0, lodash_1.entries)(stats.lores).map(([key, value]) => [`lore.${key}.desc`, `${value.name} Lore Check`]),
|
|
351
|
-
...(stats.spells.attack ? [['spells.desc', 'Spell Attack']] : []),
|
|
352
|
-
] : []),
|
|
410
|
+
['ac', secretDC ? `||${stats.ac + ((_a = stats.bump.ac) !== null && _a !== void 0 ? _a : stats.bump.default)}||` : stats.ac + ((_b = stats.bump.ac) !== null && _b !== void 0 ? _b : stats.bump.default)],
|
|
411
|
+
...(0, lodash_1.entries)(stats.saves).map(([k, v]) => { var _a; return [k, v + ((_a = stats.bump.saves) !== null && _a !== void 0 ? _a : stats.bump.default)]; }),
|
|
412
|
+
['fort', stats.saves.fortitude + ((_c = stats.bump.saves) !== null && _c !== void 0 ? _c : stats.bump.default)],
|
|
413
|
+
['ref', stats.saves.reflex + ((_d = stats.bump.saves) !== null && _d !== void 0 ? _d : stats.bump.default)],
|
|
414
|
+
['perception', stats.perception + ((_e = stats.bump.perception) !== null && _e !== void 0 ? _e : stats.bump.default)],
|
|
415
|
+
...(0, lodash_1.entries)(skills.performance ? Object.assign(Object.assign({}, skills), { perfomance: skills.performance }) : skills).map(([k, v]) => { var _a; return [k, v + ((_a = stats.bump.skills) !== null && _a !== void 0 ? _a : stats.bump.default)]; }),
|
|
416
|
+
...(0, lodash_1.entries)(stats.lores).map(toLoreMod).map(([k, v]) => { var _a; return [k, v + ((_a = stats.bump.skills) !== null && _a !== void 0 ? _a : stats.bump.default)]; }),
|
|
417
|
+
...(0, lodash_1.entries)(stats.lores).map(toLoreName),
|
|
353
418
|
...melee.flatMap(toMelee),
|
|
354
419
|
...ranged.flatMap(toRanged),
|
|
355
420
|
...(0, lodash_1.entries)(stats.extra),
|
|
356
|
-
...(stats.spells.attack ? [['spells', stats.spells.attack]] : []),
|
|
357
|
-
...(stats.spells.dc ? [dc2DC(secretDC)(['spells', stats.spells.dc])] : []),
|
|
358
|
-
...(
|
|
421
|
+
...(stats.spells.attack ? [['spells', stats.spells.attack + ((_f = stats.bump.attack) !== null && _f !== void 0 ? _f : stats.bump.default)]] : []),
|
|
422
|
+
...(stats.spells.dc ? [dc2DC(secretDC, (_g = stats.bump.spells) !== null && _g !== void 0 ? _g : stats.bump.default)(['spells', stats.spells.dc])] : []),
|
|
423
|
+
...(stats.classDC ? [['classDC', secretDC ? `||${stats.classDC + stats.bump.default}||` : `${stats.classDC + stats.bump.default}`]] : []),
|
|
424
|
+
...(stats.classDC ? [dc2DC(secretDC, stats.bump.default)(['class', stats.classDC])] : []),
|
|
425
|
+
dc2DC(secretDC, stats.bump.default)(['level', dcByLevel[Math.max(Math.min(stats.level + 1, dcByLevel.length - 1), 0)]]),
|
|
426
|
+
dc2DC(secretDC, (_h = stats.bump.ac) !== null && _h !== void 0 ? _h : stats.bump.default)(['ac', stats.ac]),
|
|
427
|
+
...(0, lodash_1.entries)(stats.extraDCs).map(dc2DC(secretDC, stats.bump.default)),
|
|
359
428
|
...(0, lodash_1.entries)(stats.extraDice),
|
|
360
429
|
...(secretDC ? [
|
|
361
|
-
...(0, lodash_1.entries)(stats.saves).map(mod2DC(true)),
|
|
362
|
-
mod2DC(true)(['perception', stats.perception]),
|
|
363
|
-
mod2DC(true)(['fort', stats.saves.fortitude]),
|
|
364
|
-
mod2DC(true)(['ref', stats.saves.reflex]),
|
|
365
|
-
...(0, lodash_1.entries)(skills).map(mod2DC(true)),
|
|
366
|
-
...(0, lodash_1.entries)(stats.extra).map(mod2DC(true)),
|
|
430
|
+
...(0, lodash_1.entries)(stats.saves).map(mod2DC(true, ((_j = stats.bump.saves) !== null && _j !== void 0 ? _j : stats.bump.default))),
|
|
431
|
+
mod2DC(true, stats.bump.default)(['perception', stats.perception]),
|
|
432
|
+
mod2DC(true, ((_k = stats.bump.saves) !== null && _k !== void 0 ? _k : stats.bump.default))(['fort', stats.saves.fortitude]),
|
|
433
|
+
mod2DC(true, ((_l = stats.bump.saves) !== null && _l !== void 0 ? _l : stats.bump.default))(['ref', stats.saves.reflex]),
|
|
434
|
+
...(0, lodash_1.entries)(skills).map(mod2DC(true, ((_m = stats.bump.skills) !== null && _m !== void 0 ? _m : stats.bump.default))),
|
|
435
|
+
...(0, lodash_1.entries)(stats.extra).map(mod2DC(true, stats.bump.default)),
|
|
367
436
|
] : []),
|
|
368
437
|
...(recallDC ? [
|
|
369
|
-
...recallDCs(stats.level, secretDC),
|
|
438
|
+
...recallDCs(stats.level, secretDC, stats.bump.default),
|
|
370
439
|
] : []),
|
|
440
|
+
...(stats.perceptionInfo.length > 0 ? [
|
|
441
|
+
[`perception.info`, `\`(${stats.perceptionInfo.join(', ')})\``]
|
|
442
|
+
] : []),
|
|
443
|
+
...(stats.initiativeInfo.length > 0 ? [
|
|
444
|
+
[`initiative.info`, `\`(${stats.initiativeInfo.join(', ')})\``]
|
|
445
|
+
] : []),
|
|
446
|
+
...(0, lodash_1.entries)(saveInfo).filter(([, v]) => v.length > 0).map(([k, v]) => [`${k}.info`, `\`(${v.join(', ')})\``]),
|
|
447
|
+
...(0, lodash_1.entries)(skillInfo).filter(([, v]) => v.length > 0).map(([k, v]) => [`${k}.info`, `\`(${v.join(', ')})\``]),
|
|
448
|
+
['out', secretDC ? 'xs' : 'm'],
|
|
371
449
|
].reduce((p, [key, value]) => { p[key] = value; return p; }, {});
|
|
372
450
|
};
|
|
373
451
|
exports.flatten = flatten;
|
|
374
|
-
const formatTSV = (stats, secretDC = false, defaultSkills = false, recallDC = false
|
|
452
|
+
const formatTSV = (stats, secretDC = false, defaultSkills = false, recallDC = false) => (tsv_1.TSV.stringify([(0, exports.flatten)(stats, secretDC, defaultSkills, recallDC)]));
|
|
375
453
|
exports.formatTSV = formatTSV;
|
|
376
|
-
const formatCommand = (stats, secretDC = false, defaultSkills = false, recallDC = false
|
|
454
|
+
const formatCommand = (stats, secretDC = false, defaultSkills = false, recallDC = false) => (Object.entries((0, exports.flatten)(stats, secretDC, defaultSkills, recallDC)).map(([k, v]) => `${k}="${v}"`).join(' '));
|
|
377
455
|
exports.formatCommand = formatCommand;
|
|
378
456
|
const formatTable = (table, season, scenario, _name, gm, players) => {
|
|
379
457
|
const name = _name.replace(/[\s-_]/g, ' ').replace(/[^a-zA-Z0-9 ]/g, '');
|
|
@@ -407,3 +485,19 @@ const formatHP = (arg) => {
|
|
|
407
485
|
return _formatHP(negative ? maxhp - hp : hp, maxhp);
|
|
408
486
|
};
|
|
409
487
|
exports.formatHP = formatHP;
|
|
488
|
+
const sortFolder = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
489
|
+
const dir = yield (0, promises_1.readdir)('.');
|
|
490
|
+
const summary = yield Promise.all(dir.map((file) => __awaiter(void 0, void 0, void 0, function* () {
|
|
491
|
+
const stats = yield (0, promises_1.stat)(file);
|
|
492
|
+
const timestamp = parseInt(stats.birthtimeMs.toFixed(0));
|
|
493
|
+
return { file, timestamp };
|
|
494
|
+
})));
|
|
495
|
+
const transformed = summary.sort((a, b) => a.timestamp - b.timestamp).map((s, index) => {
|
|
496
|
+
const prefix = String(index + 1).padStart(3, '0');
|
|
497
|
+
const name = s.file.replace('RU PFS Online - ', '').replace(/\s\[.+\]/, '');
|
|
498
|
+
return { oldname: s.file, newname: name.startsWith('ooc') ? name : `${prefix} ${name}` };
|
|
499
|
+
});
|
|
500
|
+
yield Promise.all(transformed.map((t) => __awaiter(void 0, void 0, void 0, function* () { return (0, promises_1.rename)(t.oldname, t.newname); })));
|
|
501
|
+
return transformed;
|
|
502
|
+
});
|
|
503
|
+
exports.sortFolder = sortFolder;
|
package/dist/index.js
CHANGED
|
@@ -46,10 +46,10 @@ program.command('table')
|
|
|
46
46
|
.action((argument, option) => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
47
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
48
48
|
if (option.output) {
|
|
49
|
-
yield promises_1.default.writeFile(option.output, (0, app_1.formatTable)(
|
|
49
|
+
yield promises_1.default.writeFile(option.output, (0, app_1.formatTable)((_a = option.table) !== null && _a !== void 0 ? _a : '1', (_b = option.season) !== null && _b !== void 0 ? _b : '1', (_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
50
|
}
|
|
51
51
|
else {
|
|
52
|
-
console.log((0, app_1.formatTable)(
|
|
52
|
+
console.log((0, app_1.formatTable)((_f = option.table) !== null && _f !== void 0 ? _f : '1', (_g = option.season) !== null && _g !== void 0 ? _g : '1', (_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
53
|
}
|
|
54
54
|
}));
|
|
55
55
|
program.command('hp')
|
|
@@ -58,71 +58,22 @@ program.command('hp')
|
|
|
58
58
|
.action((argument) => __awaiter(void 0, void 0, void 0, function* () {
|
|
59
59
|
console.log((0, app_1.formatHP)(argument));
|
|
60
60
|
}));
|
|
61
|
+
program.command('sort')
|
|
62
|
+
.description('Sorts log file folder and renames files')
|
|
63
|
+
.action(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
64
|
+
console.log(yield (0, app_1.sortFolder)());
|
|
65
|
+
}));
|
|
61
66
|
program.command('flat')
|
|
62
67
|
.description('Generte a special flat npc tsv')
|
|
63
68
|
.option('-n, --name <string>', 'npc name')
|
|
64
69
|
.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
70
|
.action((option) => __awaiter(void 0, void 0, void 0, function* () {
|
|
120
71
|
var _a, _b;
|
|
121
72
|
if (option.output) {
|
|
122
|
-
yield promises_1.default.writeFile(option.output, (0, app_1.fromatMap)((_a = option.name) !== null && _a !== void 0 ? _a : '
|
|
73
|
+
yield promises_1.default.writeFile(option.output, (0, app_1.fromatMap)((_a = option.name) !== null && _a !== void 0 ? _a : 'flat', app_1.prediceateMap), { encoding: 'utf-8' });
|
|
123
74
|
}
|
|
124
75
|
else {
|
|
125
|
-
console.log((0, app_1.fromatMap)((_b = option.name) !== null && _b !== void 0 ? _b : '
|
|
76
|
+
console.log((0, app_1.fromatMap)((_b = option.name) !== null && _b !== void 0 ? _b : 'flat', app_1.prediceateMap));
|
|
126
77
|
}
|
|
127
78
|
}));
|
|
128
79
|
program.command('adjustment')
|
|
@@ -148,7 +99,6 @@ program.command('statblock')
|
|
|
148
99
|
.option('-c, --command', 'output directly to txt')
|
|
149
100
|
.option('-s, --secretDC', 'produce secret DCs (tsv only)')
|
|
150
101
|
.option('-d, --defaultSkills', 'produce values for untrained skills (tsv only)')
|
|
151
|
-
.option('-e, --desc', 'produce verbose desc fields (tsv only)')
|
|
152
102
|
.option('-o, --output <file>', 'output file name')
|
|
153
103
|
.action((argument, option) => __awaiter(void 0, void 0, void 0, function* () {
|
|
154
104
|
var _a, _b;
|
|
@@ -157,11 +107,11 @@ program.command('statblock')
|
|
|
157
107
|
const stats = (0, app_1.parseStatblock)((_b = option.name) !== null && _b !== void 0 ? _b : null, file, alias);
|
|
158
108
|
if (option.tsv) {
|
|
159
109
|
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
|
|
110
|
+
yield promises_1.default.writeFile(output, (0, app_1.formatTSV)(stats, option.secretDC, option.defaultSkills), { encoding: 'utf-8' });
|
|
161
111
|
}
|
|
162
112
|
else if (option.command) {
|
|
163
113
|
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
|
|
114
|
+
yield promises_1.default.writeFile(output, (0, app_1.formatCommand)(stats, option.secretDC, option.defaultSkills), { encoding: 'utf-8' });
|
|
165
115
|
}
|
|
166
116
|
else {
|
|
167
117
|
const output = option.output ? option.output : path_1.default.join(path_1.default.parse(argument).dir, stats.alias + '.json');
|
|
@@ -175,12 +125,11 @@ program.command('tsv')
|
|
|
175
125
|
.option('-s, --secretDC', 'produce secret DCs')
|
|
176
126
|
.option('-r, --recallDC', 'produce recall DCs')
|
|
177
127
|
.option('-d, --defaultSkills', 'produce values for untrained skills')
|
|
178
|
-
.option('-e, --desc', 'produce verbose desc fields')
|
|
179
128
|
.action((argument, option) => __awaiter(void 0, void 0, void 0, function* () {
|
|
180
129
|
const file = yield promises_1.default.readFile(argument, { encoding: 'utf-8' });
|
|
181
130
|
const stats = (0, app_1.parseJSON)(file);
|
|
182
131
|
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
|
|
132
|
+
yield promises_1.default.writeFile(output, (0, app_1.formatTSV)(stats, option.secretDC, option.defaultSkills, option.recallDC), { encoding: 'utf-8' });
|
|
184
133
|
}));
|
|
185
134
|
program.command('command')
|
|
186
135
|
.description('Generte a creation command file from JSON')
|
|
@@ -189,11 +138,10 @@ program.command('command')
|
|
|
189
138
|
.option('-s, --secretDC', 'produce secret DCs')
|
|
190
139
|
.option('-r, --recallDC', 'produce recall DCs')
|
|
191
140
|
.option('-d, --defaultSkills', 'produce values for untrained skills')
|
|
192
|
-
.option('-e, --desc', 'produce verbose desc fields')
|
|
193
141
|
.action((argument, option) => __awaiter(void 0, void 0, void 0, function* () {
|
|
194
142
|
const file = yield promises_1.default.readFile(argument, { encoding: 'utf-8' });
|
|
195
143
|
const stats = (0, app_1.parseJSON)(file);
|
|
196
144
|
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
|
|
145
|
+
yield promises_1.default.writeFile(output, (0, app_1.formatCommand)(stats, option.secretDC, option.defaultSkills, option.recallDC), { encoding: 'utf-8' });
|
|
198
146
|
}));
|
|
199
147
|
program.parse();
|