rpg-event-generator 3.1.1 → 4.0.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 (66) hide show
  1. package/README.md +48 -298
  2. package/demo.js +75 -1055
  3. package/dist/RPGEventGenerator.d.ts +24 -2
  4. package/dist/RPGEventGenerator.d.ts.map +1 -1
  5. package/dist/RPGEventGenerator.js +47 -21
  6. package/dist/RPGEventGenerator.js.map +1 -1
  7. package/dist/chains/ChainSystem.js +1 -1
  8. package/dist/chains/index.js +1 -1
  9. package/dist/core/ContextAnalyzer.js +1 -1
  10. package/dist/core/DifficultyScaler.js +1 -1
  11. package/dist/core/GeneratorCore.d.ts +19 -112
  12. package/dist/core/GeneratorCore.d.ts.map +1 -1
  13. package/dist/core/GeneratorCore.js +1817 -1437
  14. package/dist/core/GeneratorCore.js.map +1 -1
  15. package/dist/core/MarkovEngine.js +1 -1
  16. package/dist/core/index.js +1 -1
  17. package/dist/database/MemoryDatabaseAdapter.js +1 -1
  18. package/dist/database/TemplateDatabase.js +1 -1
  19. package/dist/environment/EnvironmentalSystem.d.ts +2 -0
  20. package/dist/environment/EnvironmentalSystem.d.ts.map +1 -1
  21. package/dist/environment/EnvironmentalSystem.js +46 -10
  22. package/dist/environment/EnvironmentalSystem.js.map +1 -1
  23. package/dist/environment/index.js +1 -1
  24. package/dist/index.js +1 -1
  25. package/dist/interfaces/systems.d.ts +1 -1
  26. package/dist/interfaces/systems.d.ts.map +1 -1
  27. package/dist/localization/LocalizationSystem.js +1 -1
  28. package/dist/localization/index.js +1 -1
  29. package/dist/relationships/RelationshipSystem.js +1 -1
  30. package/dist/relationships/index.js +1 -1
  31. package/dist/rules/RuleEngine.js +1 -1
  32. package/dist/rules/index.js +1 -1
  33. package/dist/src/types/world.d.ts +9 -0
  34. package/dist/src/types/world.d.ts.map +1 -1
  35. package/dist/templates/TemplateSystem.js +1 -1
  36. package/dist/templates/index.js +1 -1
  37. package/dist/time/TimeSystem.js +1 -1
  38. package/dist/time/index.js +1 -1
  39. package/dist/types/world.d.ts +9 -0
  40. package/dist/types/world.d.ts.map +1 -1
  41. package/dist/utils/array.js +1 -1
  42. package/dist/utils/constants.js +1 -1
  43. package/dist/utils/file.js +1 -1
  44. package/dist/utils/index.d.ts +1 -0
  45. package/dist/utils/index.d.ts.map +1 -1
  46. package/dist/utils/index.js +2 -1
  47. package/dist/utils/index.js.map +1 -1
  48. package/dist/utils/random.js +1 -1
  49. package/dist/utils/text.js +1 -1
  50. package/dist/utils/validation.js +1 -1
  51. package/dist/utils/version.d.ts +8 -0
  52. package/dist/utils/version.d.ts.map +1 -0
  53. package/dist/utils/version.js +11 -0
  54. package/dist/utils/version.js.map +1 -0
  55. package/dist/world/WorldBuildingSystem.d.ts +16 -2
  56. package/dist/world/WorldBuildingSystem.d.ts.map +1 -1
  57. package/dist/world/WorldBuildingSystem.js +357 -155
  58. package/dist/world/WorldBuildingSystem.js.map +1 -1
  59. package/dist/world/index.d.ts +1 -1
  60. package/dist/world/index.d.ts.map +1 -1
  61. package/dist/world/index.js.map +1 -1
  62. package/dist/world/worldContent.d.ts +13 -0
  63. package/dist/world/worldContent.d.ts.map +1 -0
  64. package/dist/world/worldContent.js +109 -0
  65. package/dist/world/worldContent.js.map +1 -0
  66. package/package.json +1 -1
