Files
muuhd/models/character.js
Kim Ravn Hansen 7ecb4f724b Stuff ad things
2026-02-12 16:54:27 +01:00

93 lines
1.9 KiB
JavaScript
Executable File

import { Item } from "./item.js";
/**
* A playable character.
*
* @class
*/
export class Character {
/** @type {string} character's name */
name;
/**
* @protected
* @type {number} The number of XP the character has.
*/
xp = 0;
/** @protected @type {number} The character's level. */
level = 1;
/** @type {number} Awareness Skill */
awareness;
/** @type {number} Grit Skill */
grit;
/** @type {number} Knowledge Skill */
knowledge;
/** @type {number} Magic Skill */
magic;
/** @type {number} Melee Attack Skill */
meleeCombat;
/** @type {number} Ranged Attack Skill */
rangedCombat;
/** @type {number} Skulduggery Skill */
skulduggery;
/** @type {string} Bloodline background */
ancestry;
/** @type {string} Foundational background */
foundation;
/** @type {string} Money */
silver;
/** @type {number} Current number of hit points */
currentHitPoints;
/** @type {number} Number of hit points when fully healed */
maxHitPoints;
/** @type {number} Number items you can carry */
itemSlots;
/** @type {Set<string>} Things the character is particularly proficient at. */
proficiencies = new Set();
/** @type {Set<Item} Things the character is particularly proficient at. */
items = new Set();
/** @type {string[]} */
freeSlots = [];
/**
* @param {string} name The name of the character
*/
constructor(name) {
this.name = name;
}
/** Add an item to the equipment list
* @param {Item} item
*
* Maybe return the accumulated ItemSlots used?
*/
addItem(item) {
if (!(item instanceof Item)) {
console.debug("bad item", item);
throw new Error("item must be an instance of Item!");
}
this.items.add(item)
}
// todo removeItem(item, count)
}