@lippelt/srd-core 0.1.0 → 0.1.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.
Files changed (2) hide show
  1. package/README.md +103 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,103 @@
1
+ # @lippelt/srd-core
2
+
3
+ Contrato + registro para sistemas de RPG plugáveis. Cada sistema (D&D 5e, Pathfinder, Lancer etc) é distribuído como seu próprio pacote (`@lippelt/srd-*`), implementando o contrato `System` definido aqui.
4
+
5
+ Pensado para 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 síncrono; retorna `null` se não registrado.
30
+ - `listRegisteredSystems(): SystemId[]` — todos os ids atualmente registrados.
31
+ - `clearRegistry(): void` — limpa o registro (ú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 — rolagens customizadas (vantagem, crítico, dano)
45
+ }
46
+ ```
47
+
48
+ > Os nomes dos campos no contrato permanecem em inglês por serem identificadores de código (consumidos por TypeScript em qualquer idioma de projeto).
49
+
50
+ ### `DicePreset`
51
+
52
+ Botões de rolagem rápida por categoria (`check`, `attack`, `damage`, `save`, `special`):
53
+
54
+ ```ts
55
+ { id: 'd20-adv', label: 'd20 com vantagem', notation: '2d20kh1', category: 'check' }
56
+ ```
57
+
58
+ ### `ConditionDef`
59
+
60
+ Condições/estados do sistema:
61
+
62
+ ```ts
63
+ { id: 'poisoned', label: 'Envenenado', summary: 'Desvantagem em ataques e testes de habilidade.' }
64
+ ```
65
+
66
+ ### `TrackerField`
67
+
68
+ Campos numéricos/booleanos extras por combatente:
69
+
70
+ ```ts
71
+ { key: 'ac', label: 'CA', kind: 'integer', min: 0, max: 30, default: 10 }
72
+ { key: 'inspiration', label: 'Insp', kind: 'boolean', default: false }
73
+ ```
74
+
75
+ ### `SystemRules` (opcional)
76
+
77
+ Funções puras de rolagem/dano que vão além da notação `NdM±K`:
78
+
79
+ ```ts
80
+ rules?: {
81
+ roll?: (kind: string, params: unknown) => RollResult | null
82
+ applyDamage?: (incoming: number, target?: unknown) => { final: number; notes: string[] }
83
+ }
84
+ ```
85
+
86
+ `kind` é convenção do sistema (ex.: `'attack'`, `'save'`, `'damage'`).
87
+
88
+ ## Sistemas implementados
89
+
90
+ 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.
91
+
92
+ ## Adicionar um sistema novo
93
+
94
+ 1. Crie `packages/<seu-sistema>/` no monorepo (ou em projeto separado).
95
+ 2. Implemente o contrato `System`.
96
+ 3. Exporte como named export (ex.: `export const meuSistema: System = { ... }`).
97
+ 4. `register(meuSistema)` no bootstrap do consumidor.
98
+
99
+ Veja [`packages/dnd5e-2014/`](https://github.com/flippelt/gmcr-srd-systems/tree/main/packages/dnd5e-2014) como referência.
100
+
101
+ ## Licença
102
+
103
+ [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.2",
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",