playlist-data-engine 1.7.3 → 1.8.0

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 (35) hide show
  1. package/README.md +14 -0
  2. package/bin/cli.cjs +85 -0
  3. package/dist/gateway-CDMPqFEH.js +1320 -0
  4. package/dist/gateway-DKa45Uz6.cjs +6 -0
  5. package/dist/gateway.d.ts +1 -0
  6. package/dist/gateway.d.ts.map +1 -1
  7. package/dist/gateway.js +1 -1
  8. package/dist/gateway.mjs +22 -19
  9. package/dist/index.d.ts +1 -0
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/playlist-data-engine.js +4 -4
  12. package/dist/playlist-data-engine.mjs +30 -27
  13. package/dist/utils/engineDocs.d.ts +33 -0
  14. package/dist/utils/engineDocs.d.ts.map +1 -0
  15. package/docs/DATA_ENGINE_REFERENCE.md +6660 -0
  16. package/docs/USAGE_IN_OTHER_PROJECTS.md +587 -0
  17. package/docs/features/AUDIO_ANALYSIS.md +610 -0
  18. package/docs/features/BEAT_DETECTION.md +5250 -0
  19. package/docs/features/COMBAT_SYSTEM.md +1632 -0
  20. package/docs/features/CONTENT_PACKS.md +464 -0
  21. package/docs/features/CUSTOM_CONTENT.md +603 -0
  22. package/docs/features/ENEMY_GENERATION.md +1711 -0
  23. package/docs/features/EQUIPMENT_SYSTEM.md +2279 -0
  24. package/docs/features/EXTENSIBILITY_GUIDE.md +1106 -0
  25. package/docs/features/GATEWAY_RESOLUTION.md +725 -0
  26. package/docs/features/IRL_SENSORS.md +360 -0
  27. package/docs/features/PLAYLIST_PARSING.md +446 -0
  28. package/docs/features/PREREQUISITES.md +571 -0
  29. package/docs/features/ROLLS_AND_SEEDS.md +687 -0
  30. package/docs/features/XP_AND_STATS.md +1221 -0
  31. package/llms.txt +33 -0
  32. package/package.json +9 -2
  33. package/skills/playlist-data-engine/SKILL.md +69 -0
  34. package/dist/gateway-C_p9Ku3O.js +0 -1211
  35. package/dist/gateway-Ceg-5xug.cjs +0 -1
