@swrpg-online/dice 1.3.0 → 1.4.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 +54 -5
- package/dist/bundle.cjs.js +1 -1
- package/dist/bundle.cjs.js.map +1 -1
- package/dist/bundle.esm.js +1 -1
- package/dist/bundle.esm.js.map +1 -1
- package/dist/bundle.umd.js +1 -1
- package/dist/bundle.umd.js.map +1 -1
- package/dist/cli.js +127 -1
- package/dist/dice.js +184 -487
- package/dist/diceFaces.d.ts +17 -0
- package/dist/diceFaces.js +90 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +13 -1
- package/dist/pools.d.ts +31 -4
- package/dist/pools.js +34 -5
- package/dist/types.d.ts +29 -0
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -22,6 +22,115 @@ function parseDiceNotation(input) {
|
|
|
22
22
|
.split(" ")
|
|
23
23
|
.filter((p) => p.length > 0);
|
|
24
24
|
for (const part of parts) {
|
|
25
|
+
// Check for modifiers (start with + or -)
|
|
26
|
+
// Only treat as modifier if it has a known modifier suffix
|
|
27
|
+
if (part.startsWith("+") || (part.startsWith("-") && part.length > 2)) {
|
|
28
|
+
const isPositive = part.startsWith("+");
|
|
29
|
+
const modPart = part.slice(1);
|
|
30
|
+
const count = parseInt(modPart);
|
|
31
|
+
if (isNaN(count)) {
|
|
32
|
+
// If it starts with + but has no number, skip as invalid modifier
|
|
33
|
+
if (part.startsWith("+")) {
|
|
34
|
+
warnings.push(`Invalid modifier notation: "${part}" - number not found`);
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
// Otherwise treat as regular dice notation (for negative numbers)
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
const modifier = modPart.slice(String(count).length).toLowerCase();
|
|
41
|
+
// Check if this is actually a modifier (has a known suffix)
|
|
42
|
+
const knownModifiers = [
|
|
43
|
+
"s",
|
|
44
|
+
"success",
|
|
45
|
+
"f",
|
|
46
|
+
"failure",
|
|
47
|
+
"a",
|
|
48
|
+
"advantage",
|
|
49
|
+
"t",
|
|
50
|
+
"threat",
|
|
51
|
+
"tr",
|
|
52
|
+
"triumph",
|
|
53
|
+
"d",
|
|
54
|
+
"despair",
|
|
55
|
+
"ls",
|
|
56
|
+
"lightside",
|
|
57
|
+
"ds",
|
|
58
|
+
"darkside",
|
|
59
|
+
"ua",
|
|
60
|
+
"upgradeability",
|
|
61
|
+
"ud",
|
|
62
|
+
"upgradedifficulty",
|
|
63
|
+
"dp",
|
|
64
|
+
"downgradeproficiency",
|
|
65
|
+
"dc",
|
|
66
|
+
"downgradechallenge",
|
|
67
|
+
];
|
|
68
|
+
if (knownModifiers.includes(modifier)) {
|
|
69
|
+
const value = isPositive ? count : -count;
|
|
70
|
+
switch (modifier) {
|
|
71
|
+
// Automatic symbols
|
|
72
|
+
case "s":
|
|
73
|
+
case "success":
|
|
74
|
+
pool.automaticSuccesses = (pool.automaticSuccesses || 0) + value;
|
|
75
|
+
break;
|
|
76
|
+
case "f":
|
|
77
|
+
case "failure":
|
|
78
|
+
pool.automaticFailures = (pool.automaticFailures || 0) + value;
|
|
79
|
+
break;
|
|
80
|
+
case "a":
|
|
81
|
+
case "advantage":
|
|
82
|
+
pool.automaticAdvantages =
|
|
83
|
+
(pool.automaticAdvantages || 0) + value;
|
|
84
|
+
break;
|
|
85
|
+
case "t":
|
|
86
|
+
case "threat":
|
|
87
|
+
pool.automaticThreats = (pool.automaticThreats || 0) + value;
|
|
88
|
+
break;
|
|
89
|
+
case "tr":
|
|
90
|
+
case "triumph":
|
|
91
|
+
pool.automaticTriumphs = (pool.automaticTriumphs || 0) + value;
|
|
92
|
+
break;
|
|
93
|
+
case "d":
|
|
94
|
+
case "despair":
|
|
95
|
+
pool.automaticDespairs = (pool.automaticDespairs || 0) + value;
|
|
96
|
+
break;
|
|
97
|
+
case "ls":
|
|
98
|
+
case "lightside":
|
|
99
|
+
pool.automaticLightSide = (pool.automaticLightSide || 0) + value;
|
|
100
|
+
break;
|
|
101
|
+
case "ds":
|
|
102
|
+
case "darkside":
|
|
103
|
+
pool.automaticDarkSide = (pool.automaticDarkSide || 0) + value;
|
|
104
|
+
break;
|
|
105
|
+
// Upgrades and downgrades
|
|
106
|
+
case "ua":
|
|
107
|
+
case "upgradeability":
|
|
108
|
+
pool.upgradeAbility = (pool.upgradeAbility || 0) + value;
|
|
109
|
+
break;
|
|
110
|
+
case "ud":
|
|
111
|
+
case "upgradedifficulty":
|
|
112
|
+
pool.upgradeDifficulty = (pool.upgradeDifficulty || 0) + value;
|
|
113
|
+
break;
|
|
114
|
+
case "dp":
|
|
115
|
+
case "downgradeproficiency":
|
|
116
|
+
pool.downgradeProficiency =
|
|
117
|
+
(pool.downgradeProficiency || 0) + value;
|
|
118
|
+
break;
|
|
119
|
+
case "dc":
|
|
120
|
+
case "downgradechallenge":
|
|
121
|
+
pool.downgradeChallenge = (pool.downgradeChallenge || 0) + value;
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
else if (part.startsWith("+")) {
|
|
127
|
+
// If it starts with + but has unknown suffix, warn and skip
|
|
128
|
+
warnings.push(`Invalid modifier type: "${modifier}" in "${part}"`);
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
// If it starts with - and has no known modifier suffix, treat as negative dice count
|
|
132
|
+
}
|
|
133
|
+
}
|
|
25
134
|
const count = parseInt(part);
|
|
26
135
|
// Check if parseInt returned NaN
|
|
27
136
|
if (isNaN(count)) {
|
|
@@ -137,7 +246,8 @@ const main = () => {
|
|
|
137
246
|
: args.join(" ");
|
|
138
247
|
if (!diceNotation.trim()) {
|
|
139
248
|
console.log(`Usage: swrpg-dice <dice-notation> <dice-options>
|
|
140
|
-
Example: swrpg-dice 2y 1g 1p 1b 1sb --hints
|
|
249
|
+
Example: swrpg-dice 2y 1g 1p 1b 1sb +2s +1a --hints
|
|
250
|
+
|
|
141
251
|
Dice Options:
|
|
142
252
|
- y/pro = Yellow / Proficiency
|
|
143
253
|
- g/a = Green / Ability
|
|
@@ -146,6 +256,22 @@ const main = () => {
|
|
|
146
256
|
- p/diff = Purple / Difficulty
|
|
147
257
|
- blk/k/sb/s = Black / Setback
|
|
148
258
|
- w/f = White/Force
|
|
259
|
+
|
|
260
|
+
Modifiers (use + or - prefix):
|
|
261
|
+
Automatic Symbols:
|
|
262
|
+
- +Ns/success = Add N successes
|
|
263
|
+
- +Nf/failure = Add N failures
|
|
264
|
+
- +Na/advantage = Add N advantages
|
|
265
|
+
- +Nt/threat = Add N threats
|
|
266
|
+
- +Ntr/triumph = Add N triumphs
|
|
267
|
+
- +Nd/despair = Add N despairs
|
|
268
|
+
|
|
269
|
+
Dice Upgrades/Downgrades:
|
|
270
|
+
- +Nua = Upgrade N ability dice to proficiency
|
|
271
|
+
- +Nud = Upgrade N difficulty dice to challenge
|
|
272
|
+
- +Ndp = Downgrade N proficiency dice to ability
|
|
273
|
+
- +Ndc = Downgrade N challenge dice to difficulty
|
|
274
|
+
|
|
149
275
|
Options:
|
|
150
276
|
--hints Show possible actions based on roll results`);
|
|
151
277
|
process.exit(1);
|