pf2e-sage-stats 0.2.6 → 0.2.8
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 +53 -38
- package/dist/app.js +23 -16
- package/dist/index.js +45 -0
- package/package.json +1 -1
- package/src/app.ts +21 -10
- package/src/index.ts +43 -1
package/README.md
CHANGED
|
@@ -14,108 +14,123 @@ sage! macro set name="spell" dice="[{{p}::{o:out}:{o:m}} {x} {flat::{f:none}:{f}
|
|
|
14
14
|
```
|
|
15
15
|
### Saves
|
|
16
16
|
```
|
|
17
|
-
sage! macro set name="
|
|
17
|
+
sage! macro set name="save" dice="[{{p}::{o:out}:{o:m}} {x} {flat::{f:none}:{f}} {dice::{d:none}:{d:1}}d20+{{p}::{0}:{a:0}} {m} {v} {{p}::name:} (mod `{m:+0}`) {{p}::{0}.info:} {0} Save {utils::{t:known}:vs} {{t:none}::name:} {utils::{t:known}:`{r:Spell} DC ({c:+0} DC) `} {dc} {utils::{t:known}:dc} {{t:none}::dc.{r:spells}:} {c} {...}]" cat=Saves tier=Server -y
|
|
18
18
|
```
|
|
19
19
|
```
|
|
20
|
-
sage! macro set name="
|
|
20
|
+
sage! macro set name="fort" dice="[save Fortitude {...}]" cat=Saves tier=Server -y
|
|
21
21
|
```
|
|
22
22
|
```
|
|
23
|
-
sage! macro set name="
|
|
23
|
+
sage! macro set name="fortitude" dice="[save Fortitude {...}]" cat=Saves tier=Server -y
|
|
24
24
|
```
|
|
25
25
|
```
|
|
26
|
-
sage! macro set name="
|
|
26
|
+
sage! macro set name="ref" dice="[save Reflex {...}]" cat=Saves tier=Server -y
|
|
27
27
|
```
|
|
28
28
|
```
|
|
29
|
-
sage! macro set name="
|
|
29
|
+
sage! macro set name="reflex" dice="[save Reflex {...}]" cat=Saves tier=Server -y
|
|
30
30
|
```
|
|
31
|
-
### Initiative
|
|
32
31
|
```
|
|
33
|
-
sage! macro set name="
|
|
32
|
+
sage! macro set name="will" dice="[save Will {...}]" cat=Saves tier=Server -y
|
|
34
33
|
```
|
|
34
|
+
### Initiative
|
|
35
35
|
```
|
|
36
36
|
sage! macro set name="initiative" dice="[{{p}::{o:out}:{o:m}} {x} {flat::{f:none}:{f}} {dice::{d:none}:{d:1}}d20+{{p}::{s:Perception}:{a:0}} {m} {v} {{p}::name:} (mod `{m:+0}`) {{p}::initiative.info:} Initiative `({s:Perception}) `{...}]" cat=Initiative tier=Server -y
|
|
37
37
|
```
|
|
38
|
-
### Skills 1
|
|
39
38
|
```
|
|
40
|
-
sage! macro set name="
|
|
39
|
+
sage! macro set name="init" dice="[initiative {...}]" cat=Initiative tier=Server -y
|
|
41
40
|
```
|
|
41
|
+
### Skills 1
|
|
42
42
|
```
|
|
43
|
-
sage! macro set name="
|
|
43
|
+
sage! macro set name="skill" dice="[{{p}::{o:out}:{o:m}} {x} {flat::{f:none}:{f}} {dice::{d:none}:{d:1}}d20+{{p}::{0}:{a:0}} {m} {v} {{p}::name:} (mod `{m:+0}`) {{p}::{0}.info:} {0} Skill Check {utils::{t:known}:vs} {{t:none}::name:} {utils::{t:known}:`{r:Spell} DC ({c:+0} DC) `} {dc} {utils::{t:known}:dc} {{t:none}::dc.{r:spells}:} {c} {...}]" cat=Skills tier=Server -y
|
|
44
44
|
```
|
|
45
45
|
```
|
|
46
|
-
sage! macro set name="
|
|
46
|
+
sage! macro set name="lore" dice="[{{p}::{o:out}:{o:m}} {x} {flat::{f:none}:{f}} {dice::{d:none}:{d:1}}d20+{{p}::lore.{0}:{a:0}} {m} {v} {{p}::name:} (mod `{m:+0}`) {{p}::lore.{0}.info:} {{p}::lore.{0}.name:} Lore Check {utils::{t:known}:vs} {{t:none}::name:} {utils::{t:known}:`{r:Spell} DC ({c:+0} DC) `} {dc} {utils::{t:known}:dc} {{t:none}::dc.{r:spells}:} {c} {...}]" cat=Skills tier=Server -y
|
|
47
47
|
```
|
|
48
48
|
```
|
|
49
|
-
sage! macro set name="
|
|
49
|
+
sage! macro set name="assurance" dice="[{{p}::{o:out}:{o:m}} {x} {flat::{f:none}:{f}} (10)d20+{0:0}-10 {v} {{p}::name:} Assurance Check {utils::{t:known}:vs} {{t:none}::name:} {utils::{t:known}:`{r:Spell} DC ({c:+0} DC) `} {dc} {utils::{t:known}:dc} {{t:none}::dc.{r:spells}:} {c} {...}]" cat=Skills tier=Server -y
|
|
50
50
|
```
|
|
51
51
|
```
|
|
52
|
-
sage! macro set name="
|
|
52
|
+
sage! macro set name="secret" dice="[{{p}::{o:out}:{o:m}} {x} {flat::{f:none}:{f}} d20+{{p}::{0}:{a:0}} {v} {{p}::name:} Secret {0} Check {utils::{t:known}:vs} {{t:none}::name:} {utils::{t:known}:`{r:Spell} DC ({c:+0} DC) `} {dc} {utils::{t:known}:dc} {{t:none}::dc.{r:spells}:} {c} {...}]" cat=Skills tier=Server -y
|
|
53
53
|
```
|
|
54
54
|
### Skills 2
|
|
55
55
|
```
|
|
56
|
-
sage! macro set name="
|
|
56
|
+
sage! macro set name="acrobatics" dice="[skill Acrobatics {...}]" cat=Skills tier=Server -y
|
|
57
57
|
```
|
|
58
58
|
```
|
|
59
|
-
sage! macro set name="
|
|
59
|
+
sage! macro set name="arcana" dice="[skill Arcana {...}]" cat=Skills tier=Server -y
|
|
60
60
|
```
|
|
61
61
|
```
|
|
62
|
-
sage! macro set name="
|
|
62
|
+
sage! macro set name="athletics" dice="[skill Athletics {...}]" cat=Skills tier=Server -y
|
|
63
63
|
```
|
|
64
64
|
```
|
|
65
|
-
sage! macro set name="
|
|
65
|
+
sage! macro set name="crafting" dice="[skill Crafting {...}]" cat=Skills tier=Server -y
|
|
66
66
|
```
|
|
67
67
|
```
|
|
68
|
-
sage! macro set name="
|
|
68
|
+
sage! macro set name="craft" dice="[crafting {...}]" cat=Skills tier=Server -y
|
|
69
69
|
```
|
|
70
|
-
### Skills 3
|
|
71
70
|
```
|
|
72
|
-
sage! macro set name="
|
|
71
|
+
sage! macro set name="deception" dice="[skill Deception {...}]" cat=Skills tier=Server -y
|
|
73
72
|
```
|
|
74
73
|
```
|
|
75
|
-
sage! macro set name="
|
|
74
|
+
sage! macro set name="diplomacy" dice="[skill Diplomacy {...}]" cat=Skills tier=Server -y
|
|
76
75
|
```
|
|
77
76
|
```
|
|
78
|
-
sage! macro set name="
|
|
77
|
+
sage! macro set name="intimidation" dice="[skill Intimidation {...}]" cat=Skills tier=Server -y
|
|
79
78
|
```
|
|
80
79
|
```
|
|
81
|
-
sage! macro set name="
|
|
80
|
+
sage! macro set name="medicine" dice="[skill Medicine {...}]" cat=Skills tier=Server -y
|
|
82
81
|
```
|
|
83
82
|
```
|
|
84
|
-
sage! macro set name="
|
|
83
|
+
sage! macro set name="nature" dice="[skill Nature {...}]" cat=Skills tier=Server -y
|
|
85
84
|
```
|
|
86
|
-
### Skills 4
|
|
87
85
|
```
|
|
88
|
-
sage! macro set name="
|
|
86
|
+
sage! macro set name="occultism" dice="[skill Occultism {...}]" cat=Skills tier=Server -y
|
|
89
87
|
```
|
|
90
88
|
```
|
|
91
|
-
sage! macro set name="
|
|
89
|
+
sage! macro set name="performance" dice="[skill Performance {...}]" cat=Skills tier=Server -y
|
|
92
90
|
```
|
|
93
91
|
```
|
|
94
|
-
sage! macro set name="
|
|
92
|
+
sage! macro set name="perfomance" dice="[performance {...}]" cat=Skills tier=Server -y
|
|
95
93
|
```
|
|
96
94
|
```
|
|
97
|
-
sage! macro set name="
|
|
95
|
+
sage! macro set name="religion" dice="[skill Religion {...}]" cat=Skills tier=Server -y
|
|
98
96
|
```
|
|
99
97
|
```
|
|
100
|
-
sage! macro set name="
|
|
98
|
+
sage! macro set name="society" dice="[skill Society {...}]" cat=Skills tier=Server -y
|
|
101
99
|
```
|
|
102
|
-
### Skills 5
|
|
103
100
|
```
|
|
104
|
-
sage! macro set name="
|
|
101
|
+
sage! macro set name="stealth" dice="[skill Stealth {...}]" cat=Skills tier=Server -y
|
|
105
102
|
```
|
|
106
103
|
```
|
|
107
|
-
sage! macro set name="
|
|
104
|
+
sage! macro set name="survival" dice="[skill Survival {...}]" cat=Skills tier=Server -y
|
|
108
105
|
```
|
|
109
106
|
```
|
|
110
|
-
sage! macro set name="
|
|
107
|
+
sage! macro set name="thievery" dice="[skill Thievery {...}]" cat=Skills tier=Server -y
|
|
108
|
+
```
|
|
109
|
+
```
|
|
110
|
+
sage! macro set name="perception" dice="[skill Perception {...}]" cat=Skills tier=Server -y
|
|
111
|
+
```
|
|
112
|
+
```
|
|
113
|
+
sage! macro set name="piloting" dice="[skill Piloting {...}]" cat=Skills tier=Server -y
|
|
114
|
+
```
|
|
115
|
+
```
|
|
116
|
+
sage! macro set name="computers" dice="[skill Computers {...}]" cat=Skills tier=Server -y
|
|
117
|
+
```
|
|
118
|
+
### Actions
|
|
119
|
+
```
|
|
120
|
+
sage! macro set name="demoralize" category="Actions" dice="[intimidation r=Will {...}]" tier=Server -y
|
|
121
|
+
```
|
|
122
|
+
```
|
|
123
|
+
sage! macro set name="grapple" category="Actions" dice="[athletics r=Fortitude {...}]" tier=Server -y
|
|
124
|
+
```
|
|
111
125
|
```
|
|
112
|
-
|
|
126
|
+
sage! macro set name="trip" category="Actions" dice="[athletics r=Reflex {...}]" tier=Server -y
|
|
113
127
|
```
|
|
114
|
-
sage! macro set name="mstrike" dice="[{{p}::{o:out}:{o:m}} {x} {flat::{f:none}:{f}} {dice::{d:none}:{d:1}}d20+{{p}::melee.{s:default}:{a:0}} {m} {v} {{p}::name:} (mod `{m:+0}`) {{p}::melee.{s:default}.desc:} vs {{0}::name:} `({c:+0} AC) ` ac {{0}::{r:ac}:} {c} {{p}::melee.{s:default}.damage:} {...}]" cat=Strikes tier=Server -y
|
|
115
128
|
```
|
|
129
|
+
sage! macro set name="shove" category="Actions" dice="[athletics r=Fortitude {...}]" tier=Server -y
|
|
116
130
|
```
|
|
117
|
-
sage! macro set name="rstrike" dice="[{{p}::{o:out}:{o:m}} {x} {flat::{f:none}:{f}} {dice::{d:none}:{d:1}}d20+{{p}::ranged.{s:default}:{a:0}} {m} {v} {{p}::name:} (mod `{m:+0}`) {{p}::ranged.{s:default}.desc:} vs {{0}::name:} `({c:+0} AC) ` ac {{0}::{r:ac}:} {c} {{p}::ranged.{s:default}.damage:} {...}]" cat=Strikes tier=Server -y
|
|
118
131
|
```
|
|
132
|
+
sage! macro set name="disarm" category="Actions" dice="[athletics r=Reflex {...}]" tier=Server -y
|
|
119
133
|
```
|
|
120
|
-
sage! macro set name="sstrike" dice="[{{p}::{o:out}:{o:m}} {x} {flat::{f:none}:{f}} {dice::{d:none}:{d:1}}d20+{{p}::spells:{a:0}} {m} {v} {{p}::name:} (mod `{m:+0}`) Spell Attack vs {{0}::name:} `({c:+0} AC) ` ac {{0}::{r:ac}:} {c} {...}]" cat=Strikes tier=Server -y
|
|
121
134
|
```
|
|
135
|
+
sage! macro set name="feint" category="Actions" dice="[deception r=Preception {...}]" tier=Server -y
|
|
136
|
+
```
|
package/dist/app.js
CHANGED
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.screenPlay = exports.sortFolder = 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.stub = void 0;
|
|
15
|
+
exports.screenPlay = exports.sortFolder = 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.charSchema = exports.stub = void 0;
|
|
16
16
|
const zod_1 = __importDefault(require("zod"));
|
|
17
17
|
const tsv_1 = require("tsv");
|
|
18
18
|
const lodash_1 = require("lodash");
|
|
@@ -60,6 +60,8 @@ const schema = zod_1.default.object({
|
|
|
60
60
|
stealth: zod_1.default.coerce.number().optional(),
|
|
61
61
|
survival: zod_1.default.coerce.number().optional(),
|
|
62
62
|
thievery: zod_1.default.coerce.number().optional(),
|
|
63
|
+
piloting: zod_1.default.coerce.number().optional(),
|
|
64
|
+
computers: zod_1.default.coerce.number().optional(),
|
|
63
65
|
}).default({}),
|
|
64
66
|
lores: zod_1.default.record(zod_1.default.string(), zod_1.default.object({
|
|
65
67
|
mod: zod_1.default.coerce.number().default(0),
|
|
@@ -118,6 +120,8 @@ const schema = zod_1.default.object({
|
|
|
118
120
|
stealth: zod_1.default.array(zod_1.default.string()).optional(),
|
|
119
121
|
survival: zod_1.default.array(zod_1.default.string()).optional(),
|
|
120
122
|
thievery: zod_1.default.array(zod_1.default.string()).optional(),
|
|
123
|
+
piloting: zod_1.default.array(zod_1.default.string()).optional(),
|
|
124
|
+
computers: zod_1.default.array(zod_1.default.string()).optional(),
|
|
121
125
|
}).default({}),
|
|
122
126
|
});
|
|
123
127
|
exports.stub = {
|
|
@@ -159,6 +163,8 @@ exports.stub = {
|
|
|
159
163
|
stealth: 0,
|
|
160
164
|
survival: 0,
|
|
161
165
|
thievery: 0,
|
|
166
|
+
piloting: 0,
|
|
167
|
+
computers: 0,
|
|
162
168
|
},
|
|
163
169
|
lores: {},
|
|
164
170
|
melee: {
|
|
@@ -189,7 +195,7 @@ const childSchema = zod_1.default.object({
|
|
|
189
195
|
maxhp: zod_1.default.coerce.number().default(10),
|
|
190
196
|
conditions: zod_1.default.string().default(''),
|
|
191
197
|
});
|
|
192
|
-
|
|
198
|
+
exports.charSchema = zod_1.default.object({
|
|
193
199
|
init: zod_1.default.coerce.number().default(0),
|
|
194
200
|
foe: zod_1.default.boolean().default(false),
|
|
195
201
|
state: zod_1.default.union([zod_1.default.literal('empty'), zod_1.default.literal('arrow'), zod_1.default.literal('check'), zod_1.default.literal('cross')]).default('empty'),
|
|
@@ -213,7 +219,7 @@ const formatJSON = (stats) => JSON.stringify(stats, undefined, 2);
|
|
|
213
219
|
exports.formatJSON = formatJSON;
|
|
214
220
|
const parseJSON = (json) => schema.parse(JSON.parse(json));
|
|
215
221
|
exports.parseJSON = parseJSON;
|
|
216
|
-
const parseTracker = (json) => zod_1.default.array(charSchema).parse(JSON.parse(json));
|
|
222
|
+
const parseTracker = (json) => zod_1.default.array(exports.charSchema).parse(JSON.parse(json));
|
|
217
223
|
exports.parseTracker = parseTracker;
|
|
218
224
|
const locateName = (statblock) => {
|
|
219
225
|
const regex = /^([^()]+?)(\s+\(\d+\))?\s+\S+\s+(-?\d+)$/m;
|
|
@@ -285,18 +291,19 @@ const locateStrikes = (statblock, alias) => {
|
|
|
285
291
|
.replace(/\s+/g, ' ')
|
|
286
292
|
.replace(bps, (m) => m.toUpperCase())
|
|
287
293
|
.replace(/1d/, 'd')
|
|
288
|
-
.replace(/jousting\s+d\d
|
|
294
|
+
.replace(/jousting\s+d(\d+)/g, 'jousting-$1')
|
|
295
|
+
.replace(/boost\s+d(\d+)/g, 'boost-$1')
|
|
289
296
|
.trim();
|
|
290
297
|
const _dice = dice
|
|
291
298
|
.replace(/\s+/g, ' ')
|
|
292
299
|
.replace(bps, (m) => { var _a; return ((_a = { b: 'bludgeoning', p: 'piercing', s: 'slashing' }[m.toLowerCase()]) !== null && _a !== void 0 ? _a : m); })
|
|
293
|
-
.replace(/Fire
|
|
294
|
-
.replace(/Cold
|
|
295
|
-
.replace(/Electricity
|
|
296
|
-
.replace(/Sonic
|
|
297
|
-
.replace(/Spirit
|
|
298
|
-
.replace(/Acid
|
|
299
|
-
.replace(/[pP]lus\s(\d+d)
|
|
300
|
+
.replace(/Fire/g, 'fire')
|
|
301
|
+
.replace(/Cold/g, 'cold')
|
|
302
|
+
.replace(/Electricity/g, 'electricity')
|
|
303
|
+
.replace(/Sonic/g, 'sonic')
|
|
304
|
+
.replace(/Spirit/g, 'spirit')
|
|
305
|
+
.replace(/Acid/g, 'acid')
|
|
306
|
+
.replace(/[pP]lus\s(\d+d)/g, '+$1')
|
|
300
307
|
.trim();
|
|
301
308
|
const twoHand = _traits.match(/(two-hand|two-handed)\s+(d\d+)/);
|
|
302
309
|
if (twoHand && twoHand[2]) {
|
|
@@ -350,7 +357,7 @@ const parseStatblock = (name, _statblock, alias) => {
|
|
|
350
357
|
.replace('', '')
|
|
351
358
|
.replace(/–/g, '-') + '\n';
|
|
352
359
|
const basic = locateName(statblock);
|
|
353
|
-
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: {} });
|
|
360
|
+
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(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')), locateInt('piloting', statblock, 'Skills')), locateInt('computers', 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: {} });
|
|
354
361
|
result.untrained = improvisation ? (result.level >= 7 ? result.level : result.level >= 5 ? result.level - 1 : result.level - 2) : 0;
|
|
355
362
|
result.bullwark = plate ? Math.max(3 - result.attributes.dexterity, 0) : 0;
|
|
356
363
|
return result;
|
|
@@ -374,7 +381,7 @@ const toRanged = ([key, value]) => [
|
|
|
374
381
|
const flatten = (stats, secretDC = false, defaultSkills = false) => {
|
|
375
382
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
376
383
|
const untrained = stats.untrained;
|
|
377
|
-
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;
|
|
384
|
+
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, piloting: untrained + stats.attributes.dexterity, computers: untrained + stats.attributes.intelligence }, stats.skills) : stats.skills;
|
|
378
385
|
const lores = defaultSkills ? Object.assign(Object.assign({}, stats.lores), { other: {
|
|
379
386
|
mod: untrained + stats.attributes.intelligence,
|
|
380
387
|
name: "Other",
|
|
@@ -459,7 +466,7 @@ const flatten = (stats, secretDC = false, defaultSkills = false) => {
|
|
|
459
466
|
] : []),
|
|
460
467
|
...(0, lodash_1.entries)(saveInfo).filter(([, v]) => v.length > 0).map(([k, v]) => [`${k}.info`, `\`(${v.join(', ')})\``]),
|
|
461
468
|
...(0, lodash_1.entries)(skillInfo).filter(([, v]) => v.length > 0).map(([k, v]) => [`${k}.info`, `\`(${v.join(', ')})\``]),
|
|
462
|
-
['out', secretDC ? 'xs' : '
|
|
469
|
+
['out', secretDC ? 'xs' : 'l'],
|
|
463
470
|
].reduce((p, [key, value]) => { p[key] = value; return p; }, {});
|
|
464
471
|
};
|
|
465
472
|
exports.flatten = flatten;
|
|
@@ -503,11 +510,11 @@ const newtracker = (status) => {
|
|
|
503
510
|
var _a, _b;
|
|
504
511
|
const regex = /((.+)\s+\((\d+)\/(\d+)\s+HP\):(.*)(\n>(.+)\s+\((\d+)\/(\d+)\s+HP\):(.*))*)/gm;
|
|
505
512
|
const match = status.match(regex);
|
|
506
|
-
const tracker = zod_1.default.array(charSchema).parse([]);
|
|
513
|
+
const tracker = zod_1.default.array(exports.charSchema).parse([]);
|
|
507
514
|
for (const m of match !== null && match !== void 0 ? match : []) {
|
|
508
515
|
const mmatch = m.match(/([^>]+)\s+\((\d+)\/(\d+)\s+HP\):(.*)/);
|
|
509
516
|
const cmatch = m.match(/>\s+(\S+)\s+\((\d+)\/(\d+)\s+HP\):(.*)/g);
|
|
510
|
-
const char = charSchema.parse({
|
|
517
|
+
const char = exports.charSchema.parse({
|
|
511
518
|
name: mmatch === null || mmatch === void 0 ? void 0 : mmatch[1],
|
|
512
519
|
hp: mmatch === null || mmatch === void 0 ? void 0 : mmatch[2],
|
|
513
520
|
maxhp: mmatch === null || mmatch === void 0 ? void 0 : mmatch[3],
|
package/dist/index.js
CHANGED
|
@@ -244,6 +244,15 @@ program.command('track')
|
|
|
244
244
|
}, {
|
|
245
245
|
regex: /^\s*reset/i,
|
|
246
246
|
map: () => ({ command: 'reset' })
|
|
247
|
+
}, {
|
|
248
|
+
regex: /^\s*purge/i,
|
|
249
|
+
map: () => ({ command: 'purge' })
|
|
250
|
+
}, {
|
|
251
|
+
regex: /^\s*blank/i,
|
|
252
|
+
map: () => ({ command: 'blank' })
|
|
253
|
+
}, {
|
|
254
|
+
regex: /^\s*foe(\s+(\S+))?(\s+(\S+))?(\s+(\d+))?/i,
|
|
255
|
+
map: (match) => ({ command: 'foe', name: match[2], alias: match[4], hp: match[6] && parseInt(match[6], 10) })
|
|
247
256
|
}, {
|
|
248
257
|
regex: /^\s*heal/i,
|
|
249
258
|
map: () => ({ command: 'heal' })
|
|
@@ -280,6 +289,31 @@ program.command('track')
|
|
|
280
289
|
return { command: 'set-init', tag: match[1], value: parseInt(match[2]) };
|
|
281
290
|
}
|
|
282
291
|
},
|
|
292
|
+
}, {
|
|
293
|
+
regex: /^\s*([^\s="+-]+)\s*=?"([^"]*)"/,
|
|
294
|
+
map: (match) => {
|
|
295
|
+
return { command: 'set-conditions', tag: match[1], value: match[2] };
|
|
296
|
+
},
|
|
297
|
+
}, {
|
|
298
|
+
regex: /^\s*([^\s="+-]+)\s*\+"([^"]*)"/,
|
|
299
|
+
map: (match) => {
|
|
300
|
+
return { command: 'add-conditions', tag: match[1], value: match[2] };
|
|
301
|
+
},
|
|
302
|
+
}, {
|
|
303
|
+
regex: /^\s*([^\s="+-]+)\s*-"([^"]*)"/,
|
|
304
|
+
map: (match) => {
|
|
305
|
+
return { command: 'rem-conditions', tag: match[1], value: match[2] };
|
|
306
|
+
},
|
|
307
|
+
}, {
|
|
308
|
+
regex: /^\s*([^\s="+-]+)\s*\+\+"([^"]*)"/,
|
|
309
|
+
map: (match) => {
|
|
310
|
+
return { command: 'inc-conditions', tag: match[1], value: match[2] };
|
|
311
|
+
},
|
|
312
|
+
}, {
|
|
313
|
+
regex: /^\s*([^\s="+-]+)\s*--"([^"]*)"/,
|
|
314
|
+
map: (match) => {
|
|
315
|
+
return { command: 'dec-conditions', tag: match[1], value: match[2] };
|
|
316
|
+
},
|
|
283
317
|
}, {
|
|
284
318
|
regex: /^\s*(\S+)\s+[sS]?\s*=?"([^"]*)"/,
|
|
285
319
|
map: (match) => {
|
|
@@ -409,6 +443,9 @@ program.command('track')
|
|
|
409
443
|
else if (action.command === 'delete') {
|
|
410
444
|
tracker = tracker.filter((c) => !(c.id === action.tag || c.alias === action.tag || c.name == action.tag)).map((p) => (Object.assign(Object.assign({}, p), { children: p.children.filter((c) => !(c.id === action.tag || c.alias === action.tag || c.name == action.tag)) })));
|
|
411
445
|
}
|
|
446
|
+
else if (action.command === 'purge') {
|
|
447
|
+
tracker = tracker.filter((c) => !c.foe);
|
|
448
|
+
}
|
|
412
449
|
else if (action.command === 'exit') {
|
|
413
450
|
process.exit(0);
|
|
414
451
|
}
|
|
@@ -443,6 +480,11 @@ program.command('track')
|
|
|
443
480
|
item.init = Math.max(0, action.value);
|
|
444
481
|
}
|
|
445
482
|
}
|
|
483
|
+
else if (action.command === 'blank') {
|
|
484
|
+
tracker.forEach((item) => {
|
|
485
|
+
item.conditions = "";
|
|
486
|
+
});
|
|
487
|
+
}
|
|
446
488
|
else if (action.command === 'set-conditions') {
|
|
447
489
|
const item = (_e = tracker.find((c) => c.id === action.tag || c.alias === action.tag || c.name == action.tag)) !== null && _e !== void 0 ? _e : (tracker.flatMap((c) => c.children).find((c) => c.id === action.tag || c.alias === action.tag || c.name == action.tag));
|
|
448
490
|
if (item) {
|
|
@@ -526,6 +568,9 @@ program.command('track')
|
|
|
526
568
|
item.init = Math.max(0, item.init + action.value);
|
|
527
569
|
}
|
|
528
570
|
}
|
|
571
|
+
else if (action.command === 'foe') {
|
|
572
|
+
tracker.push(app_1.charSchema.parse({ foe: true, name: action.name, alias: action.alias, maxhp: action.hp, hp: action.hp }));
|
|
573
|
+
}
|
|
529
574
|
}
|
|
530
575
|
yield promises_1.default.writeFile(argument, JSON.stringify(tracker, undefined, 2), { encoding: 'utf-8' });
|
|
531
576
|
}
|
package/package.json
CHANGED
package/src/app.ts
CHANGED
|
@@ -46,6 +46,8 @@ const schema = zod.object({
|
|
|
46
46
|
stealth: zod.coerce.number().optional(),
|
|
47
47
|
survival: zod.coerce.number().optional(),
|
|
48
48
|
thievery: zod.coerce.number().optional(),
|
|
49
|
+
piloting: zod.coerce.number().optional(),
|
|
50
|
+
computers: zod.coerce.number().optional(),
|
|
49
51
|
}).default({}),
|
|
50
52
|
lores: zod.record(zod.string(), zod.object({
|
|
51
53
|
mod: zod.coerce.number().default(0),
|
|
@@ -104,6 +106,8 @@ const schema = zod.object({
|
|
|
104
106
|
stealth: zod.array(zod.string()).optional(),
|
|
105
107
|
survival: zod.array(zod.string()).optional(),
|
|
106
108
|
thievery: zod.array(zod.string()).optional(),
|
|
109
|
+
piloting: zod.array(zod.string()).optional(),
|
|
110
|
+
computers: zod.array(zod.string()).optional(),
|
|
107
111
|
}).default({}),
|
|
108
112
|
})
|
|
109
113
|
|
|
@@ -148,6 +152,8 @@ export const stub: Required<Schema> = {
|
|
|
148
152
|
stealth: 0,
|
|
149
153
|
survival: 0,
|
|
150
154
|
thievery: 0,
|
|
155
|
+
piloting: 0,
|
|
156
|
+
computers: 0,
|
|
151
157
|
},
|
|
152
158
|
lores: {},
|
|
153
159
|
melee: {
|
|
@@ -182,7 +188,7 @@ const childSchema = zod.object({
|
|
|
182
188
|
|
|
183
189
|
export type ChildSchema = zod.infer<typeof childSchema>;
|
|
184
190
|
|
|
185
|
-
const charSchema = zod.object({
|
|
191
|
+
export const charSchema = zod.object({
|
|
186
192
|
init: zod.coerce.number().default(0),
|
|
187
193
|
foe: zod.boolean().default(false),
|
|
188
194
|
state: zod.union([zod.literal('empty'), zod.literal('arrow'), zod.literal('check'), zod.literal('cross')]).default('empty'),
|
|
@@ -330,19 +336,20 @@ const locateStrikes = (statblock: string, alias: string): Record<string, Schema[
|
|
|
330
336
|
.replace(/\s+/g, ' ')
|
|
331
337
|
.replace(bps, (m) => m.toUpperCase())
|
|
332
338
|
.replace(/1d/, 'd')
|
|
333
|
-
.replace(/jousting\s+d\d
|
|
339
|
+
.replace(/jousting\s+d(\d+)/g, 'jousting-$1')
|
|
340
|
+
.replace(/boost\s+d(\d+)/g, 'boost-$1')
|
|
334
341
|
.trim();
|
|
335
342
|
|
|
336
343
|
const _dice = dice
|
|
337
344
|
.replace(/\s+/g, ' ')
|
|
338
345
|
.replace(bps, (m) => ({ b: 'bludgeoning', p: 'piercing', s: 'slashing' }[m.toLowerCase()] ?? m))
|
|
339
|
-
.replace(/Fire
|
|
340
|
-
.replace(/Cold
|
|
341
|
-
.replace(/Electricity
|
|
342
|
-
.replace(/Sonic
|
|
343
|
-
.replace(/Spirit
|
|
344
|
-
.replace(/Acid
|
|
345
|
-
.replace(/[pP]lus\s(\d+d)
|
|
346
|
+
.replace(/Fire/g, 'fire')
|
|
347
|
+
.replace(/Cold/g, 'cold')
|
|
348
|
+
.replace(/Electricity/g, 'electricity')
|
|
349
|
+
.replace(/Sonic/g, 'sonic')
|
|
350
|
+
.replace(/Spirit/g, 'spirit')
|
|
351
|
+
.replace(/Acid/g, 'acid')
|
|
352
|
+
.replace(/[pP]lus\s(\d+d)/g, '+$1')
|
|
346
353
|
.trim();
|
|
347
354
|
|
|
348
355
|
const twoHand = _traits.match(/(two-hand|two-handed)\s+(d\d+)/);
|
|
@@ -450,6 +457,8 @@ export const parseStatblock = (name: string | null, _statblock: string, alias: s
|
|
|
450
457
|
...locateInt('stealth', statblock, 'Skills'),
|
|
451
458
|
...locateInt('survival', statblock, 'Skills'),
|
|
452
459
|
...locateInt('thievery', statblock, 'Skills'),
|
|
460
|
+
...locateInt('piloting', statblock, 'Skills'),
|
|
461
|
+
...locateInt('computers', statblock, 'Skills'),
|
|
453
462
|
},
|
|
454
463
|
lores: {
|
|
455
464
|
...locateInts(statblock, 'Skills', 'Lore'),
|
|
@@ -513,6 +522,8 @@ export const flatten = (stats: Schema, secretDC: boolean = false, defaultSkills:
|
|
|
513
522
|
stealth: untrained + stats.attributes.dexterity,
|
|
514
523
|
survival: untrained + stats.attributes.wisdom,
|
|
515
524
|
thievery: untrained + stats.attributes.dexterity,
|
|
525
|
+
piloting: untrained + stats.attributes.dexterity,
|
|
526
|
+
computers: untrained + stats.attributes.intelligence,
|
|
516
527
|
...stats.skills,
|
|
517
528
|
} : stats.skills;
|
|
518
529
|
|
|
@@ -607,7 +618,7 @@ export const flatten = (stats: Schema, secretDC: boolean = false, defaultSkills:
|
|
|
607
618
|
] : []),
|
|
608
619
|
...entries(saveInfo).filter(([, v]) => v.length > 0).map(([k, v]) => [`${k}.info`, `\`(${v.join(', ')})\``]),
|
|
609
620
|
...entries(skillInfo).filter(([, v]) => v.length > 0).map(([k, v]) => [`${k}.info`, `\`(${v.join(', ')})\``]),
|
|
610
|
-
['out', secretDC ? 'xs' : '
|
|
621
|
+
['out', secretDC ? 'xs' : 'l'],
|
|
611
622
|
].reduce<Record<string | number, string | number>>((p, [key, value]) => { p[key] = value; return p }, {});
|
|
612
623
|
}
|
|
613
624
|
|
package/src/index.ts
CHANGED
|
@@ -8,7 +8,7 @@ import clipboardy from 'clipboardy';
|
|
|
8
8
|
|
|
9
9
|
import pack from '../package.json';
|
|
10
10
|
|
|
11
|
-
import { sortFolder, formatCommand, formatJSON, formatTSV, fromatMap, parseJSON, parseStatblock, stub, flatMap, formatTable, formatHP, newtracker, parseTracker, formatTracker, screenPlay, diceMap } from './app';
|
|
11
|
+
import { sortFolder, formatCommand, formatJSON, formatTSV, fromatMap, parseJSON, parseStatblock, stub, flatMap, formatTable, formatHP, newtracker, parseTracker, formatTracker, screenPlay, diceMap, charSchema } from './app';
|
|
12
12
|
|
|
13
13
|
const program = new Command(pack.name);
|
|
14
14
|
|
|
@@ -240,6 +240,15 @@ program.command('track')
|
|
|
240
240
|
}, {
|
|
241
241
|
regex: /^\s*reset/i,
|
|
242
242
|
map: () => ({ command: 'reset' as const })
|
|
243
|
+
}, {
|
|
244
|
+
regex: /^\s*purge/i,
|
|
245
|
+
map: () => ({ command: 'purge' as const })
|
|
246
|
+
}, {
|
|
247
|
+
regex: /^\s*blank/i,
|
|
248
|
+
map: () => ({ command: 'blank' as const })
|
|
249
|
+
}, {
|
|
250
|
+
regex: /^\s*foe(\s+(\S+))?(\s+(\S+))?(\s+(\d+))?/i,
|
|
251
|
+
map: (match: RegExpMatchArray) => ({ command: 'foe' as const, name: match[2], alias: match[4], hp: match[6] && parseInt(match[6], 10) })
|
|
243
252
|
}, {
|
|
244
253
|
regex: /^\s*heal/i,
|
|
245
254
|
map: () => ({ command: 'heal' as const })
|
|
@@ -273,6 +282,31 @@ program.command('track')
|
|
|
273
282
|
return { command: 'set-init' as const, tag: match[1], value: parseInt(match[2]) };
|
|
274
283
|
}
|
|
275
284
|
},
|
|
285
|
+
}, {
|
|
286
|
+
regex: /^\s*([^\s="+-]+)\s*=?"([^"]*)"/,
|
|
287
|
+
map: (match: RegExpMatchArray) => {
|
|
288
|
+
return { command: 'set-conditions' as const, tag: match[1], value: match[2] };
|
|
289
|
+
},
|
|
290
|
+
}, {
|
|
291
|
+
regex: /^\s*([^\s="+-]+)\s*\+"([^"]*)"/,
|
|
292
|
+
map: (match: RegExpMatchArray) => {
|
|
293
|
+
return { command: 'add-conditions' as const, tag: match[1], value: match[2] };
|
|
294
|
+
},
|
|
295
|
+
}, {
|
|
296
|
+
regex: /^\s*([^\s="+-]+)\s*-"([^"]*)"/,
|
|
297
|
+
map: (match: RegExpMatchArray) => {
|
|
298
|
+
return { command: 'rem-conditions' as const, tag: match[1], value: match[2] };
|
|
299
|
+
},
|
|
300
|
+
}, {
|
|
301
|
+
regex: /^\s*([^\s="+-]+)\s*\+\+"([^"]*)"/,
|
|
302
|
+
map: (match: RegExpMatchArray) => {
|
|
303
|
+
return { command: 'inc-conditions' as const, tag: match[1], value: match[2] };
|
|
304
|
+
},
|
|
305
|
+
}, {
|
|
306
|
+
regex: /^\s*([^\s="+-]+)\s*--"([^"]*)"/,
|
|
307
|
+
map: (match: RegExpMatchArray) => {
|
|
308
|
+
return { command: 'dec-conditions' as const, tag: match[1], value: match[2] };
|
|
309
|
+
},
|
|
276
310
|
}, {
|
|
277
311
|
regex: /^\s*(\S+)\s+[sS]?\s*=?"([^"]*)"/,
|
|
278
312
|
map: (match: RegExpMatchArray) => {
|
|
@@ -416,6 +450,8 @@ program.command('track')
|
|
|
416
450
|
...p,
|
|
417
451
|
children: p.children.filter((c) => !(c.id === action.tag || c.alias === action.tag || c.name == action.tag)),
|
|
418
452
|
}))
|
|
453
|
+
} else if (action.command === 'purge') {
|
|
454
|
+
tracker = tracker.filter((c) => !c.foe)
|
|
419
455
|
} else if (action.command === 'exit') {
|
|
420
456
|
process.exit(0)
|
|
421
457
|
} else if (action.command === 'heal') {
|
|
@@ -452,6 +488,10 @@ program.command('track')
|
|
|
452
488
|
if (item) {
|
|
453
489
|
item.init = Math.max(0, action.value)
|
|
454
490
|
}
|
|
491
|
+
} else if (action.command === 'blank') {
|
|
492
|
+
tracker.forEach((item) => {
|
|
493
|
+
item.conditions = ""
|
|
494
|
+
})
|
|
455
495
|
} else if (action.command === 'set-conditions') {
|
|
456
496
|
const item = tracker.find((c) => c.id === action.tag || c.alias === action.tag || c.name == action.tag) ?? (
|
|
457
497
|
tracker.flatMap((c) => c.children).find((c) => c.id === action.tag || c.alias === action.tag || c.name == action.tag)
|
|
@@ -557,6 +597,8 @@ program.command('track')
|
|
|
557
597
|
if (item) {
|
|
558
598
|
item.init = Math.max(0, item.init + action.value)
|
|
559
599
|
}
|
|
600
|
+
} else if (action.command === 'foe') {
|
|
601
|
+
tracker.push(charSchema.parse({ foe: true, name: action.name, alias: action.alias, maxhp: action.hp, hp: action.hp }))
|
|
560
602
|
}
|
|
561
603
|
}
|
|
562
604
|
|