@swrpg-online/dice 0.9.0 → 1.0.4
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 +103 -8
- package/dist/cli.d.ts +4 -0
- package/dist/cli.js +130 -0
- package/dist/dice.d.ts +1 -1
- package/dist/dice.js +289 -51
- package/dist/index.d.ts +3 -3
- package/dist/pools.d.ts +1 -1
- package/dist/pools.js +4 -4
- package/dist/types.d.ts +1 -1
- package/package.json +24 -3
- package/.github/workflows/publish.yml +0 -31
- package/.husky/.skip-tests +0 -0
- package/.husky/pre-commit +0 -32
- package/.replit +0 -8
- package/coverage/clover.xml +0 -113
- package/coverage/coverage-final.json +0 -4
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/dice.ts.html +0 -817
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -146
- package/coverage/lcov-report/index.ts.html +0 -109
- package/coverage/lcov-report/pools.ts.html +0 -253
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov.info +0 -246
- package/jest.config.js +0 -8
- package/src/dice.ts +0 -244
- package/src/index.ts +0 -8
- package/src/pools.ts +0 -56
- package/src/types.ts +0 -30
- package/tests/dice.test.ts +0 -351
- package/tests/pools.test.ts +0 -86
- package/tsconfig.json +0 -14
package/dist/dice.js
CHANGED
|
@@ -5,109 +5,347 @@ const rollDie = (sides) => Math.floor(Math.random() * sides) + 1;
|
|
|
5
5
|
const boostDieResult = (roll) => {
|
|
6
6
|
switch (roll) {
|
|
7
7
|
case 3:
|
|
8
|
-
return {
|
|
8
|
+
return {
|
|
9
|
+
successes: 1,
|
|
10
|
+
failures: 0,
|
|
11
|
+
advantages: 0,
|
|
12
|
+
threats: 0,
|
|
13
|
+
triumphs: 0,
|
|
14
|
+
despair: 0,
|
|
15
|
+
};
|
|
9
16
|
case 4:
|
|
10
|
-
return {
|
|
17
|
+
return {
|
|
18
|
+
successes: 1,
|
|
19
|
+
failures: 0,
|
|
20
|
+
advantages: 1,
|
|
21
|
+
threats: 0,
|
|
22
|
+
triumphs: 0,
|
|
23
|
+
despair: 0,
|
|
24
|
+
};
|
|
11
25
|
case 5:
|
|
12
|
-
return {
|
|
26
|
+
return {
|
|
27
|
+
successes: 0,
|
|
28
|
+
failures: 0,
|
|
29
|
+
advantages: 2,
|
|
30
|
+
threats: 0,
|
|
31
|
+
triumphs: 0,
|
|
32
|
+
despair: 0,
|
|
33
|
+
};
|
|
13
34
|
case 6:
|
|
14
|
-
return {
|
|
35
|
+
return {
|
|
36
|
+
successes: 0,
|
|
37
|
+
failures: 0,
|
|
38
|
+
advantages: 1,
|
|
39
|
+
threats: 0,
|
|
40
|
+
triumphs: 0,
|
|
41
|
+
despair: 0,
|
|
42
|
+
};
|
|
15
43
|
default:
|
|
16
|
-
return {
|
|
44
|
+
return {
|
|
45
|
+
successes: 0,
|
|
46
|
+
failures: 0,
|
|
47
|
+
advantages: 0,
|
|
48
|
+
threats: 0,
|
|
49
|
+
triumphs: 0,
|
|
50
|
+
despair: 0,
|
|
51
|
+
};
|
|
17
52
|
}
|
|
18
53
|
};
|
|
19
54
|
const setBackDieResult = (roll) => {
|
|
20
55
|
switch (roll) {
|
|
21
56
|
case 3:
|
|
22
57
|
case 4:
|
|
23
|
-
return {
|
|
58
|
+
return {
|
|
59
|
+
successes: 0,
|
|
60
|
+
failures: 1,
|
|
61
|
+
advantages: 0,
|
|
62
|
+
threats: 0,
|
|
63
|
+
triumphs: 0,
|
|
64
|
+
despair: 0,
|
|
65
|
+
};
|
|
24
66
|
case 5:
|
|
25
67
|
case 6:
|
|
26
|
-
return {
|
|
68
|
+
return {
|
|
69
|
+
successes: 0,
|
|
70
|
+
failures: 0,
|
|
71
|
+
advantages: 0,
|
|
72
|
+
threats: 1,
|
|
73
|
+
triumphs: 0,
|
|
74
|
+
despair: 0,
|
|
75
|
+
};
|
|
27
76
|
default:
|
|
28
|
-
return {
|
|
77
|
+
return {
|
|
78
|
+
successes: 0,
|
|
79
|
+
failures: 0,
|
|
80
|
+
advantages: 0,
|
|
81
|
+
threats: 0,
|
|
82
|
+
triumphs: 0,
|
|
83
|
+
despair: 0,
|
|
84
|
+
};
|
|
29
85
|
}
|
|
30
86
|
};
|
|
31
87
|
const abilityDieResult = (roll) => {
|
|
32
88
|
switch (roll) {
|
|
33
89
|
case 2:
|
|
34
90
|
case 3:
|
|
35
|
-
return {
|
|
91
|
+
return {
|
|
92
|
+
successes: 1,
|
|
93
|
+
failures: 0,
|
|
94
|
+
advantages: 0,
|
|
95
|
+
threats: 0,
|
|
96
|
+
triumphs: 0,
|
|
97
|
+
despair: 0,
|
|
98
|
+
};
|
|
36
99
|
case 4:
|
|
37
|
-
return {
|
|
100
|
+
return {
|
|
101
|
+
successes: 2,
|
|
102
|
+
failures: 0,
|
|
103
|
+
advantages: 0,
|
|
104
|
+
threats: 0,
|
|
105
|
+
triumphs: 0,
|
|
106
|
+
despair: 0,
|
|
107
|
+
};
|
|
38
108
|
case 5:
|
|
39
109
|
case 6:
|
|
40
|
-
return {
|
|
110
|
+
return {
|
|
111
|
+
successes: 0,
|
|
112
|
+
failures: 0,
|
|
113
|
+
advantages: 1,
|
|
114
|
+
threats: 0,
|
|
115
|
+
triumphs: 0,
|
|
116
|
+
despair: 0,
|
|
117
|
+
};
|
|
41
118
|
case 7:
|
|
42
|
-
return {
|
|
119
|
+
return {
|
|
120
|
+
successes: 1,
|
|
121
|
+
failures: 0,
|
|
122
|
+
advantages: 1,
|
|
123
|
+
threats: 0,
|
|
124
|
+
triumphs: 0,
|
|
125
|
+
despair: 0,
|
|
126
|
+
};
|
|
43
127
|
case 8:
|
|
44
|
-
return {
|
|
128
|
+
return {
|
|
129
|
+
successes: 0,
|
|
130
|
+
failures: 0,
|
|
131
|
+
advantages: 2,
|
|
132
|
+
threats: 0,
|
|
133
|
+
triumphs: 0,
|
|
134
|
+
despair: 0,
|
|
135
|
+
};
|
|
45
136
|
default:
|
|
46
|
-
return {
|
|
137
|
+
return {
|
|
138
|
+
successes: 0,
|
|
139
|
+
failures: 0,
|
|
140
|
+
advantages: 0,
|
|
141
|
+
threats: 0,
|
|
142
|
+
triumphs: 0,
|
|
143
|
+
despair: 0,
|
|
144
|
+
};
|
|
47
145
|
}
|
|
48
146
|
};
|
|
49
147
|
const difficultyDieResult = (roll) => {
|
|
50
148
|
switch (roll) {
|
|
51
149
|
case 2:
|
|
52
|
-
return {
|
|
150
|
+
return {
|
|
151
|
+
successes: 0,
|
|
152
|
+
failures: 1,
|
|
153
|
+
advantages: 0,
|
|
154
|
+
threats: 0,
|
|
155
|
+
triumphs: 0,
|
|
156
|
+
despair: 0,
|
|
157
|
+
};
|
|
53
158
|
case 3:
|
|
54
|
-
return {
|
|
159
|
+
return {
|
|
160
|
+
successes: 0,
|
|
161
|
+
failures: 2,
|
|
162
|
+
advantages: 0,
|
|
163
|
+
threats: 0,
|
|
164
|
+
triumphs: 0,
|
|
165
|
+
despair: 0,
|
|
166
|
+
};
|
|
55
167
|
case 4:
|
|
56
168
|
case 5:
|
|
57
169
|
case 6:
|
|
58
|
-
return {
|
|
170
|
+
return {
|
|
171
|
+
successes: 0,
|
|
172
|
+
failures: 0,
|
|
173
|
+
advantages: 0,
|
|
174
|
+
threats: 1,
|
|
175
|
+
triumphs: 0,
|
|
176
|
+
despair: 0,
|
|
177
|
+
};
|
|
59
178
|
case 7:
|
|
60
|
-
return {
|
|
179
|
+
return {
|
|
180
|
+
successes: 0,
|
|
181
|
+
failures: 0,
|
|
182
|
+
advantages: 0,
|
|
183
|
+
threats: 2,
|
|
184
|
+
triumphs: 0,
|
|
185
|
+
despair: 0,
|
|
186
|
+
};
|
|
61
187
|
case 8:
|
|
62
|
-
return {
|
|
188
|
+
return {
|
|
189
|
+
successes: 0,
|
|
190
|
+
failures: 1,
|
|
191
|
+
advantages: 0,
|
|
192
|
+
threats: 1,
|
|
193
|
+
triumphs: 0,
|
|
194
|
+
despair: 0,
|
|
195
|
+
};
|
|
63
196
|
default:
|
|
64
|
-
return {
|
|
197
|
+
return {
|
|
198
|
+
successes: 0,
|
|
199
|
+
failures: 0,
|
|
200
|
+
advantages: 0,
|
|
201
|
+
threats: 0,
|
|
202
|
+
triumphs: 0,
|
|
203
|
+
despair: 0,
|
|
204
|
+
};
|
|
65
205
|
}
|
|
66
206
|
};
|
|
67
207
|
const proficiencyDieResult = (roll) => {
|
|
68
208
|
switch (roll) {
|
|
69
209
|
case 2:
|
|
70
210
|
case 3:
|
|
71
|
-
return {
|
|
211
|
+
return {
|
|
212
|
+
successes: 1,
|
|
213
|
+
failures: 0,
|
|
214
|
+
advantages: 0,
|
|
215
|
+
threats: 0,
|
|
216
|
+
triumphs: 0,
|
|
217
|
+
despair: 0,
|
|
218
|
+
};
|
|
72
219
|
case 4:
|
|
73
220
|
case 5:
|
|
74
|
-
return {
|
|
221
|
+
return {
|
|
222
|
+
successes: 2,
|
|
223
|
+
failures: 0,
|
|
224
|
+
advantages: 0,
|
|
225
|
+
threats: 0,
|
|
226
|
+
triumphs: 0,
|
|
227
|
+
despair: 0,
|
|
228
|
+
};
|
|
75
229
|
case 6:
|
|
76
|
-
return {
|
|
230
|
+
return {
|
|
231
|
+
successes: 0,
|
|
232
|
+
failures: 0,
|
|
233
|
+
advantages: 1,
|
|
234
|
+
threats: 0,
|
|
235
|
+
triumphs: 0,
|
|
236
|
+
despair: 0,
|
|
237
|
+
};
|
|
77
238
|
case 7:
|
|
78
239
|
case 8:
|
|
79
240
|
case 9:
|
|
80
|
-
return {
|
|
241
|
+
return {
|
|
242
|
+
successes: 1,
|
|
243
|
+
failures: 0,
|
|
244
|
+
advantages: 1,
|
|
245
|
+
threats: 0,
|
|
246
|
+
triumphs: 0,
|
|
247
|
+
despair: 0,
|
|
248
|
+
};
|
|
81
249
|
case 10:
|
|
82
250
|
case 11:
|
|
83
|
-
return {
|
|
251
|
+
return {
|
|
252
|
+
successes: 0,
|
|
253
|
+
failures: 0,
|
|
254
|
+
advantages: 2,
|
|
255
|
+
threats: 0,
|
|
256
|
+
triumphs: 0,
|
|
257
|
+
despair: 0,
|
|
258
|
+
};
|
|
84
259
|
case 12:
|
|
85
|
-
return {
|
|
260
|
+
return {
|
|
261
|
+
successes: 0,
|
|
262
|
+
failures: 0,
|
|
263
|
+
advantages: 0,
|
|
264
|
+
threats: 0,
|
|
265
|
+
triumphs: 1,
|
|
266
|
+
despair: 0,
|
|
267
|
+
};
|
|
86
268
|
default:
|
|
87
|
-
return {
|
|
269
|
+
return {
|
|
270
|
+
successes: 0,
|
|
271
|
+
failures: 0,
|
|
272
|
+
advantages: 0,
|
|
273
|
+
threats: 0,
|
|
274
|
+
triumphs: 0,
|
|
275
|
+
despair: 0,
|
|
276
|
+
};
|
|
88
277
|
}
|
|
89
278
|
};
|
|
90
279
|
const challengeDieResult = (roll) => {
|
|
91
280
|
switch (roll) {
|
|
92
281
|
case 2:
|
|
93
282
|
case 3:
|
|
94
|
-
return {
|
|
283
|
+
return {
|
|
284
|
+
successes: 0,
|
|
285
|
+
failures: 1,
|
|
286
|
+
advantages: 0,
|
|
287
|
+
threats: 0,
|
|
288
|
+
triumphs: 0,
|
|
289
|
+
despair: 0,
|
|
290
|
+
};
|
|
95
291
|
case 4:
|
|
96
292
|
case 5:
|
|
97
|
-
return {
|
|
293
|
+
return {
|
|
294
|
+
successes: 0,
|
|
295
|
+
failures: 2,
|
|
296
|
+
advantages: 0,
|
|
297
|
+
threats: 0,
|
|
298
|
+
triumphs: 0,
|
|
299
|
+
despair: 0,
|
|
300
|
+
};
|
|
98
301
|
case 6:
|
|
99
302
|
case 7:
|
|
100
|
-
return {
|
|
303
|
+
return {
|
|
304
|
+
successes: 0,
|
|
305
|
+
failures: 0,
|
|
306
|
+
advantages: 0,
|
|
307
|
+
threats: 1,
|
|
308
|
+
triumphs: 0,
|
|
309
|
+
despair: 0,
|
|
310
|
+
};
|
|
101
311
|
case 8:
|
|
102
312
|
case 9:
|
|
103
|
-
return {
|
|
313
|
+
return {
|
|
314
|
+
successes: 0,
|
|
315
|
+
failures: 1,
|
|
316
|
+
advantages: 0,
|
|
317
|
+
threats: 1,
|
|
318
|
+
triumphs: 0,
|
|
319
|
+
despair: 0,
|
|
320
|
+
};
|
|
104
321
|
case 10:
|
|
105
322
|
case 11:
|
|
106
|
-
return {
|
|
323
|
+
return {
|
|
324
|
+
successes: 0,
|
|
325
|
+
failures: 0,
|
|
326
|
+
advantages: 0,
|
|
327
|
+
threats: 2,
|
|
328
|
+
triumphs: 0,
|
|
329
|
+
despair: 0,
|
|
330
|
+
};
|
|
107
331
|
case 12:
|
|
108
|
-
return {
|
|
332
|
+
return {
|
|
333
|
+
successes: 0,
|
|
334
|
+
failures: 0,
|
|
335
|
+
advantages: 0,
|
|
336
|
+
threats: 0,
|
|
337
|
+
triumphs: 0,
|
|
338
|
+
despair: 1,
|
|
339
|
+
};
|
|
109
340
|
default:
|
|
110
|
-
return {
|
|
341
|
+
return {
|
|
342
|
+
successes: 0,
|
|
343
|
+
failures: 0,
|
|
344
|
+
advantages: 0,
|
|
345
|
+
threats: 0,
|
|
346
|
+
triumphs: 0,
|
|
347
|
+
despair: 0,
|
|
348
|
+
};
|
|
111
349
|
}
|
|
112
350
|
};
|
|
113
351
|
const sumResults = (results) => {
|
|
@@ -117,14 +355,14 @@ const sumResults = (results) => {
|
|
|
117
355
|
advantages: acc.advantages + curr.advantages,
|
|
118
356
|
threats: acc.threats + curr.threats,
|
|
119
357
|
triumphs: acc.triumphs + curr.triumphs,
|
|
120
|
-
despair: acc.despair + curr.despair
|
|
358
|
+
despair: acc.despair + curr.despair,
|
|
121
359
|
}), {
|
|
122
360
|
successes: 0,
|
|
123
361
|
failures: 0,
|
|
124
362
|
advantages: 0,
|
|
125
363
|
threats: 0,
|
|
126
364
|
triumphs: 0,
|
|
127
|
-
despair: 0
|
|
365
|
+
despair: 0,
|
|
128
366
|
});
|
|
129
367
|
// Calculate net successes/failures
|
|
130
368
|
let netSuccesses = 0;
|
|
@@ -145,7 +383,7 @@ const sumResults = (results) => {
|
|
|
145
383
|
advantages: sums.advantages,
|
|
146
384
|
threats: sums.threats,
|
|
147
385
|
triumphs: sums.triumphs,
|
|
148
|
-
despair: sums.despair
|
|
386
|
+
despair: sums.despair,
|
|
149
387
|
};
|
|
150
388
|
};
|
|
151
389
|
const roll = (pool) => {
|
|
@@ -164,66 +402,66 @@ const roll = (pool) => {
|
|
|
164
402
|
proficiencyDice: Math.max(0, proficiencyCount),
|
|
165
403
|
setBackDice: Math.max(0, setBackCount),
|
|
166
404
|
difficultyDice: Math.max(0, difficultyCount),
|
|
167
|
-
challengeDice: Math.max(0, challengeCount)
|
|
405
|
+
challengeDice: Math.max(0, challengeCount),
|
|
168
406
|
};
|
|
169
407
|
const detailedResults = [];
|
|
170
408
|
// Roll boost dice
|
|
171
409
|
for (let i = 0; i < sanitizedPool.boostDice; i++) {
|
|
172
410
|
const roll = rollDie(6);
|
|
173
411
|
detailedResults.push({
|
|
174
|
-
type:
|
|
412
|
+
type: "boost",
|
|
175
413
|
roll,
|
|
176
|
-
result: boostDieResult(roll)
|
|
414
|
+
result: boostDieResult(roll),
|
|
177
415
|
});
|
|
178
416
|
}
|
|
179
417
|
// Roll ability dice
|
|
180
418
|
for (let i = 0; i < sanitizedPool.abilityDice; i++) {
|
|
181
419
|
const roll = rollDie(8);
|
|
182
420
|
detailedResults.push({
|
|
183
|
-
type:
|
|
421
|
+
type: "ability",
|
|
184
422
|
roll,
|
|
185
|
-
result: abilityDieResult(roll)
|
|
423
|
+
result: abilityDieResult(roll),
|
|
186
424
|
});
|
|
187
425
|
}
|
|
188
426
|
// Roll proficiency dice
|
|
189
427
|
for (let i = 0; i < sanitizedPool.proficiencyDice; i++) {
|
|
190
428
|
const roll = rollDie(12);
|
|
191
429
|
detailedResults.push({
|
|
192
|
-
type:
|
|
430
|
+
type: "proficiency",
|
|
193
431
|
roll,
|
|
194
|
-
result: proficiencyDieResult(roll)
|
|
432
|
+
result: proficiencyDieResult(roll),
|
|
195
433
|
});
|
|
196
434
|
}
|
|
197
435
|
// Roll setback dice
|
|
198
436
|
for (let i = 0; i < sanitizedPool.setBackDice; i++) {
|
|
199
437
|
const roll = rollDie(6);
|
|
200
438
|
detailedResults.push({
|
|
201
|
-
type:
|
|
439
|
+
type: "setback",
|
|
202
440
|
roll,
|
|
203
|
-
result: setBackDieResult(roll)
|
|
441
|
+
result: setBackDieResult(roll),
|
|
204
442
|
});
|
|
205
443
|
}
|
|
206
444
|
// Roll difficulty dice
|
|
207
445
|
for (let i = 0; i < sanitizedPool.difficultyDice; i++) {
|
|
208
446
|
const roll = rollDie(8);
|
|
209
447
|
detailedResults.push({
|
|
210
|
-
type:
|
|
448
|
+
type: "difficulty",
|
|
211
449
|
roll,
|
|
212
|
-
result: difficultyDieResult(roll)
|
|
450
|
+
result: difficultyDieResult(roll),
|
|
213
451
|
});
|
|
214
452
|
}
|
|
215
453
|
// Roll challenge dice
|
|
216
454
|
for (let i = 0; i < sanitizedPool.challengeDice; i++) {
|
|
217
455
|
const roll = rollDie(12);
|
|
218
456
|
detailedResults.push({
|
|
219
|
-
type:
|
|
457
|
+
type: "challenge",
|
|
220
458
|
roll,
|
|
221
|
-
result: challengeDieResult(roll)
|
|
459
|
+
result: challengeDieResult(roll),
|
|
222
460
|
});
|
|
223
461
|
}
|
|
224
462
|
return {
|
|
225
463
|
results: detailedResults,
|
|
226
|
-
summary: sumResults(detailedResults.map(r => r.result))
|
|
464
|
+
summary: sumResults(detailedResults.map((r) => r.result)),
|
|
227
465
|
};
|
|
228
466
|
};
|
|
229
467
|
exports.roll = roll;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { roll } from
|
|
2
|
-
export type { DicePool, RollResult } from
|
|
3
|
-
export { createSkillCheck, createCombatCheck, createOpposedCheck, createDifficultyPool } from
|
|
1
|
+
export { roll } from "./dice";
|
|
2
|
+
export type { DicePool, RollResult } from "./types";
|
|
3
|
+
export { createSkillCheck, createCombatCheck, createOpposedCheck, createDifficultyPool, } from "./pools";
|
package/dist/pools.d.ts
CHANGED
package/dist/pools.js
CHANGED
|
@@ -9,7 +9,7 @@ exports.createDifficultyPool = exports.createOpposedCheck = exports.createCombat
|
|
|
9
9
|
*/
|
|
10
10
|
const createSkillCheck = (ability, proficiency) => ({
|
|
11
11
|
abilityDice: Math.max(0, ability),
|
|
12
|
-
proficiencyDice: Math.max(0, proficiency)
|
|
12
|
+
proficiencyDice: Math.max(0, proficiency),
|
|
13
13
|
});
|
|
14
14
|
exports.createSkillCheck = createSkillCheck;
|
|
15
15
|
/**
|
|
@@ -22,7 +22,7 @@ exports.createSkillCheck = createSkillCheck;
|
|
|
22
22
|
const createCombatCheck = (ability, proficiency, boost = 0) => ({
|
|
23
23
|
abilityDice: Math.max(0, ability),
|
|
24
24
|
proficiencyDice: Math.max(0, proficiency),
|
|
25
|
-
boostDice: Math.max(0, boost)
|
|
25
|
+
boostDice: Math.max(0, boost),
|
|
26
26
|
});
|
|
27
27
|
exports.createCombatCheck = createCombatCheck;
|
|
28
28
|
/**
|
|
@@ -37,7 +37,7 @@ const createOpposedCheck = (ability, proficiency, difficulty, challenge = 0) =>
|
|
|
37
37
|
abilityDice: Math.max(0, ability),
|
|
38
38
|
proficiencyDice: Math.max(0, proficiency),
|
|
39
39
|
difficultyDice: Math.max(0, difficulty),
|
|
40
|
-
challengeDice: Math.max(0, challenge)
|
|
40
|
+
challengeDice: Math.max(0, challenge),
|
|
41
41
|
});
|
|
42
42
|
exports.createOpposedCheck = createOpposedCheck;
|
|
43
43
|
/**
|
|
@@ -48,6 +48,6 @@ exports.createOpposedCheck = createOpposedCheck;
|
|
|
48
48
|
*/
|
|
49
49
|
const createDifficultyPool = (difficulty, challenge = 0) => ({
|
|
50
50
|
difficultyDice: Math.max(0, difficulty),
|
|
51
|
-
challengeDice: Math.max(0, challenge)
|
|
51
|
+
challengeDice: Math.max(0, challenge),
|
|
52
52
|
});
|
|
53
53
|
exports.createDifficultyPool = createDifficultyPool;
|
package/dist/types.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export type DiceResult = {
|
|
|
14
14
|
triumphs: number;
|
|
15
15
|
despair: number;
|
|
16
16
|
};
|
|
17
|
-
export type DieType =
|
|
17
|
+
export type DieType = "boost" | "ability" | "proficiency" | "setback" | "difficulty" | "challenge";
|
|
18
18
|
export type DetailedDieResult = {
|
|
19
19
|
type: DieType;
|
|
20
20
|
roll: number;
|
package/package.json
CHANGED
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swrpg-online/dice",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "A TypeScript library for simulating Star Wars RPG narrative dice rolls.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"swrpg-dice": "dist/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./dist/index.js",
|
|
11
|
+
"./cli": "./dist/cli.js"
|
|
12
|
+
},
|
|
6
13
|
"directories": {
|
|
7
14
|
"test": "tests"
|
|
8
15
|
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist/**"
|
|
18
|
+
],
|
|
9
19
|
"scripts": {
|
|
10
20
|
"test": "npx jest --verbose",
|
|
11
|
-
"
|
|
21
|
+
"ci:test": "tsc --noEmit && npx jest --verbose",
|
|
22
|
+
"build": "tsc && ls -l",
|
|
12
23
|
"prepare": "npm run build && husky install"
|
|
13
24
|
},
|
|
14
25
|
"keywords": [],
|
|
@@ -22,10 +33,20 @@
|
|
|
22
33
|
"typescript": "^5.7.2"
|
|
23
34
|
},
|
|
24
35
|
"devDependencies": {
|
|
25
|
-
"
|
|
36
|
+
"@semantic-release/changelog": "^6.0.3",
|
|
37
|
+
"@semantic-release/git": "^10.0.1",
|
|
38
|
+
"@semantic-release/github": "^11.0.1",
|
|
39
|
+
"@semantic-release/npm": "^12.0.1",
|
|
40
|
+
"husky": "^8.0.3",
|
|
41
|
+
"lint-staged": "^15.2.10",
|
|
42
|
+
"prettier": "3.4.1",
|
|
43
|
+
"semantic-release": "^24.2.0"
|
|
26
44
|
},
|
|
27
45
|
"repository": {
|
|
28
46
|
"type": "git",
|
|
29
47
|
"url": "https://github.com/swrpg-online/dice"
|
|
48
|
+
},
|
|
49
|
+
"lint-staged": {
|
|
50
|
+
"**/*": "prettier --write --ignore-unknown"
|
|
30
51
|
}
|
|
31
52
|
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
name: Publish Package
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- main # Change this to your default branch if necessary
|
|
7
|
-
|
|
8
|
-
jobs:
|
|
9
|
-
publish:
|
|
10
|
-
runs-on: ubuntu-latest
|
|
11
|
-
|
|
12
|
-
steps:
|
|
13
|
-
- name: Checkout code
|
|
14
|
-
uses: actions/checkout@v2
|
|
15
|
-
|
|
16
|
-
- name: Set up Node.js
|
|
17
|
-
uses: actions/setup-node@v2
|
|
18
|
-
with:
|
|
19
|
-
node-version: '16' # Change to the appropriate Node.js version
|
|
20
|
-
registry-url: 'https://registry.npmjs.org/'
|
|
21
|
-
|
|
22
|
-
- name: Install dependencies
|
|
23
|
-
run: npm install
|
|
24
|
-
|
|
25
|
-
- name: Build the project
|
|
26
|
-
run: npm run build
|
|
27
|
-
|
|
28
|
-
- name: Publish package
|
|
29
|
-
run: npm publish
|
|
30
|
-
env:
|
|
31
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/.husky/.skip-tests
DELETED
|
File without changes
|
package/.husky/pre-commit
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
#!/bin/sh
|
|
2
|
-
. "$(dirname "$0")/_/husky.sh"
|
|
3
|
-
|
|
4
|
-
# Check for an existing environment variable to prevent infinite loop
|
|
5
|
-
if [ "$SKIP_HOOK" != "true" ]; then
|
|
6
|
-
export SKIP_HOOK=true
|
|
7
|
-
# Run tests
|
|
8
|
-
npm run test
|
|
9
|
-
|
|
10
|
-
# Check if coverage files have been modified
|
|
11
|
-
if ! git diff --quiet coverage/; then
|
|
12
|
-
# Set an environment variable to prevent re-triggering the hook
|
|
13
|
-
# export SKIP_HOOK=true
|
|
14
|
-
|
|
15
|
-
# Stage coverage files
|
|
16
|
-
git add coverage/
|
|
17
|
-
|
|
18
|
-
# Commit the coverage files
|
|
19
|
-
git commit -m "Add latest coverage files" --allow-empty --no-verify
|
|
20
|
-
|
|
21
|
-
# Unset the environment variable
|
|
22
|
-
unset SKIP_HOOK
|
|
23
|
-
fi
|
|
24
|
-
fi
|
|
25
|
-
|
|
26
|
-
# Build the project
|
|
27
|
-
npm run build
|
|
28
|
-
|
|
29
|
-
# Check for changes in package.json
|
|
30
|
-
if git diff --cached --name-only | grep package.json; then
|
|
31
|
-
npm version patch # Use 'minor'/'major' as needed
|
|
32
|
-
fi
|