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

dnd-npc

v2.1.0

Published

Generate random D&D NPCs

Downloads

19

Readme

NPM

About

DnD-NPC is a Node.js module allows you to easily create randomized D&D NPCs. For a complete list of previous changes, see here.

⚠️ Version 2.0 updated the entire codebase to be compatible with ES modules, which means you can no longer load it with require(). You must use import instead.

v2.0 also has many other breaking changes, it's recommended that you read the changelog before updating


Usage:

You can create a new npc in several ways.

import NPC from 'dnd-npc';

const obj = {
	raceType: "warforged",
	subRace: "juggernaut",
	classType: "fighter"
}

const npc = new NPC(obj)

// Generates a Warforged-Juggernaut Fighter
const character = await npc.generate();
import NPC from 'dnd-npc';
const npc = new NPC()
	.setRace("warforged", "juggernaut")
	.setClass("fighter");

// Generates a Warforged-Juggernaut Fighter
const character = await npc.generate();

You can also overwrite settings that you have already input.

import NPC from 'dnd-npc';

const obj = {
	raceType: "warforged",
	subRace: "juggernaut",
	classType: "fighter"
}

const npc = new NPC(obj)
	.setRace("human")
	.setClass("bard");
	
// Generates a Human Bard (why u make Bard tho?)
const character = await npc.generate();

You can also pass a sub-race as the classType and it will generate with the correct race and sub-race.

import NPC from 'dnd-npc';
const npc = new NPC({ classType: "juggernaut" });

// Generates a Warforged-Juggernaut with a random class.
const character = await npc.generate();

Leaving the raceType or classType blank, or passing an invalid type to it, will result in that thing being randomly generated.

import NPC from 'dnd-npc';
const npc = new NPC({ raceType: "warforged" });

// Generates a Warforged with a random sub-race and class.
const character = await npc.generate();
import NPC from 'dnd-npc';
const npc = new NPC({ classType: "fighter" });

// Generates a fighter with a random race
const character = await npc.generate();
import NPC from 'dnd-npc';
const npc = new NPC();

// Generates a completely random character.
const character = await npc.generate();

Output:

After using the #generate() method, you'll receive an object like this with all the details of the NPC. ⚠️ You can only use #generate() once per npc instance. Additional uses will simply return the same character.

{
	"character": CharacterData,
	"race": RaceData,
	"class": ClassData,
	"inventory": InventoryData
};

The Object type definitions can be found below:

CharacterData = {
	name: String,
	gender: String,
	alignment: String,
	age: Number,
	background: String,
	level: Number
}

RaceData = {
	name: String,
	link: String,
	size: String,
	speed: Number
}

ClassData = {
	name: String,
	link: String,
	stats: {
		strength: StatData,
		dexterity: StatData,
		constitution: StatData,
		intelligence: StatData,
		wisdom: StatData,
		charisma: StatData
	}
}

StatData = {
	total: Number,
	prof: Number
}

InventoryData = {
	weapon: WeaponData,
	armor: ArmorData || undefined,
	shield: Boolean || String,
	tools: ToolData[]
}

WeaponData = {
	name: String,
	link: String,
	damageType: String,
	damage: String,
	versatileDamage: String || undefined,
	simple: Boolean,
	ranged: Boolean,
	allowsShield: Boolean,
	properties: String[]
}

ArmorData = {
	name: String,
	type: String,
	link: String,
	strengthReq: Number,
	armorClass: Number,
	scalesWithDex: Boolean,
	maxDexBonus: Number,
	isStealthy: Boolean
}

ToolData = {
	name: String,
	link: String
}

Valid raceType and subRace

  • Aarakocra
  • Aasimar
    • Fallen
    • Protector
    • Scourge
  • Bugbear
  • Changeling
  • Dragonborn
  • Dwarf
    • Hill
    • Mountain
  • Elf
    • Dark
    • Eladrin
    • High
    • Wood
  • Firbolg
  • Genasi
    • Air
    • Earth
    • Fire
    • Water
  • Gnome
    • Deep
    • Forest
    • Rock
  • Goblin
  • Goliath
  • Grung
  • Halfelf
  • Halfling
    • Lightfoot
    • Stout
  • Halforc
  • Hobgoblin
  • Human
  • Kalashtar
  • Kenku
  • Kobold
  • Lizardfolk
  • Orc
  • Shifter
    • Beasthide
    • Longtooth
    • Swiftstride
    • Wildhunt
  • Tabaxi
  • Tiefling
  • Triton
  • Warforged
    • Envoy
    • Juggernaut
    • Skirmisher
  • Yuanti

Valid classType

  • Artificer
  • Barbarian
  • Bard
  • Cleric
  • Druid
  • Fighter
  • Monk
  • Paladin
  • Ranger
  • Rogue
  • Sorcerer
  • Warlock
  • Wizard

Need help?

If you need any extra help, feel free to hit me up on discord. If you've encountered a bug or would like to suggest a feature, feel free to create either a pull request or an issue on the github.