🎲 Character-Sheet: Beta 🎲
👑 Quickly define the relationships between stats.
👑 Manage inventories, talents, equipment, etc.
👑 Create items, skills, buffs.
👑 Save and export modified sheets.
🚩 This library is still in beta.
Concepts
Sheet
- A sheet is used to define stats.
- Stats may have computable relationships between them.
- For example: hitpoints can be based off of constitution.
Character
- A character is one instance of a sheet.
- Characters may assign values to stats.
- For example: You may set constitution from 8 to 10, which will cause hitpoints to rise from 80 to 100.
Stats
- A stat is a single named property on a character.
- Computed stats must be numerical, but sheets may also store other types of information.
- For example: player level, character name, or experience.
Modifiers
- Modifiers allow you to define sets of modifications to stats on a character.
- They can be added or removed at any time.
- For example: talents, equipment, spells, items, and buffs.
Inventory
- Inventories hold modifiers that are applied to a character.
- Inventories may also serve as storage for modifiers that are set to inactive.
- Example inventories: equipment, active effects, bags, or class features.
Design a Sheet
In the below snippet you will learn how to:
- Generate a sheet
- Define some stats
// import the library; // generate a new sheet called "TableDungeons"const TableDungeons = ; // define constitutionTableDungeons; // hp is based on constitutionTableDungeons ;
Create a Character
A continuation of the previous example, here we'll:
- Create a character
- Derive a stats' computed value
// create a character called sirKnightconst sirKnight = ; // check what sirKnight's hp is; // 125
Save My Character
After a sheet has been designed, and a character created, it can be exported and stored.
// export the sheet as an objectconst exportedSheet = sirKnight; // { ... constitution: 10, hp: 125 }
For in depth examples see below.
Define API
- Used to define base stats on a Sheet
// define constitutionTableDungeons;
Chainable Heirarchy
.define()
.describe()
.initially()
.add()
.subtract()
.divideBy()
.roundUp()
.roundDown()
.calculate()
.using()
.calculate()
String
)
.define(stat Define a stat on a Sheet
// import the library; // generate a new CharacterSheet Classconst TableDungeons = ; // generate a new CharacterSheet ClassTableDungeons // a stat named constitution // initial value of 10 ; // a new character sheetconst sirKnight = ; // get player name; // "Anonymous Player"
String | Number | Boolean
)
.initially(value Set the initial value of the stat. The type of value cannot change once set.
// import the library; // generate a new Sheetconst TableDungeons = ; // define a stringTableDungeons ; // define a numberTableDungeons ; // define a booleanTableDungeons ;
String | Number
)
.add | .subtract | .divideBy (value Mathematical operation
String
will add the computed value of another stat.Number
will add a static value.
// import the library; // generate a new Sheetconst TableDungeons = ; // create a new characterconst sirKnight = ; TableDungeons // define a stat named constitution // initial value of 10 ; TableDungeons // define a stat named hp // initially 100 // + whatever constitution's calculated value is // + 25 ;
.roundUp(), .roundDown()
Round to a whole number, with the respective rule to describe which way to round.
Inventory API
A storage mechanism that contains modifiers, defined in the CharacterSheet, and accessed on the character.
Functional Heirarchy
.give()
.of()
.filter()
.prune()
.remove()
.move()
.to()
.forEach()
.on()
.off()
Modifier API
Modifiers represent templates of modifications, that can be added to inventories. They are not in effect until added to an inventory that is on.
Features
- Create a modifier template which can be placed into any inventory
- Describe which stat to modify and augment it with sequential mathematical operations
- Switch default on or off
Functional Heirarchy
- modifier
- modifies
- add
- subtract
- divideBy
- roundDown
- roundUp
- on
- off
- modifies
Modifier API
Modifiers are placed exclusively on the character, and not on the CharacterSheet. They represent any mechanical adjustments to stats during computation.
Features
- Switch on or off
- Move to another inventory
- Destroy
- Duplicate and place in desired inventory
Functional Heirachy
- on
- off
- moveTo
- destroy
- duplicate
- to
Example Character Sheets
Example 1: Dungeons and Dragons - Stat Modifiers
Let's replicate the functionality of Dungeons and Dragons style stat modifiers. The rule is: whatever your stat is, your stat modifier is that number divided by 2, rounded down, subtract 5.
For example:
- Stat is 15
- 15 / 2 = 7.5
- Round Down 7.5 = 7
- 7 - 5 = 2
- Stat Modifier is 2.
Let's build our CharacterSheet Class, called
TableDungeons
.
// import the library; // generate a new CharacterSheet Classconst TableDungeons = ; // define whatever stats to attach to CharacterSheet Classconst stats = 'strength' 'dexterity' 'charisma'; // loop over each stat - 'strength', 'dexterity', 'charisma'stats;
Let's create our
CharacterSheet Instance
of theCharacterSheet Class
calledsirKnight
.
// sirKnights previously exported sheetconst savedSheet = strength: 8 dexterity: 10 charisma: 18; // instantiate a character sheet for a playerconst sirKnight = savedSheet; // the modifiers are calculated and vailable for query; // -1; // 0; // 4
Example 2: Talents, Equipment, and Inventory
In most table top games, there are ways to augment your character as you go. These kinds of things can include inventory, spells, equipment, talents, and so on.
In this example we'll work with passive talents, active equipment, and an inventory which holds items not currently equipped.
Let's build our CharacterSheet Class, called
TableDungeons
.
// import the library; // generate a new CharacterSheet Classconst TableDungeons = ;
We'll add 3 inventories, with an
initially()
of[]
to indiciate that these will hold modifiers.
// holds items that are not actively in use - we'll turn this one off()TableDungeons; // holds passive talents, on() by defaultTableDungeons; // holds items that are actively in use, on() by defaultTableDungeons; // healthTableDungeons; // manaTableDungeons;
We'll instantiate our good sir knight
// instantiate a character sheet for a playerconst sirKnight = ;
Let's create some modifiers that
sirKnight
will be able to consume
// create the Wand of PowersirKnight // let's give it a descriptive name // and modify mana // by adding 100 to it ; // no change - we have to give sirKnight// a wand in order for him to gain its bonus; // 250
We'll equip the Wand of Power
// select the equipment inventory // sirKnight will gain 1 // Wand of Power ; // the bonus is now being applied; // 350
Let's take the wand off for now
// select the equipment inventory // find the 1h/wand-of-power // and move to the inventory ; // because inventory is .off()// the Wand of Power no longer// affects mana.; // 250
The same thing can be done with talents.
// create the talent: Sturdy and StoutsirKnight // give it a descriptive namespace // modifies hp // adds 50 to hp // also modifies mana // subtracts 50 from mana ; // select sigKnight's equipment // give 1 // Study and Stout ; // it behaves just like the equipment// inventory. talents and items are really// the same thing. :)~; // 150; // 200