@@ -0,0 +1,464 @@
1
+ # Content Packs Guide
2
+
3
+ This guide explains how to create and manage content packs for the Playlist Data Engine. A content pack is a collection of custom content for multiple categories that can be loaded at runtime, saved to files, and restored later.
4
+
5
+ ---
6
+
7
+ ## Table of Contents
8
+
9
+ 1. [Examples](#examples)
10
+ - [Basic Content Pack](#basic-content-pack)
11
+ - [Themed Content Pack](#themed-content-pack)
12
+ - [Complete Expansion Pack](#complete-expansion-pack)
13
+ - [Advanced: Prerequisites and Subraces](#advanced-prerequisites-and-subraces)
14
+ 2. [Saving and Loading Content Packs](#saving-and-loading-content-packs)
15
+ - [Save & Load Workflow](#save--load-workflow)
16
+ - [Debugging with Export](#debugging-with-export)
17
+ - [Batch Image Methods](#batch-image-methods)
18
+
19
+ ---
20
+
21
+ ## Examples
22
+
23
+ ### Basic Content Pack
24
+
25
+ A simple content pack with equipment, spells, races, and appearance options:
26
+
27
+ ```typescript
28
+ // my-content-pack.ts
29
+ import { ExtensionManager } from 'playlist-data-engine';
30
+
31
+ export function loadContentPack() {
32
+ const manager = ExtensionManager.getInstance();
33
+
34
+ // Custom equipment with spawn weights
35
+ manager.register('equipment', [
36
+ { name: 'Dragon Scale Armor', type: 'armor', rarity: 'very_rare', weight: 15, icon: '/icons/armor/dragon-scale.png' },
37
+ { name: 'Flame Tongue', type: 'weapon', rarity: 'rare', weight: 3, icon: '/icons/weapons/flame-tongue.png' }
38
+ ], {
39
+ weights: {
40
+ 'Dragon Scale Armor': 0.3,
41
+ 'Flame Tongue': 0.5
42
+ }
43
+ });
44
+
45
+ // Custom spells
46
+ manager.register('spells', [
47
+ { name: 'Dragon Breath', level: 3, school: 'Evocation', icon: '/icons/spells/dragon-breath.png' },
48
+ { name: 'Scale Hardening', level: 2, school: 'Transmutation', icon: '/icons/spells/scale-hardening.png' }
49
+ ]);
50
+
51
+ // Custom races
52
+ manager.register('races', ['Dragonborn', 'Dracophile']);
53
+
54
+ // Custom appearance
55
+ manager.register('appearance.skinTones', [
56
+ '#8B0000', // Dark red
57
+ '#DC143C', // Crimson
58
+ '#B22222' // Fire brick
59
+ ]);
60
+
61
+ manager.register('appearance.facialFeatures', [
62
+ 'scale patches',
63
+ 'reptilian eyes',
64
+ 'horn nubs'
65
+ ]);
66
+ }
67
+
68
+ // Usage:
69
+ import { loadContentPack } from './my-content-pack';
70
+
71
+ loadContentPack();
72
+
73
+ // Now generate characters with the content pack loaded
74
+ const character = CharacterGenerator.generate(
75
+ 'my-seed',
76
+ audioProfile,
77
+ track
78
+ );
79
+ ```
80
+
81
+ ---
82
+
83
+ ### Themed Content Pack
84
+
85
+ A dark fantasy themed pack using `absolute` mode to exclude default items:
86
+
87
+ ```typescript
88
+ // dark-fantasy-pack.ts
89
+ export function loadDarkFantasyPack() {
90
+ const manager = ExtensionManager.getInstance();
91
+
92
+ // Dark fantasy equipment - ONLY these items spawn
93
+ manager.register('equipment', [
94
+ { name: 'Soul Reaver', type: 'weapon', rarity: 'legendary', weight: 4, icon: '/icons/weapons/soul-reaver.png' },
95
+ { name: 'Shadow Cloak', type: 'armor', rarity: 'very_rare', weight: 5, icon: '/icons/armor/shadow-cloak.png' },
96
+ { name: 'Blood Chalice', type: 'item', rarity: 'rare', weight: 2, icon: '/icons/items/blood-chalice.png' }
97
+ ], {
98
+ mode: 'absolute', // Only dark fantasy items spawn
99
+ weights: {
100
+ 'Soul Reaver': 0.2,
101
+ 'Shadow Cloak': 0.5,
102
+ 'Blood Chalice': 1.0
103
+ }
104
+ });
105
+
106
+ // Dark fantasy spells
107
+ manager.register('spells', [
108
+ { name: 'Soul Drain', level: 4, school: 'Necromancy', icon: '/icons/spells/soul-drain.png' },
109
+ { name: 'Shadow Step', level: 2, school: 'Conjuration', icon: '/icons/spells/shadow-step.png' },
110
+ { name: 'Death Coil', level: 3, school: 'Necromancy', icon: '/icons/spells/death-coil.png' }
111
+ ]);
112
+
113
+ // Dark fantasy appearance
114
+ manager.register('appearance.skinTones', [
115
+ '#2F4F4F', // Dark slate gray
116
+ '#4B0082', // Indigo
117
+ '#696969' // Dim gray
118
+ ]);
119
+
120
+ manager.register('appearance.facialFeatures', [
121
+ 'undead eyes',
122
+ 'necrotic scars',
123
+ 'pale complexion'
124
+ ]);
125
+ }
126
+ ```
127
+
128
+ ---
129
+
130
+ ### Complete Expansion Pack
131
+
132
+ A comprehensive "Arctic Expansion Pack" with custom features, skills, and spawn rates:
133
+
134
+ ```typescript
135
+ import { ExtensionManager, FeatureQuery, SkillQuery, CharacterGenerator } from 'playlist-data-engine';
136
+
137
+ // Create an expansion pack with custom features, skills, and spawn rates
138
+ function registerArcticExpansionPack() {
139
+ const manager = ExtensionManager.getInstance();
140
+ const featureQuery = FeatureQuery.getInstance();
141
+ const skillQuery = SkillQuery.getInstance();
142
+
143
+ // ===== CUSTOM FEATURES =====
144
+ const frostRage = {
145
+ id: 'frost_rage',
146
+ name: 'Frost Rage',
147
+ description: 'Your rage radiates cold, dealing extra cold damage.',
148
+ type: 'active',
149
+ level: 3,
150
+ class: 'Barbarian',
151
+ effects: [
152
+ {
153
+ type: 'resource_grant',
154
+ target: 'cold_damage_bonus',
155
+ value: 3,
156
+ description: '+3 cold damage while raging'
157
+ }
158
+ ],
159
+ source: 'custom',
160
+ icon: '/icons/features/frost-rage.png'
161
+ };
162
+
163
+ const snowWalker = {
164
+ id: 'snow_walker',
165
+ name: 'Snow Walker',
166
+ description: 'You move through snow and ice without penalty.',
167
+ type: 'passive',
168
+ level: 1,
169
+ class: 'Ranger',
170
+ race: 'Human',
171
+ effects: [
172
+ {
173
+ type: 'ability_unlock',
174
+ target: 'snow_movement',
175
+ value: true,
176
+ description: 'No movement penalty in snow/ice'
177
+ },
178
+ {
179
+ type: 'passive_modifier',
180
+ target: 'survival_cold_bonus',
181
+ value: 5,
182
+ description: '+5 Survival in cold environments'
183
+ }
184
+ ],
185
+ source: 'custom',
186
+ icon: '/icons/features/snow-walker.png'
187
+ };
188
+
189
+ // ===== CUSTOM SKILLS =====
190
+ const coldSurvival = {
191
+ id: 'survival_cold',
192
+ name: 'Survival (Cold Environments)',
193
+ description: 'Expertise in cold weather survival.',
194
+ ability: 'WIS',
195
+ armorPenalty: true,
196
+ categories: ['exploration', 'environmental'],
197
+ source: 'custom',
198
+ icon: '/icons/skills/cold-survival.png'
199
+ };
200
+
201
+ const iceFishing = {
202
+ id: 'ice_fishing',
203
+ name: 'Ice Fishing',
204
+ description: 'Ability to catch fish in frozen waters.',
205
+ ability: 'WIS',
206
+ armorPenalty: false,
207
+ categories: ['exploration', 'survival'],
208
+ source: 'custom',
209
+ icon: '/icons/skills/ice-fishing.png'
210
+ };
211
+
212
+ // ===== REGISTER EVERYTHING =====
213
+ // Features
214
+ manager.register('classFeatures', [frostRage, snowWalker]);
215
+ manager.register('classFeatures.Barbarian', [frostRage], {
216
+ weights: { 'frost_rage': 0.5 } // Rare feature
217
+ });
218
+ manager.register('classFeatures.Ranger', [snowWalker], {
219
+ weights: { 'snow_walker': 0.7 }
220
+ });
221
+
222
+ // Skills
223
+ manager.register('skills', [coldSurvival, iceFishing]);
224
+ manager.register('skills.WIS', [coldSurvival, iceFishing], {
225
+ weights: {
226
+ 'survival_cold': 0.5,
227
+ 'ice_fishing': 0.3 // Quite rare
228
+ }
229
+ });
230
+
231
+ // ===== SPAWN RATE CONFIGURATION =====
232
+ manager.setWeights('skillLists.Ranger', {
233
+ 'survival_cold': 2.0, // Rangers love this skill
234
+ 'ice_fishing': 1.5
235
+ });
236
+
237
+ manager.setWeights('skillLists.Barbarian', {
238
+ 'survival_cold': 1.5,
239
+ 'ice_fishing': 0.5
240
+ });
241
+
242
+ console.log('Arctic Expansion Pack registered!');
243
+ }
244
+
245
+ // Register the expansion pack
246
+ registerArcticExpansionPack();
247
+
248
+ // Generate characters with the new content
249
+ const character = CharacterGenerator.generate(seed, audio, track, {forceName: 'Arctic Hero'});
250
+ // Character may now have frost_rage, snow_walker, or survival_cold skill!
251
+ ```
252
+
253
+ ---
254
+
255
+ ### Advanced: Prerequisites and Subraces
256
+
257
+ A complete content pack demonstrating advanced patterns: custom races with subraces, racial traits, and prerequisites for skills/spells:
258
+
259
+ ```typescript
260
+ import { ExtensionManager, asClass } from 'playlist-data-engine';
261
+
262
+ const manager = ExtensionManager.getInstance();
263
+
264
+ // 1. Register a custom race with subraces
265
+ manager.register('races.data', [{
266
+ race: 'Dragonkin',
267
+ ability_bonuses: { STR: 2, CON: 1, CHA: 1 },
268
+ speed: 30,
269
+ traits: ['Draconic Ancestry', 'Darkvision'],
270
+ subraces: ['Fire Dragonkin', 'Ice Dragonkin', 'Lightning Dragonkin'],
271
+ icon: '/icons/races/dragonkin.png'
272
+ }]);
273
+
274
+ manager.register('races', ['Dragonkin']);
275
+
276
+ // 2. Register subrace-specific racial traits
277
+ manager.register('racialTraits', [{
278
+ id: 'fire_dragonkin_fire_resistance',
279
+ name: 'Fire Resistance',
280
+ description: 'You have resistance to fire damage.',
281
+ race: 'Dragonkin',
282
+ subrace: 'Fire Dragonkin',
283
+ prerequisites: { subrace: 'Fire Dragonkin' },
284
+ effects: [
285
+ { type: 'ability_unlock', target: 'fire_resistance', value: true }
286
+ ],
287
+ source: 'custom',
288
+ icon: '/icons/traits/fire-resistance.png'
289
+ }]);
290
+
291
+ // Cache is automatically invalidated after registration
292
+
293
+ // 3. Register a skill with prerequisites (feature + level + class)
294
+ manager.register('skills.INT', [{
295
+ id: 'dragon_smithing',
296
+ name: 'Dragon Smithing',
297
+ description: 'Craft weapons from dragon scales',
298
+ ability: 'INT',
299
+ prerequisites: {
300
+ features: ['draconic_bloodline'],
301
+ level: 5,
302
+ class: asClass('Sorcerer')
303
+ },
304
+ source: 'custom',
305
+ icon: '/icons/skills/dragon-smithing.png'
306
+ }]);
307
+
308
+ // Cache is automatically invalidated after registration
309
+
310
+ // 4. Register a spell with prerequisites
311
+ manager.register('spells', [{
312
+ id: 'dragon_breath',
313
+ name: 'Dragon Breath',
314
+ level: 3,
315
+ school: 'Evocation',
316
+ casting_time: '1 action',
317
+ range: '60 ft cone',
318
+ components: ['V', 'S', 'M'],
319
+ duration: 'Instantaneous',
320
+ description: 'Exhale destructive energy',
321
+ prerequisites: {
322
+ features: ['dragon_bloodline'],
323
+ abilities: { CHA: 16 }
324
+ },
325
+ icon: '/icons/spells/dragon-breath.png'
326
+ }]);
327
+ ```
328
+
329
+ ---
330
+
331
+ ## Saving and Loading Content Packs
332
+
333
+ The `ExtensionManager` provides methods to export and import custom data, allowing you to save and restore content packs.
334
+
335
+ ### Save & Load Workflow
336
+
337
+ Complete workflow for saving content packs to file and loading them later:
338
+
339
+ ```typescript
340
+ import { readFileSync, writeFileSync } from 'fs';
341
+ import { ExtensionManager, type ContentPackData } from 'playlist-data-engine';
342
+
343
+ const manager = ExtensionManager.getInstance();
344
+
345
+ // ===== SAVING =====
346
+ // Register some custom content
347
+ manager.register('equipment', [
348
+ { name: 'Dragon Sword', type: 'weapon', rarity: 'rare', weight: 5, icon: '/icons/weapons/dragon-sword.png' }
349
+ ], {
350
+ weights: { 'Dragon Sword': 0.5 }
351
+ });
352
+
353
+ // Export all custom data
354
+ const customData: ContentPackData = manager.exportCustomData();
355
+
356
+ // Output structure:
357
+ // {
358
+ // extensions: {
359
+ // equipment: {
360
+ // items: [{ name: 'Dragon Sword', ... }],
361
+ // options: { mode: 'relative', weights: {...} },
362
+ // registeredAt: '2024-01-15T10:30:00.000Z'
363
+ // }
364
+ // },
365
+ // weights: {
366
+ // equipment: { 'Dragon Sword': 0.5 }
367
+ // }
368
+ // }
369
+
370
+ // Save to file
371
+ writeFileSync('./my-content-pack.json', JSON.stringify(customData, null, 2));
372
+
373
+
374
+ // ===== LOADING =====
375
+ // Load from file
376
+ const savedData: ContentPackData = JSON.parse(readFileSync('./my-content-pack.json', 'utf-8'));
377
+
378
+ // Re-register each category
379
+ for (const [category, data] of Object.entries(savedData.extensions)) {
380
+ manager.register(category, data.items, {
381
+ ...data.options,
382
+ validate: true // Always validate when loading
383
+ });
384
+ }
385
+
386
+ // Restore weights
387
+ for (const [category, weights] of Object.entries(savedData.weights)) {
388
+ manager.setWeights(category, weights);
389
+ }
390
+ ```
391
+
392
+ ---
393
+
394
+ ### Debugging with Export
395
+
396
+ Use export to inspect registered content:
397
+
398
+ ```typescript
399
+ const manager = ExtensionManager.getInstance();
400
+
401
+ // Debug: Check what's registered
402
+ const data = manager.exportCustomData();
403
+
404
+ console.log('Registered categories:', Object.keys(data.extensions));
405
+ console.log('Equipment items:', data.extensions.equipment?.items.length);
406
+ console.log('Custom weights:', data.weights);
407
+ ```
408
+
409
+ ---
410
+
411
+ ### Batch Image Methods
412
+
413
+ Use batch methods to efficiently add icons and images to all items in a content pack:
414
+
415
+ ```typescript
416
+ import { ExtensionManager } from 'playlist-data-engine';
417
+
418
+ const manager = ExtensionManager.getInstance();
419
+
420
+ // Register content first (without icons)
421
+ manager.register('equipment', [
422
+ { name: 'Dragon Scale Armor', type: 'armor', rarity: 'very_rare', weight: 15 },
423
+ { name: 'Flame Tongue', type: 'weapon', rarity: 'rare', weight: 3 },
424
+ { name: 'Dragon Shield', type: 'shield', rarity: 'rare', weight: 5 }
425
+ ]);
426
+
427
+ // Add icons to specific items by name
428
+ manager.batchAddIcons('equipment', {
429
+ 'Dragon Scale Armor': '/icons/armor/dragon-scale.png',
430
+ 'Flame Tongue': '/icons/weapons/flame-tongue.png',
431
+ 'Dragon Shield': '/icons/shields/dragon-shield.png'
432
+ });
433
+
434
+ // Add larger images (portraits, cards, etc.)
435
+ manager.batchAddImages('equipment', {
436
+ 'Dragon Scale Armor': '/images/equipment/dragon-scale-armor.png'
437
+ });
438
+
439
+ // Add same icon to items matching a predicate
440
+ manager.batchUpdateImages('spells',
441
+ spell => spell.level === 0, // All cantrips
442
+ { icon: '/icons/spells/cantrip-icon.png' }
443
+ );
444
+
445
+ // Add icons based on a property value (by category)
446
+ manager.batchByCategory('spells', 'school', {
447
+ 'Evocation': '/icons/schools/fire.png',
448
+ 'Necromancy': '/icons/schools/skull.png',
449
+ 'Abjuration': '/icons/schools/shield.png'
450
+ // Also supports: Conjuration, Divination, Enchantment, Illusion, Transmutation
451
+ });
452
+
453
+ // Also works for equipment rarity
454
+ manager.batchByCategory('equipment', 'rarity', {
455
+ 'legendary': '/icons/rarity/star-gold.png',
456
+ 'very_rare': '/icons/rarity/star-purple.png',
457
+ 'rare': '/icons/rarity/star-blue.png'
458
+ // Also supports: uncommon, common
459
+ });
460
+ ```
461
+
462
+ ---
463
+
464
+ For more information on extensibility, see [EXTENSIBILITY_GUIDE.md](EXTENSIBILITY_GUIDE.md).