package/README.md CHANGED
@@ -3,336 +3,86 @@
3
3
  [![npm version](https://badge.fury.io/js/rpg-event-generator.svg)](https://badge.fury.io/js/rpg-event-generator)
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
5
 
6
- A powerful procedural content generation system for dynamic, context aware narratives and interactive experiences. Perfect for games, simulations, and creative applications.
7
-
8
- ## ☕ Support
9
-
10
- If RPG Event Generator has been helpful to your project, consider buying me a coffee!
11
-
12
- <a href="https://www.buymeacoffee.com/Decept1kon" target="_blank">
13
- <img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;">
14
- </a>
15
-
16
- ## ✨ Features
17
-
18
- - **🧠 Intelligent Generation** - Context aware events that adapt to user state
19
- - **🎯 Advanced Templates** - Conditional templates, composition, inheritance, mixins
20
- - **🌍 World Building** - Automated world generation with factions and history
21
- - **⚡ Performance** - Template caching, parallel generation, batched processing
22
- - **🔌 Pluggable AI** - Optional AI/ML integration with multiple providers
23
- - **💾 Database Support** - Scalable storage with pluggable adapters
24
- - **🎮 Game Engine Export** - Unity C#, Godot GDScript, Unreal Engine C++
25
- - **🌐 Multi Language** - Generate content in different languages
26
- - **⏰ Time Systems** - Seasonal changes and temporal progression
27
- - **🤝 Relationship Networks** - Dynamic character relationships
28
- - **🎲 Markov Chains** - Natural sounding narratives
29
-
30
- ## 📦 Installation
6
+ Offline procedural RPG events with context flavoured text and a built in content library. No API key required.
31
7
 
32
8
  ```bash
33
9
  npm install rpg-event-generator
34
10
  ```
35
11
 
36
- ### Requirements
37
- - Node.js 16+
38
- - TypeScript 4.5+ (for development)
12
+ Requires Node.js 16+.
39
13
 
40
- ## 🚀 Quick Start
41
-
42
- ### Basic Usage
14
+ ## Quick start
43
15
 
44
16
  ```javascript
45
- const { RPGEventGenerator, generateRPGEvent } = require('rpg-event-generator');
17
+ const { generateRPGEvent } = require('rpg-event-generator');
46
18
 
47
- // Simple event generation
48
19
  const event = generateRPGEvent({
49
- age: 25,
50
- gold: 500,
51
- influence: 15,
52
- career: 'merchant'
53
- });
54
-
55
- console.log(event.title); // "Golden Opportunity"
56
- console.log(event.description); // Procedurally generated narrative
57
- console.log(event.choices); // Array of meaningful choices
58
- ```
59
-
60
- ### With Custom Configuration
61
-
62
- ```javascript
63
- const generator = new RPGEventGenerator({
64
- theme: 'fantasy'
65
- });
66
-
67
- // Generate context aware event
68
- const event = generator.generateEvent({
69
- level: 15,
70
- gold: 2500,
71
- class: 'wizard'
20
+ level: 10,
21
+ location: 'forest',
22
+ weather: 'rainy',
23
+ class: 'fighter'
72
24
  });
73
25
 
74
- console.log(event.title);
75
- console.log(event.description);
76
- console.log(event.choices);
26
+ console.log(event.title); // e.g. "Heroic Quest"
27
+ console.log(event.description); // context prefixes: location, weather, time, class, race
28
+ console.log(event.choices); // [{ text, effect }, ...]
29
+ console.log(event.type); // e.g. "COMBAT"
77
30
  ```
78
31
 
79
- ## 🎨 Advanced Usage
32
+ Or with a configured instance:
80
33
 
81
- ### World Building
82
34
  ```javascript
83
- // Generate complete game world
84
- const world = await generator.generateWorld();
85
- console.log(`World: ${world.regions.length} regions, ${world.factions.length} factions`);
86
-
87
- // Simulate history
88
- await generator.simulateWorldYears(50);
89
- const history = generator.getHistoricalEvents();
90
- ```
35
+ const { RPGEventGenerator } = require('rpg-event-generator');
91
36
 
92
- ### Custom Templates
93
- ```javascript
94
- // Register conditional template
95
- generator.registerTemplate('merchant', {
96
- title: "Merchant Encounter",
97
- conditional_choices: [{
98
- condition: { player_gold: { gt: 1000 } },
99
- choice: { text: "Buy rare artifact", effect: { gold: -500 } }
100
- }]
101
- });
102
- ```
103
-
104
- ### AI Enhancement
105
- ```javascript
106
- const aiGenerator = new RPGEventGenerator({
107
- aiEnhancement: {
108
- provider: 'openai',
109
- apiKey: process.env.OPENAI_API_KEY
110
- }
111
- });
112
- ```
113
-
114
- ## 🔧 Configuration
115
-
116
- ```javascript
117
- const config = {
118
- theme: 'fantasy',
119
- enableAI: false,
120
- enableDatabase: false,
121
- enableCaching: true,
122
- maxParallelGeneration: 4,
123
-
124
- aiEnhancement: {
125
- provider: 'openai',
126
- apiKey: 'your-key'
127
- }
128
- };
129
- ```
130
-
131
- ## 📚 API
132
-
133
- - `generateEvent(context)` - Generate single event
134
- - `generateEvents(context, count)` - Generate multiple events
135
- - `generateWorld()` - Create game world
136
- - `registerTemplate(id, template)` - Add custom template
137
- - `exportTemplates(format, path)` - Export to game engines
138
-
139
- Full API docs: [Documentation](https://ContextWeaver.github.io/context-weaver/)
140
-
141
- ## 📄 License
142
-
143
- MIT License - see [LICENSE](LICENSE) file.
144
-
145
- ## 🎯 Use Cases & Examples
146
-
147
- ### Gaming Applications
148
- ```javascript
149
- // RPG Character Interactions
150
37
  const generator = new RPGEventGenerator({ theme: 'fantasy' });
151
- const playerState = {
152
- level: 15,
153
- class: 'wizard',
154
- gold: 2500,
155
- reputation: 75
156
- };
157
-
158
- const event = generator.generateEvent(playerState);
159
- // Result: "The ancient tome pulses with magical energy..."
160
- ```
161
-
162
- ### Business Simulations
163
- ```javascript
164
- // Customer Service Scenarios
165
- const businessGenerator = new RPGEventGenerator({
166
- trainingData: [
167
- 'Customer reports billing discrepancy',
168
- 'Technical support ticket resolved',
169
- 'Product feedback received and processed'
170
- ]
171
- });
172
-
173
- const scenario = businessGenerator.generateEvent({
174
- department: 'support',
175
- priority: 'high',
176
- customerValue: 85
177
- });
178
- ```
179
-
180
- ### Educational Tools
181
- ```javascript
182
- // Interactive Learning Scenarios
183
- const educationGenerator = new RPGEventGenerator({
184
- theme: 'historical',
185
- culture: 'educational'
186
- });
187
-
188
- const lesson = educationGenerator.generateEvent({
189
- subject: 'history',
190
- difficulty: 'intermediate',
191
- learningObjectives: ['critical_thinking', 'decision_making']
192
- });
193
- ```
194
-
195
- ### Research & Data Simulation
196
- ```javascript
197
- // User Behavior Modeling
198
- const researchGenerator = new RPGEventGenerator({
199
- enableRelationships: true,
200
- enableModifiers: true
201
- });
202
-
203
- const simulation = researchGenerator.generateEvent({
204
- userType: 'research_subject',
205
- conditions: ['experimental', 'controlled'],
206
- variables: ['time_pressure', 'cognitive_load']
207
- });
38
+ const event = generator.generateEvent({ level: 15, class: 'wizard', location: 'tower' });
208
39
  ```
209
40
 
210
- ## 🆕 Latest Features (v3.1.0)
211
-
212
- ### Database Integration
213
- Store and retrieve templates from databases for large-scale applications:
41
+ ## Custom content
214
42
 
215
43
  ```javascript
216
- const generator = new RPGEventGenerator({ enableDatabase: true });
217
-
218
- await generator.storeTemplateInDatabase(customTemplate);
219
- const retrieved = await generator.getTemplateFromDatabase('template_id');
220
- const searchResults = await generator.searchTemplatesInDatabase({ type: 'combat' });
44
+ generator.addTrainingData({
45
+ titles: { COMBAT: ['Epic Duel'] },
46
+ descriptions: { COMBAT: ['Two warriors circle each other...'] },
47
+ choices: { COMBAT: ['Fight', 'Flee', 'Negotiate'] }
48
+ }, 'my_theme');
221
49
  ```
222
50
 
223
- ### World Building System
224
- Generate entire game worlds with factions, regions, and historical events:
51
+ Use structured objects (`titles`, `descriptions`, `choices`). Raw string arrays are ignored in v4.
225
52
 
226
- ```javascript
227
- const world = await generator.generateWorld();
228
- await generator.simulateWorldYears(50); // Advance world history
229
- const factionPower = generator.getFactionPowerRanking();
230
- ```
53
+ ## Feature tiers
231
54
 
232
- ### Advanced Template Features
233
- Create complex, conditional templates with inheritance and composition:
55
+ **Start with Tier 1.** Everything else is optional.
234
56
 
235
- ```javascript
236
- // Conditional templates
237
- const conditionalTemplate = {
238
- id: 'level_based_event',
239
- conditions: [{ type: 'stat_requirement', field: 'level', operator: 'gte', value: 10 }],
240
- conditional_choices: [{
241
- condition: { type: 'has_item', item: 'magic_sword' },
242
- choice: { text: 'Use magic sword', effect: { damage: 50 } }
243
- }]
244
- };
57
+ | Tier | What | Use when |
58
+ |------|------|----------|
59
+ | **1 Core** | `generateRPGEvent()` / `generateEvent()`, built-in library, `addTrainingData()` | Game jams, first ship |
60
+ | **2 — Orchestrator** | Templates, rules, environmental modifiers, optional AI | Custom event logic |
61
+ | **3 Toolkit** | World sim, DB adapters, engine export scripts | Lore JSON, tooling experiments |
245
62
 
246
- // Template composition
247
- const composedTemplate = {
248
- id: 'weather_merchant',
249
- composition: [{
250
- template_id: 'merchant_base',
251
- merge_strategy: 'append_narrative'
252
- }, {
253
- template_id: 'weather_effects',
254
- conditions: [{ type: 'random_chance', probability: 0.6 }]
255
- }]
256
- };
257
- ```
63
+ Tier 3 (`generateWorld(seed)` or `{ seed, continentCount }`) produces seeded lore JSON — regions, factions, history. Use `getWorldLore(location)` for a one-line hook into player events. Not a live sim backbone.
258
64
 
259
- ### Performance Optimizations
260
- Handle large-scale generation with advanced caching and parallel processing:
65
+ ## Documentation
261
66
 
262
- ```javascript
263
- const generator = new RPGEventGenerator({
264
- enableTemplateCaching: true,
265
- enableEventCaching: true
266
- });
67
+ Full guides ship with the repo — no wiki required.
267
68
 
268
- // Generate events in parallel
269
- const events = await generator.generateEventsParallel(100, context, 4); // 4 threads
270
- // Generate in batches for memory efficiency
271
- const batchedEvents = generator.generateEventsBatched(1000, context, 50); // 50 events per batch
272
- ```
273
-
274
- ## 🎮 Demo
275
-
276
- Run the included demo to explore all features:
277
-
278
- ```bash
279
- # Using npm script (recommended)
280
- npm run demo
281
-
282
- # Direct script call
283
- node demo.js
284
- ```
285
-
286
- This will demonstrate event generation, chains, time progression, customization, and more.
287
-
288
- ## 📚 Documentation & Resources
289
-
290
- ### 📖 Documentation
291
- - **Wiki Available**: Comprehensive guides, tutorials, and examples available on the [GitHub Wiki](https://github.com/ContextWeaver/context-weaver/wiki)
292
- - **API Documentation**: Complete TypeDoc reference available on [GitHub Pages](https://contextweaver.github.io/context-weaver/)
293
-
294
- ### 🛠️ Development & Testing
295
- - Run `npm run demo` to see all 30+ features in action
296
- - Run `npm run docs` to regenerate API documentation
297
- - Run `npm test` to execute the comprehensive test suite
298
- - Check the `demo.js` file for interactive examples
299
- - Check the `test/` directory for usage examples
300
-
301
- ### 📂 Key Directories
302
- - `src/` - Modular TypeScript source code
303
- - `docs/` - Complete documentation and guides
304
- - `templates/` - Built-in event templates
305
- - `test/` - Comprehensive test suite
306
- - `scripts/` - Build and export scripts
307
-
308
- ## 🤝 Contributing
309
-
310
- We welcome contributions! Please feel free to submit issues, feature requests, and pull requests.
311
-
312
- ### Development Setup
313
-
314
- ```bash
315
- # Clone the repository
316
- git clone https://github.com/ContextWeaver/context-weaver.git
317
- cd context-weaver
318
-
319
- # Install dependencies
320
- npm install
321
-
322
- # Run tests
323
- npm test
324
-
325
- # Run demo
326
- npm run demo
327
-
328
- # Build for distribution
329
- npm run build
330
- ```
69
+ | Guide | Topic |
70
+ |-------|--------|
71
+ | [Getting Started](https://contextweaver.github.io/context-weaver/documents/getting-started.html) | Install, quick start, context fields |
72
+ | [Examples](https://contextweaver.github.io/context-weaver/documents/examples.html) | Copy-paste snippets by tier |
73
+ | [Custom Content](https://contextweaver.github.io/context-weaver/documents/custom-content.html) | `addTrainingData()` |
74
+ | [Feature Tiers](https://contextweaver.github.io/context-weaver/documents/feature-tiers.html) | What to use when |
75
+ | [World Building](https://contextweaver.github.io/context-weaver/documents/world-building.html) | Seeded world lore |
76
+ | [Templates & Rules](https://contextweaver.github.io/context-weaver/documents/templates-and-rules.html) | Tier 2 orchestrator |
77
+ | [Configuration](https://contextweaver.github.io/context-weaver/documents/configuration.html) | Generator options |
78
+ | [Advanced Tooling](https://contextweaver.github.io/context-weaver/documents/advanced-tooling.html) | DB, export, AI |
331
79
 
332
- ## 📄 License
80
+ Build locally: `npm run docs` → open `docs/index.html`
333
81
 
334
- MIT License - see [LICENSE](LICENSE) file for details.
82
+ - **API reference:** [contextweaver.github.io/context-weaver](https://contextweaver.github.io/context-weaver/)
83
+ - **Migration (v3 → v4):** [MIGRATION.md](MIGRATION.md)
84
+ - **Smoke test (local):** `npm run build && npm run demo` — short CLI check, not a feature tour
335
85
 
336
- ---
86
+ ## License
337
87
 
338
- **Generate infinite possibilities with RPG Event Generator!** 🎲✨
88
+ MIT see [LICENSE](LICENSE).