Classes
name="NPC"
desc="A class for generating random NPCs."
link="/npc/docs/class/npc"
%}
name="Character"
desc="A class representing a character in the game."
link="/npc/docs/class/character"
%}
name="CharacterData"
desc="A class representing the data for a character."
link="/npc/docs/class/characterdata"
%}
name="RaceData"
desc="A class representing the data for a character's race."
link="/npc/docs/class/racedata"
%}
name="ClassData"
desc="A class representing the data for a character's class."
link="/npc/docs/class/classdata"
%}
name="Stats"
desc="A class representing a character's stats."
link="/npc/docs/class/stats"
%}
name="StatData"
desc="A class representing the data for a character's stats."
link="/npc/docs/class/statdata"
%}
name="InventoryData"
desc="A class representing the data for a character's inventory."
link="/npc/docs/class/inventorydata"
%}
name="WeaponData"
desc="A class representing the data for a character's weapons."
link="/npc/docs/class/weapondata"
%}
name="ArmorData"
desc="A class representing the data for a character's armor."
link="/npc/docs/class/armordata"
%}
name="ToolData"
desc="A class representing the data for a character's tools."
link="/npc/docs/class/tooldata"
%}
Example Code
import NPC from 'dnd-npc';
const obj = {
raceType: "warforged",
subRace: "juggernaut",
classType: "fighter"
}
const npc = new NPC(obj);
/*
Generates a Warforged-Juggernaut
that has the class of "Fighter"
*/
const character = await npc.generate();
import NPC from 'dnd-npc';
const npc = new NPC()
.setRace("warforged", "juggernaut")
.setClass("fighter");
/*
Generates a Warforged-Juggernaut
that has the class of "Fighter"
*/
const character = await npc.generate();
You can 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.
const character = await npc.generate();
Passing a sub-race as the raceType and it will generate with the correct race and sub-race.
import NPC from 'dnd-npc';
const obj = {
classType: "juggernaut"
};
const npc = new NPC(obj);
/*
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 obj = {
raceType: "warforged"
};
const npc = new NPC(obj);
/*
Generates a Warforged with a
random sub-race and class.
*/
const character = await npc.generate();
import NPC from 'dnd-npc';
const obj = {
classType: "fighter"
};
const npc = new NPC(obj);
/*
Generates a fighter with
a random race.
*/
const character = await npc.generate();
import NPC from 'dnd-npc';
const npc = new NPC();
// Generates a fully random character.
const character = await npc.generate();