@lippelt/srd-core 0.1.0 → 0.1.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.
Files changed (2) hide show
  1. package/README.md +101 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,101 @@
1
+ # @lippelt/srd-core
2
+
3
+ Contrato + registry para sistemas de RPG plugáveis. Cada sistema (D&D 5e, Pathfinder, Lancer, etc) ships como seu próprio pacote (`@lippelt/srd-*`), implementando o contrato `System` definido aqui.
4
+
5
+ Pensado pra ser consumido por painéis de mesa, ferramentas de jogo e VTTs leves — agnóstico de UI.
6
+
7
+ ## Instalação
8
+
9
+ ```bash
10
+ npm install @lippelt/srd-core @lippelt/srd-dnd5e-2014 # exemplo: + D&D 5e
11
+ ```
12
+
13
+ ## Uso
14
+
15
+ ```ts
16
+ import { register, getSystem } from '@lippelt/srd-core'
17
+ import { dnd5e2014 } from '@lippelt/srd-dnd5e-2014'
18
+
19
+ register(dnd5e2014)
20
+
21
+ const sys = getSystem('dnd5e-2014')
22
+ const result = sys?.rules?.roll?.('attack', { modifier: 5, targetAC: 18, advantage: true })
23
+ // → { rolls: [18, 4], modifier: 5, total: 23, notation: '2d20kh1+5', notes: ['vantagem', 'acertou (CA 18)'] }
24
+ ```
25
+
26
+ ## API
27
+
28
+ - `register(system: System): void` — registra um sistema. Idempotente (mesma referência); colisão de id com instância diferente lança erro.
29
+ - `getSystem(id: SystemId): System | null` — resolve sync; retorna `null` se não registrado.
30
+ - `listRegisteredSystems(): SystemId[]` — todos os ids atualmente registrados.
31
+ - `clearRegistry(): void` — limpa o registry (útil em testes).
32
+
33
+ ## Contrato `System`
34
+
35
+ ```ts
36
+ interface System {
37
+ id: string
38
+ name: string
39
+ ruleVersion: string
40
+ attribution: string
41
+ dicePresets: DicePreset[]
42
+ conditions: ConditionDef[]
43
+ trackerFields: TrackerField[]
44
+ rules?: SystemRules // opcional — rolls customizados (advantage, crit, damage)
45
+ }
46
+ ```
47
+
48
+ ### `DicePreset`
49
+
50
+ Botões rápidos de rolagem por categoria (`check`, `attack`, `damage`, `save`, `special`):
51
+
52
+ ```ts
53
+ { id: 'd20-adv', label: 'd20 com vantagem', notation: '2d20kh1', category: 'check' }
54
+ ```
55
+
56
+ ### `ConditionDef`
57
+
58
+ Status/condições do sistema:
59
+
60
+ ```ts
61
+ { id: 'poisoned', label: 'Envenenado', summary: 'Desvantagem em ataques e testes de atributo.' }
62
+ ```
63
+
64
+ ### `TrackerField`
65
+
66
+ Campos numéricos/booleanos extras por combatente:
67
+
68
+ ```ts
69
+ { key: 'ac', label: 'CA', kind: 'integer', min: 0, max: 30, default: 10 }
70
+ { key: 'inspiration', label: 'Insp', kind: 'boolean', default: false }
71
+ ```
72
+
73
+ ### `SystemRules` (opcional)
74
+
75
+ Funções puras de roll/dano que vão além da notação `NdM±K`:
76
+
77
+ ```ts
78
+ rules?: {
79
+ roll?: (kind: string, params: unknown) => RollResult | null
80
+ applyDamage?: (incoming: number, target?: unknown) => { final: number; notes: string[] }
81
+ }
82
+ ```
83
+
84
+ `kind` é convenção do sistema (ex.: `'attack'`, `'save'`, `'damage'`).
85
+
86
+ ## Sistemas implementados
87
+
88
+ Veja o monorepo [gmcr-srd-systems](https://github.com/flippelt/gmcr-srd-systems): D&D 3.5, D&D 5e (2014/2024), Pathfinder 1e/2e, Starfinder 1e/2e, Lancer, GUMSHOE, Daggerheart, Candela Obscura.
89
+
90
+ ## Adicionar um sistema novo
91
+
92
+ 1. Crie `packages/<seu-sistema>/` no monorepo (ou em projeto separado).
93
+ 2. Implemente o contrato `System`.
94
+ 3. Exporte como named export (ex.: `export const meuSistema: System = { ... }`).
95
+ 4. `register(meuSistema)` no bootstrap do consumidor.
96
+
97
+ Veja [`packages/dnd5e-2014/`](https://github.com/flippelt/gmcr-srd-systems/tree/main/packages/dnd5e-2014) como referência.
98
+
99
+ ## Licença
100
+
101
+ [MIT](LICENSE).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lippelt/srd-core",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Plugin core for tabletop RPG system modules (types + registry). Each system ships in its own package.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",