Skip to content

Latest commit

 

History

History
190 lines (142 loc) · 4.53 KB

File metadata and controls

190 lines (142 loc) · 4.53 KB

API Reference

Examples given from a base of

import FCG from "fantasy-content-generator";

but all API methods work with the direct <script> include too.

All items below should be taken as WIP. We're following Semver, but assume that everything may change in the future!

Names

Generate names for a race and gender, based on D&D 5E. All base races in the 5E PHB are supported.

generate({ [race], [gender], [seed] })

Returns generated data, a seed to re-generate that data, and formatted data

FCG.Names.generate({ race: "elf", gender: "male" });
/*
{
  seed: <uuid>,
  name: 'a male elf name',
  race: 'elf',
  gender: 'male',
  formattedData: {
    name: 'a male elf name',
    race: 'Elf',
    gender: 'Male
  }
}
*/

If no race and/or gender given, one will be chosen at random for each.

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

Names based on race can also be generated by calling the race directly on the Names object as a function. All D&D 5E PHB races are supported.

FCG.Names.elf(); // an elf with a random gender
FCG.Names.elf({ gender: "female" }); // a female elf

A seed can be passed to ensure deterministic generation

FCG.Names.elf({ seed: "a" }); // seed of 'a' will always be the same

Storyhooks

Generate short, interesting things to happen that can spur on an encounter or spice things up if they're getting stale.

npcActs()

An NPC does something.

FCG.Storyhooks.npcActs(); // 'An NPC becomes fearful'

NPCs

Generate NPCs.

generate({ [race:string], [gender:string], [seed:string], [shouldGenerateRelations:bool] })

A generated NPC will have;

  • race
  • gender
  • name
  • traits physical characteristics, mannerisms
  • desires things the NPC wants to achieve for themselves or others
FCG.NPCs.generate();

/*
{
  name: 'Biri Drachedandion',
  gender: 'female',
  race: 'dragonborn',
  seed: '8fd7f407-ac19-4bac-b9cf-d50e1f2df15f'
  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.'
  ]
}
*/

A seed can be passed to ensure the same generated NPC. If no seed is passed, a UUID will be generated and used as the seed, so you can recreate that NPC in future.

### NPC Generated Relations

If shouldGenerateRelations is passed as true to generate(), relations will be generated on your NPC for you. These are based off keywords from all your NPCs generated desires. For example, an NPC with a desire of "I want to find my father" will generate a father relation (a male NPC of the same race). These generated relations will also have seeds attached, so they can be readily generated in future.

MagicItems

Generate magical items, with names, effects, school of magic and power level

Currently only generating melee weapons! More flavours of magic items to come soon!

generate()

A generated magic item.

Generated magic items will have;

  • type
    • the base "role" of the item. E.g weapon, armour, item, etc.
  • subtype
    • subtypes depend on base type. for type 'weapon', for example, subtype could be Hand Axe, Short Sword, etc.
  • schoolOfMagic
    • 'conjuration', 'necromancy', etc.
  • effects
    • any magic effects the item has
  • formattedData
    • some pre-built strings for you to use
FCG.MagicItems.generate({ type: "weapon" });

/*
{
  type: 'weapon',
  subtype: 'War Pick',
  powerLevel: 'greater',
  schoolOfMagic: 'evocation',
  effects: [
    'The blade of this weapon crackles with magical energy. When swung in front of a group of creatures, 2  of the creatures are struck with bolts of energy. Each affected creature takes 3d4 Lightning damage, and becomes Paralyzed for 2 rounds.'
  ],
  formattedData: {
    title: 'War Pick of Greater Evocation'
  }
}
*/

Loots

Generate loot items by different methods

Functions:

source({ [source] })

Generate loot from the "source of the loot" as opposed to the "type" of loot.

Loot generated from source() will have

  • source
    • the source of the loot
  • loot
    • the loot item itself
FCG.Loot.source();

/*
{
  source: 'Humanoid (Wild)',
  loot: 'a crudely fashioned hunting trap. It is made of gnarled wood and jagged iron spikes. It could be used to trap small creatures, such as boar or deer.'
}
*/