npm install rpg-event-generator
Requires Node.js 16+.
const { generateRPGEvent } = require('rpg-event-generator');
const event = generateRPGEvent({
level: 10,
location: 'forest',
weather: 'rainy',
class: 'fighter',
timeOfDay: 'night'
});
console.log(event.title);
console.log(event.description);
console.log(event.choices);
console.log(event.type);
Every event includes:
| Field | Description |
|---|---|
id |
Unique event id |
title |
Short headline |
description |
Narrative text (may include location/weather/time/class/race prefixes) |
choices |
Array of { text, effect } |
type |
Event category (e.g. COMBAT, MAGIC) |
difficulty |
easy, normal, hard, or legendary |
tags |
Lowercase type + optional wealth tier |
const { RPGEventGenerator } = require('rpg-event-generator');
const generator = new RPGEventGenerator({ theme: 'fantasy' });
const event = generator.generateEvent({
level: 15,
gold: 2500,
class: 'wizard',
race: 'elf',
location: 'tower',
weather: 'stormy',
timeOfDay: 'night'
});
const batch = generator.generateEvents({ level: 5 }, 5);
Pass any of these on PlayerContext to flavour descriptions:
| Field | Example | Effect |
|---|---|---|
location |
'forest' |
~70% chance of location prefix |
weather |
'rainy', 'stormy' |
~60% chance of weather prefix |
timeOfDay |
'night', 'dawn' |
~50% chance of time prefix |
class |
'fighter' |
~40% chance of class prefix |
race |
'elf' |
~40% chance of race prefix |
level, gold, health |
numbers | Used for difficulty scaling |
Stats like level, gold, and influence also feed difficulty and choice effects.
npm run demo
Optional smoke test after npm run build. For runnable examples, see Examples.