rpg-event-generator 4.0.0 → 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 -371
  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 +45 -19
  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 +1 -41
  12. package/dist/core/GeneratorCore.d.ts.map +1 -1
  13. package/dist/core/GeneratorCore.js +6 -48
  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,409 +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 with location, weather, time, class, and race integration
19
- - **📚 Massive Content Library** - 1,870+ unique narrative elements (850+ titles, 510+ descriptions, 510+ choices) across 17 event types
20
- - **🎯 Advanced Templates** - Conditional templates, composition, inheritance, mixins
21
- - **🌍 World Building** - Automated world generation with factions and history
22
- - **⚡ Performance** - Template caching, parallel generation, batched processing
23
- - **🔌 Pluggable AI** - Optional AI/ML integration with multiple providers
24
- - **💾 Database Support** - Scalable storage with pluggable adapters
25
- - **🎮 Game Engine Export** - Unity C#, Godot GDScript, Unreal Engine C++
26
- - **🌐 Multi Language** - Generate content in different languages
27
- - **⏰ Time Systems** - Seasonal changes and temporal progression
28
- - **🤝 Relationship Networks** - Dynamic character relationships
29
- - **🎨 Thematic Consistency** - Perfect alignment between titles, descriptions, and choices
30
- - **♾️ Infinite Variety** - 98%+ unique descriptions across 1000+ events
31
- - **🎲 Optional Markov Mode** - Traditional Markov chain generation available via `pureMarkovMode` option
32
-
33
- ## 📦 Installation
6
+ Offline procedural RPG events with context flavoured text and a built in content library. No API key required.
34
7
 
35
8
  ```bash
36
9
  npm install rpg-event-generator
37
10
  ```
38
11
 
39
- ### Requirements
40
- - Node.js 16+
41
- - TypeScript 4.5+ (for development)
42
-
43
- ## 🚀 Quick Start
12
+ Requires Node.js 16+.
44
13
 
45
- ### Basic Usage
14
+ ## Quick start
46
15
 
47
16
  ```javascript
48
- const { RPGEventGenerator, generateRPGEvent } = require('rpg-event-generator');
17
+ const { generateRPGEvent } = require('rpg-event-generator');
49
18
 
50
- // Simple event generation with context
51
19
  const event = generateRPGEvent({
52
- age: 25,
53
- gold: 500,
54
- influence: 15,
55
- career: 'merchant',
56
- location: 'market',
57
- weather: 'sunny',
58
- class: 'trader'
59
- });
60
-
61
- console.log(event.title); // "Golden Opportunity"
62
- console.log(event.description); // "In the market, beneath clear blue skies, a shrewd merchant..."
63
- console.log(event.choices); // Array of contextually relevant choices
64
- console.log(event.type); // "ECONOMIC"
65
- console.log(event.tags); // ["economic", "moderate"]
66
- ```
67
-
68
- ### With Custom Configuration
69
-
70
- ```javascript
71
- const generator = new RPGEventGenerator({
72
- theme: 'fantasy'
73
- });
74
-
75
- // Generate context aware event with rich contextual details
76
- const event = generator.generateEvent({
77
- level: 15,
78
- gold: 2500,
79
- class: 'wizard',
80
- race: 'elf',
81
- location: 'tower',
82
- weather: 'storm',
83
- timeOfDay: 'night'
84
- });
85
-
86
- console.log(event.title); // "Arcane Ritual Chamber"
87
- console.log(event.description); // "Deep in the night, within the shadows of the tower, arcane runes float..."
88
- console.log(event.choices); // Perfectly matched magical choices
89
- console.log(event.type); // "MAGIC" or "SPELLCASTING"
90
- ```
91
-
92
- ### Custom Training Data
93
-
94
- ```javascript
95
- // Add custom content for any theme
96
- generator.addTrainingData({
97
- titles: {
98
- COMBAT: ['⚔️ Epic Duel', '🗡️ Warrior Showdown']
99
- },
100
- descriptions: {
101
- COMBAT: ['Two legendary warriors circle each other in a duel that will determine the fate of kingdoms.']
102
- },
103
- choices: {
104
- COMBAT: ['⚔️ Engage in honorable combat', '🛡️ Take defensive position', '💨 Attempt strategic retreat']
105
- }
106
- }, 'custom_theme');
107
-
108
- // Custom content is automatically used when generating events
109
- const event = generator.generateEvent({ class: 'fighter' });
110
- // Will use custom content from 'custom_theme' if available
111
- ```
112
-
113
- ## 🎨 Advanced Usage
114
-
115
- ### World Building
116
- ```javascript
117
- // Generate complete game world
118
- const world = await generator.generateWorld();
119
- console.log(`World: ${world.regions.length} regions, ${world.factions.length} factions`);
120
-
121
- // Simulate history
122
- await generator.simulateWorldYears(50);
123
- const history = generator.getHistoricalEvents();
124
- ```
125
-
126
- ### Custom Templates
127
- ```javascript
128
- // Register conditional template
129
- generator.registerTemplate('merchant', {
130
- title: "Merchant Encounter",
131
- conditional_choices: [{
132
- condition: { player_gold: { gt: 1000 } },
133
- choice: { text: "Buy rare artifact", effect: { gold: -500 } }
134
- }]
20
+ level: 10,
21
+ location: 'forest',
22
+ weather: 'rainy',
23
+ class: 'fighter'
135
24
  });
136
- ```
137
25
 
