D&D SRD data library
npm install dndsrdA TypeScript library providing D&D SRD (System Reference Document) data.
``bash`
npm install dndsrd
`typescript
import { classes, spells, monsters, CharacterClass, Spell, Monster } from 'dndsrd';
// Get all character classes
console.log(classes);
// [
// {
// name: 'Fighter',
// hitDie: 10,
// proficiencies: [...],
// savingThrows: ['Strength', 'Constitution']
// },
// ...
// ]
// Get all spells
console.log(spells);
// [
// {
// name: 'Magic Missile',
// level: 1,
// school: 'Evocation',
// castingTime: '1 action',
// range: '120 feet',
// components: ['V', 'S'],
// duration: 'Instantaneous',
// description: '...'
// },
// ...
// ]
// Get all monsters
console.log(monsters);
// [
// {
// name: 'Goblin',
// size: 'Small',
// type: 'humanoid',
// alignment: 'neutral evil',
// armorClass: 15,
// hitPoints: 7,
// speed: '30 ft.',
// abilities: { strength: 8, dexterity: 14, ... },
// challengeRating: 0.25
// },
// ...
// ]
`
The library exports TypeScript types for all data structures:
`typescript
interface CharacterClass {
name: string;
hitDie: number;
proficiencies: string[];
savingThrows: string[];
}
interface Spell {
name: string;
level: number;
school: string;
castingTime: string;
range: string;
components: string[];
duration: string;
description: string;
}
interface Monster {
name: string;
size: string;
type: string;
alignment: string;
armorClass: number;
hitPoints: number;
speed: string;
abilities: {
strength: number;
dexterity: number;
constitution: number;
intelligence: number;
wisdom: number;
charisma: number;
};
challengeRating: number;
}
``
MIT