npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fantasy-content-generator

v4.9.1

Published

Generates RPG friendly, fantasy themed content, such as names, NPCs, magic items, and more

Downloads

53

Readme

Fantasy Content Generator

npm

Simple API for generating flavourful and interesting fantasy gaming content. Need an NPC? A name? A magic item? You came to the right place.

Top Features Include:

  • Interesting, flavoursome, and narrative-focused content, designed for roleplaying and inspiration for DMs
  • Easy to understand API
  • A single dependency (https://www.npmjs.com/package/seedrandom)
  • Can be used in both Node & browser
  • Optional seeding for deterministic generation
  • Ties-in to D&D 5E mechanics (weapon stats, magic effects, etc.)

Using this library in a project? Please let me know!


Installing

Node/Webpack

npm install --save fantasy-content-generator

import FCG from "fantasy-content-generator";

Browser/Direct <script> Include

Download fantasy_content_generator.js direct from Github and include in a script tag.

<script src="./fantasy_content_generator.js" type="text/javascript"></script>

<script>
  // API available on window.FantasyContentGenerator
</script>

Usage

import FCG from "fantasy-content-generator";

FCG.Names.generate();
/*
{
  seed: <uuid>,
  name: 'Sutha Chernin',
  race: 'halfOrc',
  gender: 'female',
  formattedData: {
    name: 'Sutha Chernin',
    race: 'Half-Orc',
    gender: 'Female'
  }
}
*/

FCG.Storyhooks.npcActs();
/*
{
  seed: <uuid>,
  storyhook: 'An NPC takes a liking to a PC'
}
*/

FCG.NPCs.generate();
/*
{
  seed: <uuid>,
  name: 'Biri Drachedandion',
  gender: 'female',
  race: 'dragonborn',
  traits: [
    'I am unusually tall for my race.',
    'I\'m very clumsy.'
  ],
  desires: [
    'I want to prove myself in combat, so I\'m going to win a tournament.'
  ]
}
*/

FCG.Settlements.generate();
/*
{
  seed: <uuid>,
  type: 'large_city',
  population: '45,760'
}
*/

FCG.MagicItems.generate();
/*
{
  seed: <uuid>,
  type: 'weapon',
  subtype: 'Battleaxe',
  powerLevel: 'minor',
  schoolOfMagic: 'necromancy',
  effects: [
    'On a successful attack, target must make a DC 12 CON save or take an extra 1d2 of Necrotic damage. This effect occurs once per day.'
  ],
  formattedData: {
    title: 'Battleaxe of Minor Necromancy'
  }
}
*/

API

API Reference

There are a number of "sets" available. These are

  • Names - generates names based on race and gender
  • NPCs - generates full NPCs
  • Loots - generates loot and treasure
  • MagicItems - generates magic items
  • Storyhooks - generates storyhooks
  • Settlements - generates settlement information

and can all be found on the base Fantasy Content Generator object.

Sets expose a generate() function, some expose others unique to that set.

Many of the sets are currently WIP and quite limited. More content to come soon! Follow me on Twitter for release and update details.

Tests

npm test

If you want to run a specific test file manually, ensure you set ENVIRONMENT=test

Contributing

Development

If you're wanting to quickly test some changes, the best way is to

  • npm run build:node && node to get a Node build locally and run a node instance locally
  • const FCG = require('./dist/index.js'); to load FCG into memory
  • FCG.NPCs.generate(); you can then start running generators, and seeing the JSON output in your console

Open Sourcery

Open up a PR!

Please make sure your PR includes;

  • a thorough description, including what you're changing and why
  • tests
    • if you're touching utils stuff, tests to ensure behaviour is correct
    • if you're adding/amending sets, tests to ensure that the final returned object doesn't contain any undefined's, etc.

If you want to use content taken from other sources, please check with their licensing first. For example, D&D 5E content is OK, as long its from the SRD.

Releasing

With permission to release, simply run any one of;

  • npm run publish:patch
  • npm run publish:minor
  • npm run publish:major

from your CLI and follow the steps. Requires NPM to be installed locally on your machine.

Credits

d100 Community - Endless Inspiration

tmcgry - Code & Content

SkyD1vingNun - Additional Content

https://github.com/davidbau/seedrandom - Random seeding code, huge thank you