Extend the built-in library with structured training data. This is the recommended way to add game-specific events in v4.
const { RPGEventGenerator } = require('rpg-event-generator');
const generator = new RPGEventGenerator({ theme: 'fantasy' });
generator.addTrainingData({
titles: {
COMBAT: ['Epic Duel', 'Ambush at the Crossroads']
},
descriptions: {
COMBAT: [
'Two warriors circle each other, blades drawn.',
'Assassins leap from the shadows.'
]
},
choices: {
COMBAT: ['Fight', 'Flee', 'Negotiate', 'Call for backup']
}
}, 'my_theme');
const event = generator.generateEvent({ class: 'fighter' });
{
titles?: { [eventType: string]: string[] },
descriptions?: { [eventType: string]: string[] },
choices?: { [eventType: string]: string[] }
}
Event types match core types: ADVENTURE, COMBAT, ECONOMIC, EXPLORATION, GUILD, MAGIC, MYSTERY, POLITICAL, QUEST, SOCIAL, SPELLCASTING, SUPERNATURAL, TECHNOLOGICAL, UNDERWORLD.
See Event Types for the full list.
The second argument is a theme name (default: 'default'):
generator.addTrainingData({ titles: { QUEST: ['My Quest'] } }, 'side_quests');
generator.addTrainingData({ titles: { COMBAT: ['Boss Fight'] } }, 'default');
Custom themes are merged with default when generating — any theme with content for the rolled event type can be picked.
v3-style raw text training is a no-op in v4:
// Does nothing in v4 (kept for API compatibility)
generator.addTrainingData(['Some random text', 'More text']);
Use structured objects instead. For Markov-style generation, enable pureMarkovMode — see Configuration.
location / weather / etc. are still applied on top of your descriptionsdebug: true in constructor options to log when raw texts are ignored