pf2e-sage-stats 0.1.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -9,6 +9,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  step((generator = generator.apply(thisArg, _arguments || [])).next());
10
10
  });
11
11
  };
12
+ var __asyncValues = (this && this.__asyncValues) || function (o) {
13
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
14
+ var m = o[Symbol.asyncIterator], i;
15
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
16
+ function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
17
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
18
+ };
12
19
  var __importDefault = (this && this.__importDefault) || function (mod) {
13
20
  return (mod && mod.__esModule) ? mod : { "default": mod };
14
21
  };
@@ -16,6 +23,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
16
23
  const commander_1 = require("commander");
17
24
  const promises_1 = __importDefault(require("fs/promises"));
18
25
  const path_1 = __importDefault(require("path"));
26
+ const readline_1 = __importDefault(require("readline"));
19
27
  const package_json_1 = __importDefault(require("../package.json"));
20
28
  const app_1 = require("./app");
21
29
  const program = new commander_1.Command(package_json_1.default.name);
@@ -46,10 +54,10 @@ program.command('table')
46
54
  .action((argument, option) => __awaiter(void 0, void 0, void 0, function* () {
47
55
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
48
56
  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' });
57
+ 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
58
  }
51
59
  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>'));
60
+ 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
61
  }
54
62
  }));
55
63
  program.command('hp')
@@ -58,71 +66,22 @@ program.command('hp')
58
66
  .action((argument) => __awaiter(void 0, void 0, void 0, function* () {
59
67
  console.log((0, app_1.formatHP)(argument));
60
68
  }));
69
+ program.command('sort')
70
+ .description('Sorts log file folder and renames files')
71
+ .action(() => __awaiter(void 0, void 0, void 0, function* () {
72
+ console.log(yield (0, app_1.sortFolder)());
73
+ }));
61
74
  program.command('flat')
62
75
  .description('Generte a special flat npc tsv')
63
76
  .option('-n, --name <string>', 'npc name')
64
77
  .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
78
  .action((option) => __awaiter(void 0, void 0, void 0, function* () {
120
79
  var _a, _b;
121
80
  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' });
81
+ 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
82
  }
124
83
  else {
125
- console.log((0, app_1.fromatMap)((_b = option.name) !== null && _b !== void 0 ? _b : 'dice', (0, app_1.valueMap)()));
84
+ console.log((0, app_1.fromatMap)((_b = option.name) !== null && _b !== void 0 ? _b : 'flat', app_1.prediceateMap));
126
85
  }
127
86
  }));
128
87
  program.command('adjustment')
@@ -148,7 +107,6 @@ program.command('statblock')
148
107
  .option('-c, --command', 'output directly to txt')
149
108
  .option('-s, --secretDC', 'produce secret DCs (tsv only)')
150
109
  .option('-d, --defaultSkills', 'produce values for untrained skills (tsv only)')
151
- .option('-e, --desc', 'produce verbose desc fields (tsv only)')
152
110
  .option('-o, --output <file>', 'output file name')