138
- ### AI Enhancement
139
- ```javascript
140
- const aiGenerator = new RPGEventGenerator({
141
- aiEnhancement: {
142
- provider: 'openai',
143
- apiKey: process.env.OPENAI_API_KEY
144
- }
145
- });
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"
146
30
  ```
147
31
 
148
- ## 🔧 Configuration
32
+ Or with a configured instance:
149
33
 
150
34
  ```javascript
151
- const config = {
152
- theme: 'fantasy',
153
- enableAI: false,
154
- enableDatabase: false,
155
- enableCaching: true,
156
- maxParallelGeneration: 4,
157
-
158
- aiEnhancement: {
159
- provider: 'openai',
160
- apiKey: 'your-key'
161
- }
162
- };
163
- ```
164
-
165
- ## 📚 API
166
-
167
- ### Core Generation
168
- - `generateEvent(context)` - Generate single context-aware event with 1,870+ possible narrative combinations
169
- - `generateEvents(context, count)` - Generate multiple unique events
170
- - `addTrainingData(data, theme)` - Add custom titles, descriptions, and choices (supports multi-theme)
171
-
172
- ### Advanced Features
173
- - `generateWorld()` - Create game world
174
- - `registerTemplate(id, template)` - Add custom template
175
- - `exportTemplates(format, path)` - Export to game engines
35
+ const { RPGEventGenerator } = require('rpg-event-generator');
176
36
 
