@mcptoolshop/roll 1.0.0
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/CHANGELOG.md +17 -0
- package/LICENSE +21 -0
- package/README.es.md +204 -0
- package/README.fr.md +204 -0
- package/README.hi.md +204 -0
- package/README.it.md +204 -0
- package/README.ja.md +204 -0
- package/README.md +204 -0
- package/README.pt-BR.md +204 -0
- package/README.zh.md +204 -0
- package/dist/analyze/distribution.d.ts +6 -0
- package/dist/analyze/distribution.d.ts.map +1 -0
- package/dist/analyze/distribution.js +252 -0
- package/dist/analyze/distribution.js.map +1 -0
- package/dist/analyze/montecarlo.d.ts +5 -0
- package/dist/analyze/montecarlo.d.ts.map +1 -0
- package/dist/analyze/montecarlo.js +19 -0
- package/dist/analyze/montecarlo.js.map +1 -0
- package/dist/analyze/stats.d.ts +16 -0
- package/dist/analyze/stats.d.ts.map +1 -0
- package/dist/analyze/stats.js +66 -0
- package/dist/analyze/stats.js.map +1 -0
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +267 -0
- package/dist/bin.js.map +1 -0
- package/dist/display/box.d.ts +5 -0
- package/dist/display/box.d.ts.map +1 -0
- package/dist/display/box.js +26 -0
- package/dist/display/box.js.map +1 -0
- package/dist/display/color.d.ts +12 -0
- package/dist/display/color.d.ts.map +1 -0
- package/dist/display/color.js +19 -0
- package/dist/display/color.js.map +1 -0
- package/dist/display/format.d.ts +13 -0
- package/dist/display/format.d.ts.map +1 -0
- package/dist/display/format.js +134 -0
- package/dist/display/format.js.map +1 -0
- package/dist/display/histogram.d.ts +7 -0
- package/dist/display/histogram.d.ts.map +1 -0
- package/dist/display/histogram.js +48 -0
- package/dist/display/histogram.js.map +1 -0
- package/dist/engine/random.d.ts +6 -0
- package/dist/engine/random.d.ts.map +1 -0
- package/dist/engine/random.js +17 -0
- package/dist/engine/random.js.map +1 -0
- package/dist/engine/roller.d.ts +19 -0
- package/dist/engine/roller.d.ts.map +1 -0
- package/dist/engine/roller.js +168 -0
- package/dist/engine/roller.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/loot/table.d.ts +27 -0
- package/dist/loot/table.d.ts.map +1 -0
- package/dist/loot/table.js +92 -0
- package/dist/loot/table.js.map +1 -0
- package/dist/parser/ast.d.ts +27 -0
- package/dist/parser/ast.d.ts.map +1 -0
- package/dist/parser/ast.js +2 -0
- package/dist/parser/ast.js.map +1 -0
- package/dist/parser/lexer.d.ts +7 -0
- package/dist/parser/lexer.d.ts.map +1 -0
- package/dist/parser/lexer.js +126 -0
- package/dist/parser/lexer.js.map +1 -0
- package/dist/parser/parser.d.ts +7 -0
- package/dist/parser/parser.d.ts.map +1 -0
- package/dist/parser/parser.js +188 -0
- package/dist/parser/parser.js.map +1 -0
- package/dist/parser/tokens.d.ts +25 -0
- package/dist/parser/tokens.d.ts.map +1 -0
- package/dist/parser/tokens.js +21 -0
- package/dist/parser/tokens.js.map +1 -0
- package/package.json +55 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 1.0.0 (2026-04-10)
|
|
4
|
+
|
|
5
|
+
Initial release.
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
- **Dice expression parser** — full recursive descent parser supporting `NdM`, arithmetic (`+`, `-`, `*`, `/`), parentheses, keep highest/lowest (`kh`, `kl`), drop highest/lowest (`dh`, `dl`), exploding dice (`!`, `!>N`), percentile (`d%`), and Fate dice (`dF`)
|
|
10
|
+
- **Probability analyzer** — exact distributions via convolution and enumeration, Monte Carlo fallback for complex expressions
|
|
11
|
+
- **Statistics** — mean, median, mode, standard deviation, percentiles (10/25/50/75/90/95), Shannon entropy
|
|
12
|
+
- **Terminal histograms** — colored bar charts with mode/median markers
|
|
13
|
+
- **Loot table roller** — weighted selection, nested table references, integrated dice expressions for quantity and value
|
|
14
|
+
- **Comparison mode** — side-by-side distribution analysis of two expressions
|
|
15
|
+
- **At-least mode** — P(result >= target) with visual probability bar
|
|
16
|
+
- **Zero runtime dependencies** — Node 22+ builtins only
|
|
17
|
+
- **Dual-use** — CLI via `npx @mcptoolshop/roll` and importable as a library
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 mcp-tool-shop
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.es.md
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="README.ja.md">日本語</a> | <a href="README.zh.md">中文</a> | <a href="README.md">English</a> | <a href="README.fr.md">Français</a> | <a href="README.hi.md">हिन्दी</a> | <a href="README.it.md">Italiano</a> | <a href="README.pt-BR.md">Português (BR)</a>
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center"><img src="https://raw.githubusercontent.com/mcp-tool-shop-org/brand/main/logos/roll/readme.png" width="400" alt="Roll"></p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://github.com/mcp-tool-shop-org/roll/actions"><img src="https://github.com/mcp-tool-shop-org/roll/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
|
|
9
|
+
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="MIT License"></a>
|
|
10
|
+
<a href="https://mcp-tool-shop-org.github.io/roll/"><img src="https://img.shields.io/badge/Landing_Page-online-brightgreen" alt="Landing Page"></a>
|
|
11
|
+
<a href="https://www.npmjs.com/package/@mcptoolshop/roll"><img src="https://img.shields.io/npm/v/@mcptoolshop/roll" alt="npm version"></a>
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
<p align="center">RPG dice engine with probability analysis, loot tables, and beautiful terminal output.</p>
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
npx @mcptoolshop/roll 4d6dl1 --analyze
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
Distribution
|
|
22
|
+
|
|
23
|
+
3 0.08%
|
|
24
|
+
4 █ 0.31%
|
|
25
|
+
5 ███ 0.77%
|
|
26
|
+
6 ███████ 1.62%
|
|
27
|
+
7 █████████████ 2.93%
|
|
28
|
+
8 ██████████████████████ 4.78%
|
|
29
|
+
9 ████████████████████████████████ 7.02%
|
|
30
|
+
10 ███████████████████████████████████████████ 9.41%
|
|
31
|
+
11 ████████████████████████████████████████████████████ 11.42%
|
|
32
|
+
12 ██████████████████████████████████████████████████████████ 12.89%
|
|
33
|
+
13 ████████████████████████████████████████████████████████████ 13.27%
|
|
34
|
+
14 ████████████████████████████████████████████████████████ 12.35%
|
|
35
|
+
15 ██████████████████████████████████████████████ 10.11%
|
|
36
|
+
16 █████████████████████████████████ 7.25%
|
|
37
|
+
17 ███████████████████ 4.17%
|
|
38
|
+
18 ███████ 1.62%
|
|
39
|
+
|
|
40
|
+
┌─ Statistics ─────────────────────────────────┐
|
|
41
|
+
│ Mean: 12.24 │
|
|
42
|
+
│ Median: 12 │
|
|
43
|
+
│ Mode: 13 │
|
|
44
|
+
│ Std Dev: 2.85 │
|
|
45
|
+
│ Range: 3–18 │
|
|
46
|
+
│ Entropy: 3.53 bits │
|
|
47
|
+
│ │
|
|
48
|
+
│ Percentiles: │
|
|
49
|
+
│ p10:8 p25:10 p50:12 p75:14 p90:16 p95:17│
|
|
50
|
+
└───────────────────────────────────────────────┘
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Instalación
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
npm install @mcptoolshop/roll
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Requiere Node.js >= 22.
|
|
60
|
+
|
|
61
|
+
## Uso de la línea de comandos
|
|
62
|
+
|
|
63
|
+
### Lanzar dados
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
roll 2d6+3
|
|
67
|
+
roll d20+5
|
|
68
|
+
roll 4d6kh3
|
|
69
|
+
roll 1d6!
|
|
70
|
+
roll d%
|
|
71
|
+
roll 4dF
|
|
72
|
+
roll "(2d6+3)*2"
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Analizar probabilidad
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
roll 2d6 --analyze # Full distribution + statistics
|
|
79
|
+
roll d20+5 --at-least 15 # P(result >= 15)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Comparar distribuciones
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
roll --compare "4d6dl1" "3d6"
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Estadísticas comparativas (media, mediana, moda, desviación estándar, rango, entropía) con columna de diferencias, además de ambos histogramas.
|
|
89
|
+
|
|
90
|
+
### Tablas de botín
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
roll --loot treasure.json
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Formato JSON:
|
|
97
|
+
|
|
98
|
+
```json
|
|
99
|
+
{
|
|
100
|
+
"tables": [
|
|
101
|
+
{
|
|
102
|
+
"table": "Treasure",
|
|
103
|
+
"items": [
|
|
104
|
+
{ "name": "Gold", "weight": 40, "roll": "2d6*10" },
|
|
105
|
+
{ "name": "Potion of Healing", "weight": 30 },
|
|
106
|
+
{ "name": "Scroll", "weight": 15, "quantity": "1d3" },
|
|
107
|
+
{ "name": "Rare Item", "weight": 5, "table": "Rare Weapons" }
|
|
108
|
+
]
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"table": "Rare Weapons",
|
|
112
|
+
"items": [
|
|
113
|
+
{ "name": "Vorpal Blade", "weight": 5 },
|
|
114
|
+
{ "name": "Frost Brand", "weight": 25 }
|
|
115
|
+
]
|
|
116
|
+
}
|
|
117
|
+
]
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Características: selección ponderada, referencias a tablas anidadas, expresiones de dados para cantidad y valor.
|
|
122
|
+
|
|
123
|
+
### Otras opciones
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
roll 2d6+3 --times 5 # Roll 5 times
|
|
127
|
+
roll 2d6+3 --json # Machine-readable output
|
|
128
|
+
roll --help # Full usage
|
|
129
|
+
roll --version # Version
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Notación de dados
|
|
133
|
+
|
|
134
|
+
| Notación | Significado |
|
|
135
|
+
|----------|---------|
|
|
136
|
+
| `2d6` | Lanzar 2 dados de seis caras |
|
|
137
|
+
| `d20` | Lanzar 1 dado de veinte caras |
|
|
138
|
+
| `4d6kh3` | Lanzar 4d6, conservar los 3 más altos |
|
|
139
|
+
| `4d6dl1` | Lanzar 4d6, descartar el más bajo |
|
|
140
|
+
| `1d6!` | Dado explosivo (relanzar en el máximo, sumar) |
|
|
141
|
+
| `1d6!>4` | Explosión al obtener 4 o más |
|
|
142
|
+
| `d%` | Dado de percentil (1-100) |
|
|
143
|
+
| `4dF` | Dados de Fate/Fudge (-1, 0, +1 cada uno) |
|
|
144
|
+
| `(2d6+3)*2` | Aritmética con agrupación |
|
|
145
|
+
| `2d6+1d4+3` | Expresiones encadenadas |
|
|
146
|
+
|
|
147
|
+
## API de la biblioteca
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
import { roll, analyze, parse, evaluate, computeDistribution } from '@mcptoolshop/roll';
|
|
151
|
+
|
|
152
|
+
// Quick roll
|
|
153
|
+
const result = roll('4d6kh3');
|
|
154
|
+
console.log(result.total); // 14
|
|
155
|
+
console.log(result.groups[0].dice); // per-die breakdown
|
|
156
|
+
|
|
157
|
+
// Full analysis
|
|
158
|
+
const analysis = analyze('2d6+3');
|
|
159
|
+
console.log(analysis.stats.mean); // 10
|
|
160
|
+
console.log(analysis.stats.percentiles[95]); // 14
|
|
161
|
+
console.log(analysis.probabilityAtLeast(12)); // 0.2778
|
|
162
|
+
|
|
163
|
+
// Low-level: parse → AST → evaluate
|
|
164
|
+
import { seededRng } from '@mcptoolshop/roll';
|
|
165
|
+
const ast = parse('4d6dl1');
|
|
166
|
+
const r = evaluate(ast, seededRng(42)); // deterministic
|
|
167
|
+
|
|
168
|
+
// Loot tables
|
|
169
|
+
import { rollLootTable } from '@mcptoolshop/roll';
|
|
170
|
+
const tables = [{ table: "Loot", items: [{ name: "Gold", weight: 50, roll: "2d6*10" }] }];
|
|
171
|
+
const drops = rollLootTable(tables);
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Motor de probabilidad
|
|
175
|
+
|
|
176
|
+
- **Distribuciones exactas** mediante convolución polinómica para NdM básicos.
|
|
177
|
+
- **Enumeración completa** para mecánicas de conservación/descarte (4d6 = 1296 estados).
|
|
178
|
+
- **Recursión truncada** para dados explosivos (limitado a 10 explosiones).
|
|
179
|
+
- **Método de Monte Carlo** (100.000 muestras) cuando el cálculo exacto supera los 10 millones de estados.
|
|
180
|
+
|
|
181
|
+
## Sin dependencias externas
|
|
182
|
+
|
|
183
|
+
Construido completamente con funciones integradas de Node.js 22+:
|
|
184
|
+
- `util.styleText` para colores en la terminal.
|
|
185
|
+
- `util.parseArgs` para el análisis de argumentos de la línea de comandos.
|
|
186
|
+
- `crypto.randomInt` para generación de números aleatorios criptográficamente seguros para el lanzamiento de dados.
|
|
187
|
+
|
|
188
|
+
## Seguridad y Confianza
|
|
189
|
+
|
|
190
|
+
`@mcptoolshop/roll` procesa expresiones de dados y nada más. No realiza solicitudes de red, no escribe archivos y no recopila datos. El único acceso al sistema de archivos es a través de la opción `--loot`, que lee un único archivo JSON especificado por el usuario.
|
|
191
|
+
|
|
192
|
+
No hay telemetría, ni análisis, ni seguimiento de ningún tipo. No se utilizan secretos, tokens ni credenciales en ninguna operación.
|
|
193
|
+
|
|
194
|
+
Todos los lanzamientos de dados utilizan `crypto.randomInt` del módulo `crypto` de Node.js, proporcionando aleatoriedad criptográficamente segura adecuada para obtener resultados justos.
|
|
195
|
+
|
|
196
|
+
Consulte [SECURITY.md](./SECURITY.md) para obtener la política de informes de vulnerabilidades.
|
|
197
|
+
|
|
198
|
+
## Licencia
|
|
199
|
+
|
|
200
|
+
MIT
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
Desarrollado por <a href="https://mcp-tool-shop.github.io/">MCP Tool Shop</a>
|
package/README.fr.md
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="README.ja.md">日本語</a> | <a href="README.zh.md">中文</a> | <a href="README.es.md">Español</a> | <a href="README.md">English</a> | <a href="README.hi.md">हिन्दी</a> | <a href="README.it.md">Italiano</a> | <a href="README.pt-BR.md">Português (BR)</a>
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center"><img src="https://raw.githubusercontent.com/mcp-tool-shop-org/brand/main/logos/roll/readme.png" width="400" alt="Roll"></p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://github.com/mcp-tool-shop-org/roll/actions"><img src="https://github.com/mcp-tool-shop-org/roll/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
|
|
9
|
+
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="MIT License"></a>
|
|
10
|
+
<a href="https://mcp-tool-shop-org.github.io/roll/"><img src="https://img.shields.io/badge/Landing_Page-online-brightgreen" alt="Landing Page"></a>
|
|
11
|
+
<a href="https://www.npmjs.com/package/@mcptoolshop/roll"><img src="https://img.shields.io/npm/v/@mcptoolshop/roll" alt="npm version"></a>
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
<p align="center">RPG dice engine with probability analysis, loot tables, and beautiful terminal output.</p>
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
npx @mcptoolshop/roll 4d6dl1 --analyze
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
Distribution
|
|
22
|
+
|
|
23
|
+
3 0.08%
|
|
24
|
+
4 █ 0.31%
|
|
25
|
+
5 ███ 0.77%
|
|
26
|
+
6 ███████ 1.62%
|
|
27
|
+
7 █████████████ 2.93%
|
|
28
|
+
8 ██████████████████████ 4.78%
|
|
29
|
+
9 ████████████████████████████████ 7.02%
|
|
30
|
+
10 ███████████████████████████████████████████ 9.41%
|
|
31
|
+
11 ████████████████████████████████████████████████████ 11.42%
|
|
32
|
+
12 ██████████████████████████████████████████████████████████ 12.89%
|
|
33
|
+
13 ████████████████████████████████████████████████████████████ 13.27%
|
|
34
|
+
14 ████████████████████████████████████████████████████████ 12.35%
|
|
35
|
+
15 ██████████████████████████████████████████████ 10.11%
|
|
36
|
+
16 █████████████████████████████████ 7.25%
|
|
37
|
+
17 ███████████████████ 4.17%
|
|
38
|
+
18 ███████ 1.62%
|
|
39
|
+
|
|
40
|
+
┌─ Statistics ─────────────────────────────────┐
|
|
41
|
+
│ Mean: 12.24 │
|
|
42
|
+
│ Median: 12 │
|
|
43
|
+
│ Mode: 13 │
|
|
44
|
+
│ Std Dev: 2.85 │
|
|
45
|
+
│ Range: 3–18 │
|
|
46
|
+
│ Entropy: 3.53 bits │
|
|
47
|
+
│ │
|
|
48
|
+
│ Percentiles: │
|
|
49
|
+
│ p10:8 p25:10 p50:12 p75:14 p90:16 p95:17│
|
|
50
|
+
└───────────────────────────────────────────────┘
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Installation
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
npm install @mcptoolshop/roll
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Nécessite Node.js >= 22.
|
|
60
|
+
|
|
61
|
+
## Utilisation de l'interface en ligne de commande (CLI)
|
|
62
|
+
|
|
63
|
+
### Lancer des dés
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
roll 2d6+3
|
|
67
|
+
roll d20+5
|
|
68
|
+
roll 4d6kh3
|
|
69
|
+
roll 1d6!
|
|
70
|
+
roll d%
|
|
71
|
+
roll 4dF
|
|
72
|
+
roll "(2d6+3)*2"
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Analyser les probabilités
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
roll 2d6 --analyze # Full distribution + statistics
|
|
79
|
+
roll d20+5 --at-least 15 # P(result >= 15)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Comparer les distributions
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
roll --compare "4d6dl1" "3d6"
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Statistiques côte à côte (moyenne, médiane, mode, écart type, plage, entropie) avec une colonne de différence, ainsi que les deux histogrammes.
|
|
89
|
+
|
|
90
|
+
### Tables de butin
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
roll --loot treasure.json
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Format JSON :
|
|
97
|
+
|
|
98
|
+
```json
|
|
99
|
+
{
|
|
100
|
+
"tables": [
|
|
101
|
+
{
|
|
102
|
+
"table": "Treasure",
|
|
103
|
+
"items": [
|
|
104
|
+
{ "name": "Gold", "weight": 40, "roll": "2d6*10" },
|
|
105
|
+
{ "name": "Potion of Healing", "weight": 30 },
|
|
106
|
+
{ "name": "Scroll", "weight": 15, "quantity": "1d3" },
|
|
107
|
+
{ "name": "Rare Item", "weight": 5, "table": "Rare Weapons" }
|
|
108
|
+
]
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"table": "Rare Weapons",
|
|
112
|
+
"items": [
|
|
113
|
+
{ "name": "Vorpal Blade", "weight": 5 },
|
|
114
|
+
{ "name": "Frost Brand", "weight": 25 }
|
|
115
|
+
]
|
|
116
|
+
}
|
|
117
|
+
]
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Fonctionnalités : sélection pondérée, références de tables imbriquées, expressions de dés pour la quantité et la valeur.
|
|
122
|
+
|
|
123
|
+
### Autres options
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
roll 2d6+3 --times 5 # Roll 5 times
|
|
127
|
+
roll 2d6+3 --json # Machine-readable output
|
|
128
|
+
roll --help # Full usage
|
|
129
|
+
roll --version # Version
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Notation des dés
|
|
133
|
+
|
|
134
|
+
| Notation | Signification |
|
|
135
|
+
|----------|---------|
|
|
136
|
+
| `2d6` | Lancer 2 dés à 6 faces |
|
|
137
|
+
| `d20` | Lancer 1 dé à 20 faces |
|
|
138
|
+
| `4d6kh3` | Lancer 4d6, conserver les 3 plus élevés |
|
|
139
|
+
| `4d6dl1` | Lancer 4d6, éliminer le plus bas |
|
|
140
|
+
| `1d6!` | Dé explosif (relancer sur le maximum, ajouter) |
|
|
141
|
+
| `1d6!>4` | Exploser sur 4 ou plus |
|
|
142
|
+
| `d%` | Dé en pourcentage (1-100) |
|
|
143
|
+
| `4dF` | Dés Fate/Fudge (-1, 0, +1 chacun) |
|
|
144
|
+
| `(2d6+3)*2` | Opérations arithmétiques avec regroupement |
|
|
145
|
+
| `2d6+1d4+3` | Expressions chaînées |
|
|
146
|
+
|
|
147
|
+
## API de la bibliothèque
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
import { roll, analyze, parse, evaluate, computeDistribution } from '@mcptoolshop/roll';
|
|
151
|
+
|
|
152
|
+
// Quick roll
|
|
153
|
+
const result = roll('4d6kh3');
|
|
154
|
+
console.log(result.total); // 14
|
|
155
|
+
console.log(result.groups[0].dice); // per-die breakdown
|
|
156
|
+
|
|
157
|
+
// Full analysis
|
|
158
|
+
const analysis = analyze('2d6+3');
|
|
159
|
+
console.log(analysis.stats.mean); // 10
|
|
160
|
+
console.log(analysis.stats.percentiles[95]); // 14
|
|
161
|
+
console.log(analysis.probabilityAtLeast(12)); // 0.2778
|
|
162
|
+
|
|
163
|
+
// Low-level: parse → AST → evaluate
|
|
164
|
+
import { seededRng } from '@mcptoolshop/roll';
|
|
165
|
+
const ast = parse('4d6dl1');
|
|
166
|
+
const r = evaluate(ast, seededRng(42)); // deterministic
|
|
167
|
+
|
|
168
|
+
// Loot tables
|
|
169
|
+
import { rollLootTable } from '@mcptoolshop/roll';
|
|
170
|
+
const tables = [{ table: "Loot", items: [{ name: "Gold", weight: 50, roll: "2d6*10" }] }];
|
|
171
|
+
const drops = rollLootTable(tables);
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Moteur de probabilités
|
|
175
|
+
|
|
176
|
+
- **Distributions exactes** via convolution polynomiale pour les dés de base (NdM)
|
|
177
|
+
- **Énumération complète** pour les mécanismes de conservation/élimination (4d6 = 1296 états)
|
|
178
|
+
- **Récursion tronquée** pour les dés explosifs (limité à 10 explosions)
|
|
179
|
+
- **Rétrogradation Monte Carlo** (100 000 échantillons) lorsque le calcul exact dépasse 10 millions d'états
|
|
180
|
+
|
|
181
|
+
## Aucune dépendance
|
|
182
|
+
|
|
183
|
+
Construit entièrement sur les fonctionnalités intégrées de Node.js 22+ :
|
|
184
|
+
- `util.styleText` pour les couleurs du terminal
|
|
185
|
+
- `util.parseArgs` pour l'analyse des arguments de l'interface en ligne de commande
|
|
186
|
+
- `crypto.randomInt` pour des lancers de dés cryptographiquement sécurisés
|
|
187
|
+
|
|
188
|
+
## Sécurité et confiance
|
|
189
|
+
|
|
190
|
+
`@mcptoolshop/roll` traite les expressions de dés et rien d'autre. Il ne fait aucune requête réseau, n'écrit aucun fichier et ne collecte aucune donnée. L'accès au système de fichiers est limité à l'option `--loot`, qui lit un seul fichier JSON spécifié par l'utilisateur.
|
|
191
|
+
|
|
192
|
+
Il n'y a pas de télémétrie, d'analyse ni de suivi de quelque nature que ce soit. Aucun secret, jeton ou identifiant n'est impliqué dans aucune opération.
|
|
193
|
+
|
|
194
|
+
Tous les lancers de dés utilisent `crypto.randomInt` du module `crypto` de Node.js, ce qui fournit une aléatoire cryptographiquement sécurisée, adaptée pour des résultats équitables.
|
|
195
|
+
|
|
196
|
+
Consultez [SECURITY.md](./SECURITY.md) pour connaître la politique de signalement des vulnérabilités.
|
|
197
|
+
|
|
198
|
+
## Licence
|
|
199
|
+
|
|
200
|
+
MIT
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
Créé par <a href="https://mcp-tool-shop.github.io/">MCP Tool Shop</a>
|
package/README.hi.md
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="README.ja.md">日本語</a> | <a href="README.zh.md">中文</a> | <a href="README.es.md">Español</a> | <a href="README.fr.md">Français</a> | <a href="README.md">English</a> | <a href="README.it.md">Italiano</a> | <a href="README.pt-BR.md">Português (BR)</a>
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center"><img src="https://raw.githubusercontent.com/mcp-tool-shop-org/brand/main/logos/roll/readme.png" width="400" alt="Roll"></p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://github.com/mcp-tool-shop-org/roll/actions"><img src="https://github.com/mcp-tool-shop-org/roll/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
|
|
9
|
+
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="MIT License"></a>
|
|
10
|
+
<a href="https://mcp-tool-shop-org.github.io/roll/"><img src="https://img.shields.io/badge/Landing_Page-online-brightgreen" alt="Landing Page"></a>
|
|
11
|
+
<a href="https://www.npmjs.com/package/@mcptoolshop/roll"><img src="https://img.shields.io/npm/v/@mcptoolshop/roll" alt="npm version"></a>
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
<p align="center">RPG dice engine with probability analysis, loot tables, and beautiful terminal output.</p>
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
npx @mcptoolshop/roll 4d6dl1 --analyze
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
Distribution
|
|
22
|
+
|
|
23
|
+
3 0.08%
|
|
24
|
+
4 █ 0.31%
|
|
25
|
+
5 ███ 0.77%
|
|
26
|
+
6 ███████ 1.62%
|
|
27
|
+
7 █████████████ 2.93%
|
|
28
|
+
8 ██████████████████████ 4.78%
|
|
29
|
+
9 ████████████████████████████████ 7.02%
|
|
30
|
+
10 ███████████████████████████████████████████ 9.41%
|
|
31
|
+
11 ████████████████████████████████████████████████████ 11.42%
|
|
32
|
+
12 ██████████████████████████████████████████████████████████ 12.89%
|
|
33
|
+
13 ████████████████████████████████████████████████████████████ 13.27%
|
|
34
|
+
14 ████████████████████████████████████████████████████████ 12.35%
|
|
35
|
+
15 ██████████████████████████████████████████████ 10.11%
|
|
36
|
+
16 █████████████████████████████████ 7.25%
|
|
37
|
+
17 ███████████████████ 4.17%
|
|
38
|
+
18 ███████ 1.62%
|
|
39
|
+
|
|
40
|
+
┌─ Statistics ─────────────────────────────────┐
|
|
41
|
+
│ Mean: 12.24 │
|
|
42
|
+
│ Median: 12 │
|
|
43
|
+
│ Mode: 13 │
|
|
44
|
+
│ Std Dev: 2.85 │
|
|
45
|
+
│ Range: 3–18 │
|
|
46
|
+
│ Entropy: 3.53 bits │
|
|
47
|
+
│ │
|
|
48
|
+
│ Percentiles: │
|
|
49
|
+
│ p10:8 p25:10 p50:12 p75:14 p90:16 p95:17│
|
|
50
|
+
└───────────────────────────────────────────────┘
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## इंस्टॉल करें
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
npm install @mcptoolshop/roll
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
इसके लिए Node.js >= 22 की आवश्यकता है।
|
|
60
|
+
|
|
61
|
+
## सीएलआई (CLI) का उपयोग
|
|
62
|
+
|
|
63
|
+
### पासा फेंको
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
roll 2d6+3
|
|
67
|
+
roll d20+5
|
|
68
|
+
roll 4d6kh3
|
|
69
|
+
roll 1d6!
|
|
70
|
+
roll d%
|
|
71
|
+
roll 4dF
|
|
72
|
+
roll "(2d6+3)*2"
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### संभावना का विश्लेषण करें
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
roll 2d6 --analyze # Full distribution + statistics
|
|
79
|
+
roll d20+5 --at-least 15 # P(result >= 15)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### वितरणों की तुलना करें
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
roll --compare "4d6dl1" "3d6"
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
एक साथ आंकड़े (माध्य, माध्यिका, बहुलक, मानक विचलन, सीमा, एंट्रॉपी) 'अंतर' कॉलम के साथ, साथ ही दोनों हिस्टोग्राम।
|
|
89
|
+
|
|
90
|
+
### लूट तालिकाएँ
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
roll --loot treasure.json
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
JSON प्रारूप:
|
|
97
|
+
|
|
98
|
+
```json
|
|
99
|
+
{
|
|
100
|
+
"tables": [
|
|
101
|
+
{
|
|
102
|
+
"table": "Treasure",
|
|
103
|
+
"items": [
|
|
104
|
+
{ "name": "Gold", "weight": 40, "roll": "2d6*10" },
|
|
105
|
+
{ "name": "Potion of Healing", "weight": 30 },
|
|
106
|
+
{ "name": "Scroll", "weight": 15, "quantity": "1d3" },
|
|
107
|
+
{ "name": "Rare Item", "weight": 5, "table": "Rare Weapons" }
|
|
108
|
+
]
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"table": "Rare Weapons",
|
|
112
|
+
"items": [
|
|
113
|
+
{ "name": "Vorpal Blade", "weight": 5 },
|
|
114
|
+
{ "name": "Frost Brand", "weight": 25 }
|
|
115
|
+
]
|
|
116
|
+
}
|
|
117
|
+
]
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
विशेषताएं: भारित चयन, नेस्टेड टेबल संदर्भ, मात्रा और मूल्य के लिए पासा अभिव्यक्तियाँ।
|
|
122
|
+
|
|
123
|
+
### अन्य विकल्प
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
roll 2d6+3 --times 5 # Roll 5 times
|
|
127
|
+
roll 2d6+3 --json # Machine-readable output
|
|
128
|
+
roll --help # Full usage
|
|
129
|
+
roll --version # Version
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## पासा संकेतन
|
|
133
|
+
|
|
134
|
+
| संकेतन | अर्थ |
|
|
135
|
+
|----------|---------|
|
|
136
|
+
| `2d6` | 2 छः-भुजा वाले पासे फेंको |
|
|
137
|
+
| `d20` | 1 बीस-भुजा वाला पासा फेंको |
|
|
138
|
+
| `4d6kh3` | 4d6 फेंको, शीर्ष 3 रखें |
|
|
139
|
+
| `4d6dl1` | 4d6 फेंको, सबसे कम 1 हटा दें |
|
|
140
|
+
| `1d6!` | विस्फोटक d6 (अधिकतम पर पुनः रोल करें, जोड़ें) |
|
|
141
|
+
| `1d6!>4` | 4 या उससे अधिक पर विस्फोट करें |
|
|
142
|
+
| `d%` | प्रतिशत पासा (1-100) |
|
|
143
|
+
| `4dF` | फेट/फज पासे (-1, 0, +1 प्रत्येक) |
|
|
144
|
+
| `(2d6+3)*2` | समूहीकरण के साथ अंकगणित |
|
|
145
|
+
| `2d6+1d4+3` | शृंखलाबद्ध अभिव्यक्तियाँ |
|
|
146
|
+
|
|
147
|
+
## लाइब्रेरी एपीआई
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
import { roll, analyze, parse, evaluate, computeDistribution } from '@mcptoolshop/roll';
|
|
151
|
+
|
|
152
|
+
// Quick roll
|
|
153
|
+
const result = roll('4d6kh3');
|
|
154
|
+
console.log(result.total); // 14
|
|
155
|
+
console.log(result.groups[0].dice); // per-die breakdown
|
|
156
|
+
|
|
157
|
+
// Full analysis
|
|
158
|
+
const analysis = analyze('2d6+3');
|
|
159
|
+
console.log(analysis.stats.mean); // 10
|
|
160
|
+
console.log(analysis.stats.percentiles[95]); // 14
|
|
161
|
+
console.log(analysis.probabilityAtLeast(12)); // 0.2778
|
|
162
|
+
|
|
163
|
+
// Low-level: parse → AST → evaluate
|
|
164
|
+
import { seededRng } from '@mcptoolshop/roll';
|
|
165
|
+
const ast = parse('4d6dl1');
|
|
166
|
+
const r = evaluate(ast, seededRng(42)); // deterministic
|
|
167
|
+
|
|
168
|
+
// Loot tables
|
|
169
|
+
import { rollLootTable } from '@mcptoolshop/roll';
|
|
170
|
+
const tables = [{ table: "Loot", items: [{ name: "Gold", weight: 50, roll: "2d6*10" }] }];
|
|
171
|
+
const drops = rollLootTable(tables);
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## संभावना इंजन
|
|
175
|
+
|
|
176
|
+
- बुनियादी NdM के लिए बहुपद संवलन के माध्यम से **सटीक वितरण**
|
|
177
|
+
- 'कीप/ड्रॉप' तंत्र के लिए **पूर्ण गणना** (4d6 = 1,296 अवस्थाएँ)
|
|
178
|
+
- विस्फोटक पासे के लिए **छंटनी की गई पुनरावृत्ति** (10 विस्फोटों तक सीमित)
|
|
179
|
+
- जब सटीक गणना 10 मिलियन से अधिक अवस्थाओं से अधिक हो जाती है तो **मोंटे कार्लो बैकअप** (100k नमूने)
|
|
180
|
+
|
|
181
|
+
## शून्य निर्भरताएँ
|
|
182
|
+
|
|
183
|
+
यह पूरी तरह से Node.js 22+ के अंतर्निहित घटकों पर आधारित है:
|
|
184
|
+
- टर्मिनल रंगों के लिए `util.styleText`
|
|
185
|
+
- सीएलआई तर्क पार्सिंग के लिए `util.parseArgs`
|
|
186
|
+
- क्रिप्टोग्राफिक रूप से सुरक्षित पासा रोल के लिए `crypto.randomInt`
|
|
187
|
+
|
|
188
|
+
## सुरक्षा और विश्वसनीयता
|
|
189
|
+
|
|
190
|
+
`@mcptoolshop/roll` केवल पासा अभिव्यक्तियों को संसाधित करता है और कुछ और नहीं। यह कोई नेटवर्क अनुरोध नहीं करता है, कोई फ़ाइल नहीं लिखता है और कोई डेटा एकत्र नहीं करता है। एकमात्र फ़ाइल सिस्टम एक्सेस `--loot` ध्वज है, जो एक उपयोगकर्ता-निर्दिष्ट JSON फ़ाइल को पढ़ता है।
|
|
191
|
+
|
|
192
|
+
इसमें कोई टेलीमेट्री, कोई विश्लेषण और किसी भी प्रकार की ट्रैकिंग नहीं है। किसी भी ऑपरेशन में कोई गुप्त जानकारी, टोकन या क्रेडेंशियल शामिल नहीं हैं।
|
|
193
|
+
|
|
194
|
+
सभी पासा रोल Node.js के `crypto` मॉड्यूल से `crypto.randomInt` का उपयोग करते हैं, जो निष्पक्ष परिणामों के लिए उपयुक्त क्रिप्टोग्राफिक रूप से सुरक्षित यादृच्छिकता प्रदान करता है।
|
|
195
|
+
|
|
196
|
+
भेद्यता रिपोर्टिंग नीति के लिए [SECURITY.md](./SECURITY.md) देखें।
|
|
197
|
+
|
|
198
|
+
## लाइसेंस
|
|
199
|
+
|
|
200
|
+
MIT
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
<a href="https://mcp-tool-shop.github.io/">MCP Tool Shop</a> द्वारा निर्मित।
|