153
111
  .action((argument, option) => __awaiter(void 0, void 0, void 0, function* () {
154
112
  var _a, _b;
@@ -157,11 +115,11 @@ program.command('statblock')
157
115
  const stats = (0, app_1.parseStatblock)((_b = option.name) !== null && _b !== void 0 ? _b : null, file, alias);
158
116
  if (option.tsv) {
159
117
  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' });
118
+ yield promises_1.default.writeFile(output, (0, app_1.formatTSV)(stats, option.secretDC, option.defaultSkills), { encoding: 'utf-8' });
161
119
  }
162
120
  else if (option.command) {
163
121
  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' });
122
+ yield promises_1.default.writeFile(output, (0, app_1.formatCommand)(stats, option.secretDC, option.defaultSkills), { encoding: 'utf-8' });
165
123
  }
166
124
  else {
167
125
  const output = option.output ? option.output : path_1.default.join(path_1.default.parse(argument).dir, stats.alias + '.json');
@@ -175,12 +133,11 @@ program.command('tsv')
175
133
  .option('-s, --secretDC', 'produce secret DCs')
176
134
  .option('-r, --recallDC', 'produce recall DCs')
177
135
  .option('-d, --defaultSkills', 'produce values for untrained skills')
178
- .option('-e, --desc', 'produce verbose desc fields')
179
136
  .action((argument, option) => __awaiter(void 0, void 0, void 0, function* () {
180
137
  const file = yield promises_1.default.readFile(argument, { encoding: 'utf-8' });
181
138
  const stats = (0, app_1.parseJSON)(file);
182
139
  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' });
140
+ yield promises_1.default.writeFile(output, (0, app_1.formatTSV)(stats, option.secretDC, option.defaultSkills, option.recallDC), { encoding: 'utf-8' });
184
141
  }));
185
142
  program.command('command')
186
143
  .description('Generte a creation command file from JSON')
@@ -189,11 +146,97 @@ program.command('command')
189
146
  .option('-s, --secretDC', 'produce secret DCs')
190
147
  .option('-r, --recallDC', 'produce recall DCs')
191
148
  .option('-d, --defaultSkills', 'produce values for untrained skills')
192
- .option('-e, --desc', 'produce verbose desc fields')
193
149
  .action((argument, option) => __awaiter(void 0, void 0, void 0, function* () {
194
150
  const file = yield promises_1.default.readFile(argument, { encoding: 'utf-8' });
195
151
  const stats = (0, app_1.parseJSON)(file);
196
152
  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' });
153
+ yield promises_1.default.writeFile(output, (0, app_1.formatCommand)(stats, option.secretDC, option.defaultSkills, option.recallDC), { encoding: 'utf-8' });
154
+ }));
155
+ program.command('newtracker')
156
+ .argument('<file>', 'input text file')
157
+ .option('-o, --output <file>', 'output file name')
158
+ .action((argument, option) => __awaiter(void 0, void 0, void 0, function* () {
159
+ const file = yield promises_1.default.readFile(argument, { encoding: 'utf-8' });
160
+ const tracker = (0, app_1.newtracker)(file);
161
+ if (option.output) {
162
+ yield promises_1.default.writeFile(option.output, JSON.stringify(tracker, undefined, 2), { encoding: 'utf-8' });
163
+ }
164
+ else {
165
+ console.log(JSON.stringify(tracker, undefined, 2));
166
+ }
167
+ }));
168
+ program.command('tracker')
169
+ .argument('<file>', 'input text file')
170
+ .option('-o, --output <file>', 'output file name')
171
+ .action((argument, option) => __awaiter(void 0, void 0, void 0, function* () {
172
+ const file = yield promises_1.default.readFile(argument, { encoding: 'utf-8' });
173
+ const tracker = (0, app_1.parseTracker)(file);
174
+ if (option.output) {
175
+ yield promises_1.default.writeFile(option.output, (0, app_1.formatTracker)(tracker), { encoding: 'utf-8' });
176
+ }
177
+ else {
178
+ console.log((0, app_1.formatTracker)(tracker));
179
+ }
180
+ }));
181
+ program.command('track')
182
+ .argument('<file>', 'input text file')
183
+ .option('-o, --output <file>', 'output file name')
184
+ .action((argument, option) => __awaiter(void 0, void 0, void 0, function* () {
185
+ const iterator = promises_1.default.watch(argument);
186
+ const invoke = (filename) => __awaiter(void 0, void 0, void 0, function* () {
187
+ const file = yield promises_1.default.readFile(filename, { encoding: 'utf-8' });
188
+ const tracker = (0, app_1.parseTracker)(file);
189
+ if (option.output) {
190
+ yield promises_1.default.writeFile(option.output, (0, app_1.formatTracker)(tracker), { encoding: 'utf-8' });
191
+ }
192
+ else {
193
+ console.clear();
194
+ console.log((0, app_1.formatTracker)(tracker));
195
+ }
196
+ });
197
+ yield invoke(argument);
198
+ yield Promise.all([
199
+ (() => __awaiter(void 0, void 0, void 0, function* () {
200
+ var _a, e_1, _b, _c;
201
+ var _d;
202
+ try {
203
+ for (var _e = true, iterator_1 = __asyncValues(iterator), iterator_1_1; iterator_1_1 = yield iterator_1.next(), _a = iterator_1_1.done, !_a; _e = true) {
204
+ _c = iterator_1_1.value;
205
+ _e = false;
206
+ const value = _c;
207
+ yield invoke((_d = value.filename) !== null && _d !== void 0 ? _d : argument);
208
+ }
209
+ }
210
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
211
+ finally {
212
+ try {
213
+ if (!_e && !_a && (_b = iterator_1.return)) yield _b.call(iterator_1);
214
+ }
215
+ finally { if (e_1) throw e_1.error; }
216
+ }
217
+ }))(),
218
+ (() => __awaiter(void 0, void 0, void 0, function* () {
219
+ const rl = readline_1.default.createInterface({
220
+ input: process.stdin,
221
+ output: process.stdout
222
+ });
223
+ while (true) {
224
+ yield new Promise((resolve) => setTimeout(resolve, 500));
225
+ const input = yield new Promise((resolve) => (rl.question('>', resolve)));
226
+ const comm = input.match(/(\S+)\s*([+-]\d+)/);
227
+ if (!comm) {
228
+ continue;
229
+ }
230
+ const file = yield promises_1.default.readFile(argument, { encoding: 'utf-8' });
231
+ const tracker = (0, app_1.parseTracker)(file);
232
+ const index = tracker.findIndex((c) => c.alias === comm[1]);
233
+ if (index < 0) {
234
+ continue;
235
+ }
236
+ tracker[index].hp += parseInt(comm[2]);
237
+ yield promises_1.default.writeFile(argument, JSON.stringify(tracker, undefined, 2), { encoding: 'utf-8' });
238
+ }
239
+ }))(),
240
+ ]);
198
241
  }));
199
242
  program.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pf2e-sage-stats",
3
- "version": "0.1.1",
3
+ "version": "0.2.2",
4
4
  "description": "An RPG Sage's .tsv stat generation tool",
5
5
  "main": "dist/index.js",
6
6
  "author": "ikariott@gmail.com",