177
- ### Event Types Supported
178
- **17 Event Types**: ADVENTURE, COMBAT, ECONOMIC, EXPLORATION, GUILD, **MAGIC**, MYSTERY, POLITICAL, QUEST, SOCIAL, **SPELLCASTING**, SUPERNATURAL, TECHNOLOGICAL, UNDERWORLD, FIGHTER, CLERIC, ROGUE, MAGE, NECROMANCER
179
-
180
- Each type includes 50+ titles, 30+ descriptions, and 30+ specific choices for infinite variety.
181
-
182
- Full API docs: [Documentation](https://ContextWeaver.github.io/context-weaver/)
183
-
184
- ## 📄 License
185
-
186
- MIT License - see [LICENSE](LICENSE) file.
187
-
188
- ## 🎯 Use Cases & Examples
189
-
190
- ### Gaming Applications
191
- ```javascript
192
- // RPG Character Interactions with Rich Context
193
37
  const generator = new RPGEventGenerator({ theme: 'fantasy' });
194
- const playerState = {
195
- level: 15,
196
- class: 'wizard',
197
- race: 'elf',
198
- gold: 2500,
199
- reputation: 75,
200
- location: 'ancient library',
201
- weather: 'foggy',
202
- timeOfDay: 'midnight'
203
- };
204
-
205
- const event = generator.generateEvent(playerState);
206
- // Result: "At the stroke of midnight, deep within the ancient library, arcane runes float in the air..."
207
- // With perfectly matched choices like "Channel arcane energies", "Consult mystical visions", etc.
38
+ const event = generator.generateEvent({ level: 15, class: 'wizard', location: 'tower' });
208
39
  ```
209
40
 
210
- ### Business Simulations
211
- ```javascript
212
- // Customer Service Scenarios
213
- const businessGenerator = new RPGEventGenerator({
214
- trainingData: [
215
- 'Customer reports billing discrepancy',
216
- 'Technical support ticket resolved',
217
- 'Product feedback received and processed'
218
- ]
219
- });
220
-
221
- const scenario = businessGenerator.generateEvent({
222
- department: 'support',
223
- priority: 'high',
224
- customerValue: 85
225
- });
226
- ```
41
+ ## Custom content
227
42
 
228
- ### Educational Tools
229
43
  ```javascript
230
- // Interactive Learning Scenarios
231
- const educationGenerator = new RPGEventGenerator({
232
- theme: 'historical',
233
- culture: 'educational'
234
- });
235
-
236
- const lesson = educationGenerator.generateEvent({
237
- subject: 'history',
238
- difficulty: 'intermediate',
239
- learningObjectives: ['critical_thinking', 'decision_making']
240
- });
241
- ```
242
-
243
- ### Research & Data Simulation
244
- ```javascript
245
- // User Behavior Modeling
246
- const researchGenerator = new RPGEventGenerator({
247
- enableRelationships: true,
248
- enableModifiers: true
249
- });
250
-
251
- const simulation = researchGenerator.generateEvent({
252
- userType: 'research_subject',
253
- conditions: ['experimental', 'controlled'],
254
- variables: ['time_pressure', 'cognitive_load']
255
- });
256
- ```
257
-
258
- ## 🆕 Latest Features (v4.0.0)
259
-
260
- ### Complete GeneratorCore Rebuild
261
- The core event generation system has been completely rebuilt to provide truly infinite event variety:
262
-
263
- - **1,870+ Unique Narrative Elements**: Expanded from 8 titles/5 descriptions/4 choices to 50+ titles/30+ descriptions/30+ choices per event type
264
- - **Perfect Thematic Matching**: Choices now perfectly align with event descriptions (e.g., scouting descriptions get military choices)
265
- - **Enhanced Context Integration**: Dynamic contextual phrases based on location (70% rate), weather (60% rate), time of day (50% rate), and class/race (40% rate)
266
- - **Proven Variety**: 100% unique titles, 98% unique descriptions in 50-event batches
267
- - **Multi-Theme Support**: Custom content from any theme is automatically discovered and used
268
- - **Simplified Architecture**: Replaced Markov chain generation with direct content mapping for more reliable, coherent output (Markov chains still available via `pureMarkovMode` option)
269
-
270
- ### Example Output
271
- ```javascript
272
- // Before: Generic, repetitive
273
- Title: "Dangerous Encounter"
274
- Description: "A situation presents itself."
275
- Choices: ["Fight bravely", "Use strategy"]
276
-
277
- // After: Rich, contextual, unique
278
- Title: "Scouts' Vital Intelligence"
279
- Description: "Beneath the stormy downpour, scouts range ahead of main forces, mapping terrain and reporting enemy positions with deadly accuracy."
280
- Choices: ["Report findings", "Set up ambush", "Gather more intelligence", "Return to base"]
281
- ```
282
-
283
- ## Previous Features (v3.1.0)
284
-
285
- ### Database Integration
286
- Store and retrieve templates from databases for large-scale applications:
287
-
288
- ```javascript
289
- const generator = new RPGEventGenerator({ enableDatabase: true });
290
-
291
- await generator.storeTemplateInDatabase(customTemplate);
292
- const retrieved = await generator.getTemplateFromDatabase('template_id');
293
- const searchResults = await generator.searchTemplatesInDatabase({ type: 'combat' });
294
- ```
295
-
296
- ### World Building System
297
- Generate entire game worlds with factions, regions, and historical events:
298
-
299
- ```javascript
300
- const world = await generator.generateWorld();
301
- await generator.simulateWorldYears(50); // Advance world history
302
- const factionPower = generator.getFactionPowerRanking();
303
- ```
304
-
305
- ### Advanced Template Features
306
- Create complex, conditional templates with inheritance and composition:
307
-
308
- ```javascript
309
- // Conditional templates
310
- const conditionalTemplate = {
311
- id: 'level_based_event',
312
- conditions: [{ type: 'stat_requirement', field: 'level', operator: 'gte', value: 10 }],
313
- conditional_choices: [{
314
- condition: { type: 'has_item', item: 'magic_sword' },
315
- choice: { text: 'Use magic sword', effect: { damage: 50 } }
316
- }]
317
- };
318
-
319
- // Template composition
320
- const composedTemplate = {
321
- id: 'weather_merchant',
322
- composition: [{
323
- template_id: 'merchant_base',
324
- merge_strategy: 'append_narrative'
325
- }, {
326
- template_id: 'weather_effects',
327
- conditions: [{ type: 'random_chance', probability: 0.6 }]
328
- }]
329
- };
330
- ```
331
-
332
- ### Performance Optimizations
333
- Handle large-scale generation with advanced caching and parallel processing:
334
-
335
- ```javascript
336
- const generator = new RPGEventGenerator({
337
- enableTemplateCaching: true,
338
- enableEventCaching: true
339
- });
340
-
341
- // Generate events in parallel
342
- const events = await generator.generateEventsParallel(100, context, 4); // 4 threads
343
- // Generate in batches for memory efficiency
344
- const batchedEvents = generator.generateEventsBatched(1000, context, 50); // 50 events per batch
345
- ```
346
-
347
- ## 🎮 Demo
348
-
349
- Run the included demo to explore all features:
350
-
351
- ```bash
352
- # Using npm script (recommended)
353
- npm run demo
354
-
355
- # Direct script call
356
- node demo.js
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');
357
49
  ```
358
50
 
359
- This will demonstrate event generation, chains, time progression, customization, and more.
360
-
361
- ## 📚 Documentation & Resources
51
+ Use structured objects (`titles`, `descriptions`, `choices`). Raw string arrays are ignored in v4.
362
52
 
363
- ### 📖 Documentation
364
- - **Wiki Available**: Comprehensive guides, tutorials, and examples available on the [GitHub Wiki](https://github.com/ContextWeaver/context-weaver/wiki)
365
- - **API Documentation**: Complete TypeDoc reference available on [GitHub Pages](https://contextweaver.github.io/context-weaver/)
53
+ ## Feature tiers
366
54
 
367
- ### 🛠️ Development & Testing
368
- - Run `npm run demo` to see all 30+ features in action
369
- - Run `npm run docs` to regenerate API documentation
370
- - Run `npm test` to execute the comprehensive test suite
371
- - Check the `demo.js` file for interactive examples
372
- - Check the `test/` directory for usage examples
55
+ **Start with Tier 1.** Everything else is optional.
373
56
 
374
- ### 📂 Key Directories
375
- - `src/` - Modular TypeScript source code
376
- - `docs/` - Complete documentation and guides
377
- - `templates/` - Built-in event templates
378
- - `test/` - Comprehensive test suite
379
- - `scripts/` - Build and export scripts
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 |
380
62
 
381
- ## 🤝 Contributing
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.
382
64
 
383
- We welcome contributions! Please feel free to submit issues, feature requests, and pull requests.
65
+ ## Documentation
384
66
 
385
- ### Development Setup
67
+ Full guides ship with the repo — no wiki required.
386
68
 
387
- ```bash
388
- # Clone the repository
389
- git clone https://github.com/ContextWeaver/context-weaver.git
390
- cd context-weaver
391
-
392
- # Install dependencies
393
- npm install
394
-
395
- # Run tests
396
- npm test
397
-
398
- # Run demo
399
- npm run demo
400
-
401
- # Build for distribution
402
- npm run build
403
- ```
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 |
404
79
 
405
- ## 📄 License
80
+ Build locally: `npm run docs` → open `docs/index.html`
406
81
 
407
- 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
408
85
 
409
- ---
86
+ ## License
410
87
 
411
- **Generate infinite possibilities with RPG Event Generator!** 🎲✨
88
+ MIT see [LICENSE](LICENSE).