rpg-event-generator 1.2.4 → 1.2.6

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/demo.js +491 -0
  2. package/package.json +3 -1
package/demo.js ADDED
@@ -0,0 +1,491 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * RPG Event Generator v1.2.0 - Complete Feature Showcase
5
+ * Run with: node demo.js
6
+ *
7
+ * This demo showcases ALL features from v1.0.0 AND v1.2.0:
8
+ *
9
+ * 🌟 ORIGINAL v1.0.0 FEATURES:
10
+ * ⚔ Basic Event Generation
11
+ * šŸŽÆ Context-Aware Events
12
+ * šŸ“š Custom Training Data
13
+ * 🧩 Modular Event System
14
+ * šŸ“Š Dynamic Difficulty Scaling
15
+ * ā›“ļø Event Chains
16
+ * ā° Time-Based Events
17
+ * šŸ’¾ Game State Management
18
+ *
19
+ * šŸš€ ENHANCED v1.2.0 FEATURES:
20
+ * šŸŒ Multi-Language Support
21
+ * šŸŒ¤ļø Environmental Modifiers
22
+ * šŸ”— Event Dependencies
23
+ * šŸ‘„ NPC Relationships
24
+ * šŸŽ­ Combined Feature Usage
25
+ */
26
+
27
+ const { RPGEventGenerator } = require('./dist/index.js');
28
+
29
+ console.log('šŸŽ® RPG Event Generator v1.2.0 - Complete Feature Showcase\n');
30
+
31
+ // ================================
32
+ // ⚔ ORIGINAL v1.0.0: BASIC EVENT GENERATION
33
+ // ================================
34
+ console.log('⚔ Demo 1: Basic Event Generation (v1.0.0)');
35
+
36
+ const basicGenerator = new RPGEventGenerator();
37
+ const basicEvent = basicGenerator.generateEvent();
38
+ console.log(`Basic Event: ${basicEvent.title}`);
39
+ console.log(`Type: ${basicEvent.type}, Difficulty: ${basicEvent.difficulty}`);
40
+ console.log(`Choices: ${basicEvent.choices.length} options`);
41
+ console.log(`Sample choice: "${basicEvent.choices[0].text}"`);
42
+ console.log();
43
+
44
+ // ================================
45
+ // šŸ“Š ORIGINAL v1.0.0: DYNAMIC DIFFICULTY SCALING
46
+ // ================================
47
+ console.log('šŸ“Š Demo 2: Dynamic Difficulty Scaling (v1.0.0)');
48
+
49
+ // Weak character
50
+ const weakling = {
51
+ gold: 50,
52
+ influence: 10,
53
+ skills: { combat: 20 }
54
+ };
55
+ const easyEvent = basicGenerator.generateEvent(weakling);
56
+ console.log(`Weak character event: ${easyEvent.title} (${easyEvent.difficulty})`);
57
+
58
+ // Powerful character
59
+ const hero = {
60
+ gold: 50000,
61
+ influence: 500,
62
+ skills: { combat: 100, diplomacy: 80 },
63
+ relationships: [{ name: 'King', type: 'ally', relationship: 80 }]
64
+ };
65
+ const hardEvent = basicGenerator.generateEvent(hero);
66
+ console.log(`Powerful character event: ${hardEvent.title} (${hardEvent.difficulty})`);
67
+ console.log();
68
+
69
+ // ================================
70
+ // šŸŽÆ ORIGINAL v1.0.0: CONTEXT-AWARE EVENTS
71
+ // ================================
72
+ console.log('šŸŽÆ Demo 3: Context-Aware Events (v1.0.0)');
73
+
74
+ const playerContext = {
75
+ age: 35,
76
+ gold: 2500,
77
+ influence: 40,
78
+ reputation: 25,
79
+ career: 'noble',
80
+ skills: { diplomacy: 70, combat: 45, intrigue: 30 },
81
+ relationships: [
82
+ { name: 'Lord Harrington', type: 'ally', relationship: 60 }
83
+ ],
84
+ location: 'capital',
85
+ season: 'winter'
86
+ };
87
+
88
+ const contextEvent = basicGenerator.generateEvent(playerContext);
89
+ console.log(`Context-aware event: ${contextEvent.title}`);
90
+ console.log(`Generated for: ${playerContext.career} in ${playerContext.location} during ${playerContext.season}`);
91
+ console.log();
92
+
93
+ // ================================
94
+ // šŸ“š ORIGINAL v1.0.0: CUSTOM TRAINING DATA
95
+ // ================================
96
+ console.log('šŸ“š Demo 4: Custom Training Data (v1.0.0)');
97
+
98
+ const customTrainingGenerator = new RPGEventGenerator();
99
+ customTrainingGenerator.addTrainingData([
100
+ 'The ancient dragon hoards glittering treasures in its mountain lair',
101
+ 'Mystical runes glow with ethereal blue light in the dark chamber',
102
+ 'The enchanted forest whispers secrets to those who listen carefully',
103
+ 'Crystal caverns sparkle with magical energy and hidden dangers'
104
+ ]);
105
+
106
+ const customEvent = customTrainingGenerator.generateEvent();
107
+ console.log(`Custom training event: ${customEvent.title}`);
108
+ console.log(`Description: ${customEvent.description.substring(0, 100)}...`);
109
+ console.log();
110
+
111
+ // ================================
112
+ // 🧩 ORIGINAL v1.0.0: MODULAR EVENT SYSTEM
113
+ // ================================
114
+ console.log('🧩 Demo 5: Modular Event System (v1.0.0)');
115
+
116
+ const modularGenerator = new RPGEventGenerator();
117
+
118
+ const customTemplate = {
119
+ title: 'Mystic Vision',
120
+ narrative: 'You experience a vivid prophetic dream showing future events.',
121
+ choices: [
122
+ {
123
+ text: 'Seek out the prophecy',
124
+ effect: { wisdom: 15, risk: 20 },
125
+ consequence: 'visionary'
126
+ },
127
+ {
128
+ text: 'Dismiss it as a dream',
129
+ effect: { stress: -10 },
130
+ consequence: 'skeptical'
131
+ }
132
+ ]
133
+ };
134
+
135
+ modularGenerator.registerEventTemplate('MYSTIC_VISION', customTemplate);
136
+ modularGenerator.addCustomTrainingData([
137
+ 'The ancient prophecy foretells of great change',
138
+ 'Mystic visions reveal hidden truths to the worthy',
139
+ 'Dreams of the future guide the destinies of heroes'
140
+ ], 'mystical');
141
+
142
+ const modularEvent = modularGenerator.generateEvent();
143
+ console.log(`Modular system event: ${modularEvent.title}`);
144
+
145
+ // Test export/import
146
+ const exportedContent = modularGenerator.exportCustomContent();
147
+ console.log(`Exported ${Object.keys(exportedContent.templates).length} templates`);
148
+
149
+ const newGenerator = new RPGEventGenerator();
150
+ const importResult = newGenerator.importCustomContent(exportedContent);
151
+ console.log(`Imported ${importResult.templates.success} templates`);
152
+ console.log();
153
+
154
+ // ================================
155
+ // ā›“ļø ORIGINAL v1.0.0: EVENT CHAINS
156
+ // ================================
157
+ console.log('ā›“ļø Demo 6: Event Chains (v1.0.0)');
158
+
159
+ const chainGenerator = new RPGEventGenerator();
160
+
161
+ const chainResult = chainGenerator.startChain('BANDIT_RISING');
162
+ console.log(`Started chain: ${chainResult.title}`);
163
+ console.log(`Available choices in this event lead to different consequences...`);
164
+
165
+ // To advance the chain, we need to choose the option that leads to the 'bandit' consequence
166
+ const nextEvent = chainGenerator.advanceChain(chainResult.chainId, 'bandit');
167
+ if (nextEvent) {
168
+ console.log(`Chain advanced: ${nextEvent.title}`);
169
+ } else {
170
+ console.log(`Chain could not advance - need to choose 'bandit' consequence first`);
171
+ }
172
+
173
+ const activeChains = chainGenerator.getActiveChains();
174
+ console.log(`Active chains: ${activeChains.length}`);
175
+ console.log();
176
+
177
+ // ================================
178
+ // ā° ORIGINAL v1.0.0: TIME-BASED EVENTS
179
+ // ================================
180
+ console.log('ā° Demo 7: Time-Based Events (v1.0.0)');
181
+
182
+ const timeGenerator = new RPGEventGenerator();
183
+
184
+ const dueEvents = timeGenerator.advanceGameDay();
185
+ console.log(`Advanced to day ${timeGenerator.getCurrentTime().day}, season: ${timeGenerator.getCurrentTime().season}`);
186
+
187
+ timeGenerator.startTimeBasedChain('POLITICAL_UPRISING');
188
+ const activeTimeChains = timeGenerator.getActiveTimeChains();
189
+ console.log(`Active time-based chains: ${activeTimeChains.length}`);
190
+
191
+ const timeEvent = timeGenerator.generateTimeAwareEvent({ season: 'spring' });
192
+ console.log(`Season-aware event: ${timeEvent.title}`);
193
+ console.log();
194
+
195
+ // ================================
196
+ // šŸ’¾ ORIGINAL v1.0.0: GAME STATE MANAGEMENT
197
+ // ================================
198
+ console.log('šŸ’¾ Demo 8: Game State Management (v1.0.0)');
199
+
200
+ const stateGenerator = new RPGEventGenerator();
201
+
202
+ // Save state
203
+ const gameState = {
204
+ player: { level: 5, gold: 1000 },
205
+ completedEvents: new Set(['tutorial']),
206
+ currentDay: 10
207
+ };
208
+
209
+ stateGenerator.loadGameState(gameState);
210
+ const savedState = stateGenerator.getGameState();
211
+ console.log(`Game state loaded and saved successfully`);
212
+ console.log(`Current day: ${savedState.timeSystem.currentDay}, Season: ${savedState.timeSystem.currentSeason}`);
213
+ console.log(`Active chains: ${savedState.activeChains.length}`);
214
+ console.log();
215
+
216
+ // ================================
217
+ // šŸš€ ENHANCED v1.2.0 FEATURES START HERE
218
+ // ================================
219
+ console.log('šŸš€ ENHANCED FEATURES (v1.2.0)\n');
220
+
221
+ const generator = new RPGEventGenerator({
222
+ enableModifiers: true,
223
+ enableRelationships: true,
224
+ enableDependencies: true,
225
+ language: 'en'
226
+ });
227
+
228
+ // ================================
229
+ // šŸŒ MULTI-LANGUAGE SUPPORT
230
+ // ================================
231
+ console.log('šŸŒ Demo 1: Multi-Language Support');
232
+
233
+ // Load multiple language packs
234
+ generator.loadLanguagePack('es', {
235
+ ui: {
236
+ 'event.title.default': 'Evento Inesperado',
237
+ 'choice.fight': 'Luchar',
238
+ 'choice.flee': 'Huir',
239
+ 'choice.negotiate': 'Negociar'
240
+ },
241
+ culture: {
242
+ nameFormats: ['western'],
243
+ currencySymbols: ['oro']
244
+ }
245
+ });
246
+
247
+ generator.loadLanguagePack('fr', {
248
+ ui: {
249
+ 'event.title.default': 'ƉvĆ©nement Inattendu',
250
+ 'choice.fight': 'Combattre',
251
+ 'choice.flee': 'Fuire',
252
+ 'choice.negotiate': 'NƩgocier'
253
+ }
254
+ });
255
+
256
+ // Test language switching
257
+ console.log('English:', generator.translate('choice.fight'));
258
+ generator.setLanguage('es');
259
+ console.log('Spanish:', generator.translate('choice.fight'));
260
+ generator.setLanguage('fr');
261
+ console.log('French:', generator.translate('choice.fight'));
262
+ generator.setLanguage('en'); // Back to English
263
+ console.log();
264
+
265
+ // ================================
266
+ // šŸŒ¤ļø ENVIRONMENTAL MODIFIERS
267
+ // ================================
268
+ console.log('šŸŒ¤ļø Demo 2: Environmental Modifiers');
269
+
270
+ // Test individual modifiers
271
+ console.log('Individual Modifiers:');
272
+ generator.setEnvironmentalContext({ weather: 'rain' });
273
+ const rainEvent = generator.generateEnhancedEvent();
274
+ console.log(`Rain Event: ${rainEvent.title}`);
275
+ console.log(`Description contains atmospheric text: ${rainEvent.description.includes('gloomy')}`);
276
+
277
+ generator.setEnvironmentalContext({ season: 'winter' });
278
+ const winterEvent = generator.generateEnhancedEvent();
279
+ console.log(`Winter Event: ${winterEvent.title}`);
280
+ console.log(`Description contains seasonal text: ${winterEvent.description.includes('bleak')}`);
281
+
282
+ // Test combined modifiers
283
+ console.log('\nCombined Modifiers:');
284
+ const testEvent = {
285
+ title: 'Test Event',
286
+ description: 'Testing modifier effects.',
287
+ choices: [{
288
+ text: 'Continue',
289
+ effect: { health: 10, gold: 50 }
290
+ }]
291
+ };
292
+
293
+ generator.setEnvironmentalContext({ weather: 'storm', season: 'winter' });
294
+ const modifiedEvent = generator.applyModifiers(testEvent);
295
+ console.log(`Original health: ${testEvent.choices[0].effect.health}`);
296
+ console.log(`Modified health: ${modifiedEvent.choices[0].effect.health} (storm: -5, winter: *1.5 = 7)`);
297
+ console.log(`Modified gold: ${modifiedEvent.choices[0].effect.gold} (unchanged)`);
298
+ console.log();
299
+
300
+ // ================================
301
+ // šŸ”— EVENT DEPENDENCIES
302
+ // ================================
303
+ console.log('šŸ”— Demo 3: Event Dependencies');
304
+
305
+ // Simple dependency
306
+ generator.registerEventDependency('ROYAL_BALL', {
307
+ type: 'event_completed',
308
+ eventId: 'COURT_INTRODUCTION'
309
+ });
310
+
311
+ // Complex AND dependency
312
+ generator.registerEventDependency('ELITE_MISSION', {
313
+ operator: 'AND',
314
+ conditions: [
315
+ { type: 'stat_requirement', stat: 'level', min: 10 },
316
+ { type: 'event_completed', eventId: 'BASIC_TRAINING' },
317
+ { type: 'stat_requirement', stat: 'reputation', min: 50 }
318
+ ]
319
+ });
320
+
321
+ // Complex OR dependency
322
+ generator.registerEventDependency('SOCIAL_EVENT', {
323
+ operator: 'OR',
324
+ conditions: [
325
+ { type: 'stat_requirement', stat: 'reputation', min: 75 },
326
+ { type: 'stat_requirement', stat: 'gold', min: 1000 },
327
+ { type: 'relationship_requirement', npc: 'nobleman', min: 60 }
328
+ ]
329
+ });
330
+
331
+ // Test dependencies
332
+ const dependencyGameState = {
333
+ completedEvents: new Set(['COURT_INTRODUCTION', 'BASIC_TRAINING']),
334
+ player: { level: 12, reputation: 80, gold: 500 }
335
+ };
336
+
337
+ console.log('Dependency Checks:');
338
+ console.log(`Can access Royal Ball: ${generator.checkEventDependencies('ROYAL_BALL', dependencyGameState)}`);
339
+ console.log(`Can access Elite Mission: ${generator.checkEventDependencies('ELITE_MISSION', dependencyGameState)}`);
340
+ console.log(`Can access Social Event: ${generator.checkEventDependencies('SOCIAL_EVENT', dependencyGameState)}`);
341
+ console.log();
342
+
343
+ // ================================
344
+ // šŸ‘„ NPC RELATIONSHIPS
345
+ // ================================
346
+ console.log('šŸ‘„ Demo 4: NPC Relationships');
347
+
348
+ // Add multiple NPCs
349
+ generator.addNPC({
350
+ id: 'merchant_sam',
351
+ name: 'Merchant Sam',
352
+ type: 'merchant'
353
+ });
354
+
355
+ generator.addNPC({
356
+ id: 'guard_captain',
357
+ name: 'Captain Valeria',
358
+ type: 'guard'
359
+ });
360
+
361
+ generator.addNPC({
362
+ id: 'nobleman',
363
+ name: 'Lord Harrington',
364
+ type: 'noble'
365
+ });
366
+
367
+ // Test relationship interactions
368
+ console.log('Relationship Interactions:');
369
+
370
+ let samRel = generator.getRelationship('merchant_sam', 'player');
371
+ console.log(`Initial relationship with Merchant Sam: ${samRel?.strength || 0}`);
372
+
373
+ generator.applyRelationshipRule('merchant_sam', 'player', 'save_life');
374
+ samRel = generator.getRelationship('merchant_sam', 'player');
375
+ console.log(`After saving life: ${samRel?.strength || 0}`);
376
+
377
+ generator.updateRelationship('guard_captain', 'player', -15, 'minor dispute');
378
+ let guardRel = generator.getRelationship('guard_captain', 'player');
379
+ console.log(`Guard Captain relationship: ${guardRel?.strength || 0}`);
380
+
381
+ generator.applyRelationshipRule('nobleman', 'player', 'help_combat');
382
+ let nobleRel = generator.getRelationship('nobleman', 'player');
383
+ console.log(`Nobleman relationship: ${nobleRel?.strength || 0}`);
384
+
385
+ // Test relationship summary
386
+ const samSummary = generator.getRelationshipSummary('merchant_sam');
387
+ console.log(`\nMerchant Sam has ${samSummary.totalRelationships} relationships`);
388
+ console.log(`Average relationship strength: ${samSummary.averageStrength.toFixed(1)}`);
389
+ console.log();
390
+
391
+ // ================================
392
+ // šŸŽ­ COMBINED FEATURE USAGE
393
+ // ================================
394
+ console.log('šŸŽ­ Demo 5: Combined Feature Usage');
395
+
396
+ const comprehensiveContext = {
397
+ player: {
398
+ id: 'player',
399
+ level: 15,
400
+ reputation: 70,
401
+ gold: 2000
402
+ },
403
+ environment: {
404
+ weather: 'rain',
405
+ season: 'spring',
406
+ timeOfDay: 'dawn'
407
+ },
408
+ gameState: {
409
+ completedEvents: new Set(['TUTORIAL', 'FIRST_QUEST']),
410
+ relationships: {
411
+ merchant_sam: { strength: 45, type: 'friend' }
412
+ }
413
+ }
414
+ };
415
+
416
+ console.log('Generating event with ALL features combined:');
417
+ const comprehensiveEvent = generator.generateEnhancedEvent(comprehensiveContext);
418
+ console.log(`Title: ${comprehensiveEvent.title}`);
419
+ console.log(`Has environmental modifications: ${comprehensiveEvent.appliedModifiers?.length > 0}`);
420
+ console.log(`Choices: ${comprehensiveEvent.choices.length}`);
421
+ console.log();
422
+
423
+ // ================================
424
+ // šŸ”„ BACKWARD COMPATIBILITY
425
+ // ================================
426
+ console.log('šŸ”„ Demo 6: Backward Compatibility');
427
+
428
+ // Test with no enhanced features
429
+ const legacyGenerator = new RPGEventGenerator();
430
+ const legacyEvent = legacyGenerator.generateEvent();
431
+ console.log(`Basic generator works: ${legacyEvent.title}`);
432
+
433
+ // Test with some features disabled
434
+ const partialGenerator = new RPGEventGenerator({
435
+ enableModifiers: false,
436
+ enableRelationships: true,
437
+ enableDependencies: false
438
+ });
439
+ const partialEvent = partialGenerator.generateEvent();
440
+ console.log(`Partial features work: ${partialEvent.title}`);
441
+
442
+ // Test old API still works
443
+ const oldApiGenerator = new RPGEventGenerator({
444
+ theme: 'fantasy',
445
+ culture: 'norse'
446
+ });
447
+ const oldApiEvent = oldApiGenerator.generateEvent();
448
+ console.log(`Legacy API works: ${oldApiEvent.title}`);
449
+ console.log();
450
+
451
+ // ================================
452
+ // šŸ“Š SYSTEM STATUS
453
+ // ================================
454
+ console.log('šŸ“Š Demo 7: System Status');
455
+ const status = generator.getSystemStatus();
456
+ console.log(`Current language: ${status.language}`);
457
+ console.log(`Available languages: ${status.availableLanguages.join(', ')}`);
458
+ console.log(`Modifiers enabled: ${status.modifiersEnabled}`);
459
+ console.log(`Relationships enabled: ${status.relationshipsEnabled}`);
460
+ console.log(`Dependencies enabled: ${status.dependenciesEnabled}`);
461
+ console.log(`Total NPCs: ${status.totalNPCs}`);
462
+ console.log();
463
+
464
+ // ================================
465
+ // šŸŽÆ ADVANCED USAGE EXAMPLES
466
+ // ================================
467
+ console.log('šŸŽÆ Demo 8: Advanced Usage Examples');
468
+
469
+ // Custom modifier
470
+ generator.registerModifier('festival', {
471
+ type: 'event',
472
+ effects: { mood_bonus: 20 },
473
+ text_modifiers: {
474
+ atmosphere: 'festive',
475
+ add_descriptors: ['celebratory', 'joyful']
476
+ }
477
+ });
478
+
479
+ // Time-based effects
480
+ console.log('Time progression:');
481
+ generator.advanceTime(30); // Advance 30 days
482
+ console.log(`New season: ${generator.timeSystem.currentSeason}`);
483
+
484
+ // Relationship network
485
+ const network = generator.getRelationshipNetwork('merchant_sam', 2);
486
+ console.log(`Merchant Sam's relationship network: ${network.nodes.size} nodes, ${network.edges.length} connections`);
487
+
488
+ console.log('\nāœ… COMPREHENSIVE DEMO COMPLETE!');
489
+ console.log('šŸŽ‰ All enhanced features demonstrated successfully!');
490
+ console.log('šŸ“¦ Version 1.2.0 delivers powerful new capabilities while maintaining full backward compatibility.');
491
+ console.log('šŸš€ Ready for future enhancements and releases!');
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "rpg-event-generator",
3
- "version": "1.2.4",
3
+ "version": "1.2.6",
4
4
  "description": "Procedural RPG event generation system for games",
5
5
  "main": "dist/index.js",
6
6
  "files": [
7
7
  "dist/",
8
+ "demo.js",
8
9
  "README.md",
9
10
  "LICENSE"
10
11
  ],
@@ -45,6 +46,7 @@
45
46
  ],
46
47
  "author": "decept1kon",
47
48
  "license": "MIT",
49
+ "homepage": "https://rpgevents.netlify.app/",
48
50
  "dependencies": {
49
51
  "chance": "^1.1.13"
50
52
  },