actor classes
This commit is contained in:
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 120 KiB |
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 76 KiB |
|
Before Width: | Height: | Size: 903 KiB After Width: | Height: | Size: 903 KiB |
@@ -0,0 +1,89 @@
|
|||||||
|
import { TotemActor } from "./actor.mjs";
|
||||||
|
/**
|
||||||
|
* @extends {TotemActor}
|
||||||
|
*/
|
||||||
|
export class TotemCharacter extends TotemActor {
|
||||||
|
|
||||||
|
/** @override */
|
||||||
|
prepareData() {
|
||||||
|
// Prepare data for the actor. Calling the super version of this executes
|
||||||
|
// the following, in order: data reset (to clear active effects),
|
||||||
|
// prepareBaseData(), prepareEmbeddedDocuments() (including active effects),
|
||||||
|
// prepareDerivedData().
|
||||||
|
super.prepareData();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @override */
|
||||||
|
prepareBaseData() {
|
||||||
|
// Data modifications in this step occur before processing embedded
|
||||||
|
// documents or derived data.
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @override
|
||||||
|
* Augment the basic actor data with additional dynamic data. Typically,
|
||||||
|
* you'll want to handle most of your calculated/derived data in this step.
|
||||||
|
* Data calculated in this step should generally not exist in template.json
|
||||||
|
* (such as ability modifiers rather than ability scores) and should be
|
||||||
|
* available both inside and outside of character sheets (such as if an actor
|
||||||
|
* is queried and has a roll executed directly from it).
|
||||||
|
*/
|
||||||
|
prepareDerivedData() {
|
||||||
|
const actorData = this;
|
||||||
|
const systemData = actorData.system;
|
||||||
|
const flags = actorData.flags.totem || {};
|
||||||
|
|
||||||
|
// Make separate methods for each Actor type (character, npc, etc.) to keep
|
||||||
|
// things organized.
|
||||||
|
this._prepareCharacterData(actorData);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare Character type specific data
|
||||||
|
*/
|
||||||
|
_prepareCharacterData(actorData) {
|
||||||
|
if (actorData.type !== 'character') return;
|
||||||
|
|
||||||
|
// Make modifications to data here. For example:
|
||||||
|
const systemData = actorData.system;
|
||||||
|
|
||||||
|
// Loop through ability scores, and add their modifiers to our sheet output.
|
||||||
|
for (let [key, ability] of Object.entries(systemData.abilities)) {
|
||||||
|
// Calculate the modifier using d20 rules.
|
||||||
|
ability.mod = Math.floor((ability.value - 10) / 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override getRollData() that's supplied to rolls.
|
||||||
|
*/
|
||||||
|
getRollData() {
|
||||||
|
const data = super.getRollData();
|
||||||
|
|
||||||
|
// Prepare character roll data.
|
||||||
|
this._getCharacterRollData(data);
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare character roll data.
|
||||||
|
*/
|
||||||
|
_getCharacterRollData(data) {
|
||||||
|
if (this.type !== 'character') return;
|
||||||
|
|
||||||
|
// Copy the ability scores to the top level, so that rolls can use
|
||||||
|
// formulas like `@str.mod + 4`.
|
||||||
|
if (data.abilities) {
|
||||||
|
for (let [k, v] of Object.entries(data.abilities)) {
|
||||||
|
data[k] = foundry.utils.deepClone(v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add level for easier access, or fall back to 0.
|
||||||
|
if (data.attributes.level) {
|
||||||
|
data.lvl = data.attributes.level.value ?? 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
import { TotemActor } from "./actor.mjs";
|
||||||
|
/**
|
||||||
|
* Extend the base Actor document by defining a custom roll data structure which is ideal for the Simple system.
|
||||||
|
* @extends {TotemActor}
|
||||||
|
*/
|
||||||
|
export class TotemCreature extends TotemActor {
|
||||||
|
|
||||||
|
/** @override */
|
||||||
|
prepareData() {
|
||||||
|
// Prepare data for the actor. Calling the super version of this executes
|
||||||
|
// the following, in order: data reset (to clear active effects),
|
||||||
|
// prepareBaseData(), prepareEmbeddedDocuments() (including active effects),
|
||||||
|
// prepareDerivedData().
|
||||||
|
super.prepareData();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @override */
|
||||||
|
prepareBaseData() {
|
||||||
|
// Data modifications in this step occur before processing embedded
|
||||||
|
// documents or derived data.
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @override
|
||||||
|
* Augment the basic actor data with additional dynamic data. Typically,
|
||||||
|
* you'll want to handle most of your calculated/derived data in this step.
|
||||||
|
* Data calculated in this step should generally not exist in template.json
|
||||||
|
* (such as ability modifiers rather than ability scores) and should be
|
||||||
|
* available both inside and outside of character sheets (such as if an actor
|
||||||
|
* is queried and has a roll executed directly from it).
|
||||||
|
*/
|
||||||
|
prepareDerivedData() {
|
||||||
|
const actorData = this;
|
||||||
|
const systemData = actorData.system;
|
||||||
|
const flags = actorData.flags.totem || {};
|
||||||
|
|
||||||
|
// Make separate methods for each Actor type (character, npc, etc.) to keep
|
||||||
|
// things organized.
|
||||||
|
this._prepareNpcData(actorData);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare NPC type specific data.
|
||||||
|
*/
|
||||||
|
_prepareNpcData(actorData) {
|
||||||
|
if (actorData.type !== 'npc') return;
|
||||||
|
|
||||||
|
// Make modifications to data here. For example:
|
||||||
|
const systemData = actorData.system;
|
||||||
|
systemData.xp = (systemData.cr * systemData.cr) * 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override getRollData() that's supplied to rolls.
|
||||||
|
*/
|
||||||
|
getRollData() {
|
||||||
|
const data = super.getRollData();
|
||||||
|
|
||||||
|
// Prepare character roll data.
|
||||||
|
this._getNpcRollData(data);
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare NPC roll data.
|
||||||
|
*/
|
||||||
|
_getNpcRollData(data) {
|
||||||
|
if (this.type !== 'creature') return;
|
||||||
|
|
||||||
|
// Process additional NPC data here.
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
import { TotemActor } from "./actor.mjs";
|
||||||
|
/**
|
||||||
|
* Extend the base Actor document by defining a custom roll data structure which is ideal for the Simple system.
|
||||||
|
* @extends {TotemActor}
|
||||||
|
*/
|
||||||
|
export class TotemNpc extends TotemActor {
|
||||||
|
|
||||||
|
/** @override */
|
||||||
|
prepareData() {
|
||||||
|
// Prepare data for the actor. Calling the super version of this executes
|
||||||
|
// the following, in order: data reset (to clear active effects),
|
||||||
|
// prepareBaseData(), prepareEmbeddedDocuments() (including active effects),
|
||||||
|
// prepareDerivedData().
|
||||||
|
super.prepareData();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @override */
|
||||||
|
prepareBaseData() {
|
||||||
|
// Data modifications in this step occur before processing embedded
|
||||||
|
// documents or derived data.
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @override
|
||||||
|
* Augment the basic actor data with additional dynamic data. Typically,
|
||||||
|
* you'll want to handle most of your calculated/derived data in this step.
|
||||||
|
* Data calculated in this step should generally not exist in template.json
|
||||||
|
* (such as ability modifiers rather than ability scores) and should be
|
||||||
|
* available both inside and outside of character sheets (such as if an actor
|
||||||
|
* is queried and has a roll executed directly from it).
|
||||||
|
*/
|
||||||
|
prepareDerivedData() {
|
||||||
|
const actorData = this;
|
||||||
|
const systemData = actorData.system;
|
||||||
|
const flags = actorData.flags.totem || {};
|
||||||
|
|
||||||
|
// Make separate methods for each Actor type (character, npc, etc.) to keep
|
||||||
|
// things organized.
|
||||||
|
this._prepareNpcData(actorData);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare NPC type specific data.
|
||||||
|
*/
|
||||||
|
_prepareNpcData(actorData) {
|
||||||
|
if (actorData.type !== 'npc') return;
|
||||||
|
|
||||||
|
// Make modifications to data here. For example:
|
||||||
|
const systemData = actorData.system;
|
||||||
|
systemData.xp = (systemData.cr * systemData.cr) * 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override getRollData() that's supplied to rolls.
|
||||||
|
*/
|
||||||
|
getRollData() {
|
||||||
|
const data = super.getRollData();
|
||||||
|
|
||||||
|
// Prepare character roll data.
|
||||||
|
this._getNpcRollData(data);
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare NPC roll data.
|
||||||
|
*/
|
||||||
|
_getNpcRollData(data) {
|
||||||
|
if (this.type !== 'npc') return;
|
||||||
|
|
||||||
|
// Process additional NPC data here.
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
export const TOTEM = {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The set of Ability Scores used within the sytem.
|
|
||||||
* @type {Object}
|
|
||||||
*/
|
|
||||||
TOTEM.abilities = {
|
|
||||||
"str": "TOTEM.AbilityStr",
|
|
||||||
"dex": "TOTEM.AbilityDex",
|
|
||||||
"con": "TOTEM.AbilityCon",
|
|
||||||
"int": "TOTEM.AbilityInt",
|
|
||||||
"wis": "TOTEM.AbilityWis",
|
|
||||||
"cha": "TOTEM.AbilityCha"
|
|
||||||
};
|
|
||||||
|
|
||||||
TOTEM.abilityAbbreviations = {
|
|
||||||
"str": "TOTEM.AbilityStrAbbr",
|
|
||||||
"dex": "TOTEM.AbilityDexAbbr",
|
|
||||||
"con": "TOTEM.AbilityConAbbr",
|
|
||||||
"int": "TOTEM.AbilityIntAbbr",
|
|
||||||
"wis": "TOTEM.AbilityWisAbbr",
|
|
||||||
"cha": "TOTEM.AbilityChaAbbr"
|
|
||||||
};
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
/**
|
|
||||||
* Manage Active Effect instances through the Actor Sheet via effect control buttons.
|
|
||||||
* @param {MouseEvent} event The left-click event on the effect control
|
|
||||||
* @param {Actor|Item} owner The owning document which manages this effect
|
|
||||||
*/
|
|
||||||
export function onManageActiveEffect(event, owner) {
|
|
||||||
event.preventDefault();
|
|
||||||
const a = event.currentTarget;
|
|
||||||
const li = a.closest("li");
|
|
||||||
const effect = li.dataset.effectId ? owner.effects.get(li.dataset.effectId) : null;
|
|
||||||
switch ( a.dataset.action ) {
|
|
||||||
case "create":
|
|
||||||
return owner.createEmbeddedDocuments("ActiveEffect", [{
|
|
||||||
label: "New Effect",
|
|
||||||
icon: "icons/svg/aura.svg",
|
|
||||||
origin: owner.uuid,
|
|
||||||
"duration.rounds": li.dataset.effectType === "temporary" ? 1 : undefined,
|
|
||||||
disabled: li.dataset.effectType === "inactive"
|
|
||||||
}]);
|
|
||||||
case "edit":
|
|
||||||
return effect.sheet.render(true);
|
|
||||||
case "delete":
|
|
||||||
return effect.delete();
|
|
||||||
case "toggle":
|
|
||||||
return effect.update({disabled: !effect.disabled});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prepare the data structure for Active Effects which are currently applied to an Actor or Item.
|
|
||||||
* @param {ActiveEffect[]} effects The array of Active Effect instances to prepare sheet data for
|
|
||||||
* @return {object} Data for rendering
|
|
||||||
*/
|
|
||||||
export function prepareActiveEffectCategories(effects) {
|
|
||||||
|
|
||||||
// Define effect header categories
|
|
||||||
const categories = {
|
|
||||||
temporary: {
|
|
||||||
type: "temporary",
|
|
||||||
label: "Temporary Effects",
|
|
||||||
effects: []
|
|
||||||
},
|
|
||||||
passive: {
|
|
||||||
type: "passive",
|
|
||||||
label: "Passive Effects",
|
|
||||||
effects: []
|
|
||||||
},
|
|
||||||
inactive: {
|
|
||||||
type: "inactive",
|
|
||||||
label: "Inactive Effects",
|
|
||||||
effects: []
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Iterate over active effects, classifying them into categories
|
|
||||||
for ( let e of effects ) {
|
|
||||||
e._getSourceName(); // Trigger a lookup for the source name
|
|
||||||
if ( e.disabled ) categories.inactive.effects.push(e);
|
|
||||||
else if ( e.isTemporary ) categories.temporary.effects.push(e);
|
|
||||||
else categories.passive.effects.push(e);
|
|
||||||
}
|
|
||||||
return categories;
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
/**
|
|
||||||
* Define a set of template paths to pre-load
|
|
||||||
* Pre-loaded templates are compiled and cached for fast access when rendering
|
|
||||||
* @return {Promise}
|
|
||||||
*/
|
|
||||||
export const preloadHandlebarsTemplates = async function() {
|
|
||||||
return loadTemplates([
|
|
||||||
|
|
||||||
// Actor partials.
|
|
||||||
"systems/totem/templates/actor/parts/actor-features.html",
|
|
||||||
"systems/totem/templates/actor/parts/actor-items.html",
|
|
||||||
"systems/totem/templates/actor/parts/actor-spells.html",
|
|
||||||
"systems/totem/templates/actor/parts/actor-effects.html",
|
|
||||||
]);
|
|
||||||
};
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import {onManageActiveEffect, prepareActiveEffectCategories} from "../helpers/effects.mjs";
|
import {onManageActiveEffect, prepareActiveEffectCategories} from "../system/effects.mjs";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extend the basic ActorSheet with some very simple modifications
|
* Extend the basic ActorSheet with some very simple modifications
|
||||||
|
|||||||
@@ -0,0 +1,231 @@
|
|||||||
|
import {onManageActiveEffect, prepareActiveEffectCategories} from "../system/effects.mjs";
|
||||||
|
import { TotemActorSheet } from "./actor-sheet.mjs";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extend the basic ActorSheet with some very simple modifications
|
||||||
|
* @extends {TotemActorSheet}
|
||||||
|
*/
|
||||||
|
export class TotemCharacterSheet extends TotemActorSheet {
|
||||||
|
|
||||||
|
/** @override */
|
||||||
|
static get defaultOptions() {
|
||||||
|
return mergeObject(super.defaultOptions, {
|
||||||
|
classes: ["totem", "sheet", "actor"],
|
||||||
|
template: "systems/totem/templates/actor/actor-sheet.html",
|
||||||
|
width: 600,
|
||||||
|
height: 600,
|
||||||
|
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "features" }]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @override */
|
||||||
|
get template() {
|
||||||
|
return `systems/totem/templates/actor/actor-${this.actor.type}-sheet.html`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
|
||||||
|
/** @override */
|
||||||
|
getData() {
|
||||||
|
// Retrieve the data structure from the base sheet. You can inspect or log
|
||||||
|
// the context variable to see the structure, but some key properties for
|
||||||
|
// sheets are the actor object, the data object, whether or not it's
|
||||||
|
// editable, the items array, and the effects array.
|
||||||
|
const context = super.getData();
|
||||||
|
|
||||||
|
// Use a safe clone of the actor data for further operations.
|
||||||
|
const actorData = this.actor.toObject(false);
|
||||||
|
|
||||||
|
// Add the actor's data to context.data for easier access, as well as flags.
|
||||||
|
context.system = actorData.system;
|
||||||
|
context.flags = actorData.flags;
|
||||||
|
context.config = CONFIG.TOTEM;
|
||||||
|
|
||||||
|
// Prepare character data and items.
|
||||||
|
if (actorData.type == 'character') {
|
||||||
|
this._prepareItems(context);
|
||||||
|
this._prepareCharacterData(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prepare NPC data and items.
|
||||||
|
if (actorData.type == 'npc') {
|
||||||
|
this._prepareItems(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add roll data for TinyMCE editors.
|
||||||
|
context.rollData = context.actor.getRollData();
|
||||||
|
|
||||||
|
// Prepare active effects
|
||||||
|
context.effects = prepareActiveEffectCategories(this.actor.effects);
|
||||||
|
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Organize and classify Items for Character sheets.
|
||||||
|
*
|
||||||
|
* @param {Object} actorData The actor to prepare.
|
||||||
|
*
|
||||||
|
* @return {undefined}
|
||||||
|
*/
|
||||||
|
_prepareCharacterData(context) {
|
||||||
|
// Handle ability scores.
|
||||||
|
for (let [k, v] of Object.entries(context.system.abilities)) {
|
||||||
|
v.label = game.i18n.localize(context.system.abilities[k].label) ?? k;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Organize and classify Items for Character sheets.
|
||||||
|
*
|
||||||
|
* @param {Object} actorData The actor to prepare.
|
||||||
|
*
|
||||||
|
* @return {undefined}
|
||||||
|
*/
|
||||||
|
_prepareItems(context) {
|
||||||
|
// Initialize containers.
|
||||||
|
const gear = [];
|
||||||
|
const features = [];
|
||||||
|
const spells = {
|
||||||
|
0: [],
|
||||||
|
1: [],
|
||||||
|
2: [],
|
||||||
|
3: [],
|
||||||
|
4: [],
|
||||||
|
5: [],
|
||||||
|
6: [],
|
||||||
|
7: [],
|
||||||
|
8: [],
|
||||||
|
9: []
|
||||||
|
};
|
||||||
|
|
||||||
|
// Iterate through items, allocating to containers
|
||||||
|
for (let i of context.items) {
|
||||||
|
i.img = i.img || DEFAULT_TOKEN;
|
||||||
|
// Append to gear.
|
||||||
|
if (i.type === 'item') {
|
||||||
|
gear.push(i);
|
||||||
|
}
|
||||||
|
// Append to features.
|
||||||
|
else if (i.type === 'feature') {
|
||||||
|
features.push(i);
|
||||||
|
}
|
||||||
|
// Append to spells.
|
||||||
|
else if (i.type === 'spell') {
|
||||||
|
if (i.system.spellLevel != undefined) {
|
||||||
|
spells[i.system.spellLevel].push(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assign and return
|
||||||
|
context.gear = gear;
|
||||||
|
context.features = features;
|
||||||
|
context.spells = spells;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
|
||||||
|
/** @override */
|
||||||
|
activateListeners(html) {
|
||||||
|
super.activateListeners(html);
|
||||||
|
|
||||||
|
// Render the item sheet for viewing/editing prior to the editable check.
|
||||||
|
html.find('.item-edit').click(ev => {
|
||||||
|
const li = $(ev.currentTarget).parents(".item");
|
||||||
|
const item = this.actor.items.get(li.data("itemId"));
|
||||||
|
item.sheet.render(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
// -------------------------------------------------------------
|
||||||
|
// Everything below here is only needed if the sheet is editable
|
||||||
|
if (!this.isEditable) return;
|
||||||
|
|
||||||
|
// Add Inventory Item
|
||||||
|
html.find('.item-create').click(this._onItemCreate.bind(this));
|
||||||
|
|
||||||
|
// Delete Inventory Item
|
||||||
|
html.find('.item-delete').click(ev => {
|
||||||
|
const li = $(ev.currentTarget).parents(".item");
|
||||||
|
const item = this.actor.items.get(li.data("itemId"));
|
||||||
|
item.delete();
|
||||||
|
li.slideUp(200, () => this.render(false));
|
||||||
|
});
|
||||||
|
|
||||||
|
// Active Effect management
|
||||||
|
html.find(".effect-control").click(ev => onManageActiveEffect(ev, this.actor));
|
||||||
|
|
||||||
|
// Rollable abilities.
|
||||||
|
html.find('.rollable').click(this._onRoll.bind(this));
|
||||||
|
|
||||||
|
// Drag events for macros.
|
||||||
|
if (this.actor.isOwner) {
|
||||||
|
let handler = ev => this._onDragStart(ev);
|
||||||
|
html.find('li.item').each((i, li) => {
|
||||||
|
if (li.classList.contains("inventory-header")) return;
|
||||||
|
li.setAttribute("draggable", true);
|
||||||
|
li.addEventListener("dragstart", handler, false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle creating a new Owned Item for the actor using initial data defined in the HTML dataset
|
||||||
|
* @param {Event} event The originating click event
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
async _onItemCreate(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
const header = event.currentTarget;
|
||||||
|
// Get the type of item to create.
|
||||||
|
const type = header.dataset.type;
|
||||||
|
// Grab any data associated with this control.
|
||||||
|
const data = duplicate(header.dataset);
|
||||||
|
// Initialize a default name.
|
||||||
|
const name = `New ${type.capitalize()}`;
|
||||||
|
// Prepare the item object.
|
||||||
|
const itemData = {
|
||||||
|
name: name,
|
||||||
|
type: type,
|
||||||
|
system: data
|
||||||
|
};
|
||||||
|
// Remove the type from the dataset since it's in the itemData.type prop.
|
||||||
|
delete itemData.system["type"];
|
||||||
|
|
||||||
|
// Finally, create the item!
|
||||||
|
return await Item.create(itemData, {parent: this.actor});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle clickable rolls.
|
||||||
|
* @param {Event} event The originating click event
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
_onRoll(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
const element = event.currentTarget;
|
||||||
|
const dataset = element.dataset;
|
||||||
|
|
||||||
|
// Handle item rolls.
|
||||||
|
if (dataset.rollType) {
|
||||||
|
if (dataset.rollType == 'item') {
|
||||||
|
const itemId = element.closest('.item').dataset.itemId;
|
||||||
|
const item = this.actor.items.get(itemId);
|
||||||
|
if (item) return item.roll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle rolls that supply the formula directly.
|
||||||
|
if (dataset.roll) {
|
||||||
|
let label = dataset.label ? `[ability] ${dataset.label}` : '';
|
||||||
|
let roll = new Roll(dataset.roll, this.actor.getRollData());
|
||||||
|
roll.toMessage({
|
||||||
|
speaker: ChatMessage.getSpeaker({ actor: this.actor }),
|
||||||
|
flavor: label,
|
||||||
|
rollMode: game.settings.get('core', 'rollMode'),
|
||||||
|
});
|
||||||
|
return roll;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,231 @@
|
|||||||
|
import {onManageActiveEffect, prepareActiveEffectCategories} from "../system/effects.mjs";
|
||||||
|
import { TotemActorSheet } from "./actor-sheet.mjs";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extend the basic ActorSheet with some very simple modifications
|
||||||
|
* @extends {ActorSheet}
|
||||||
|
*/
|
||||||
|
export class TotemActorSheet extends ActorSheet {
|
||||||
|
|
||||||
|
/** @override */
|
||||||
|
static get defaultOptions() {
|
||||||
|
return mergeObject(super.defaultOptions, {
|
||||||
|
classes: ["totem", "sheet", "actor"],
|
||||||
|
template: "systems/totem/templates/actor/actor-sheet.html",
|
||||||
|
width: 600,
|
||||||
|
height: 600,
|
||||||
|
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "features" }]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @override */
|
||||||
|
get template() {
|
||||||
|
return `systems/totem/templates/actor/actor-${this.actor.type}-sheet.html`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
|
||||||
|
/** @override */
|
||||||
|
getData() {
|
||||||
|
// Retrieve the data structure from the base sheet. You can inspect or log
|
||||||
|
// the context variable to see the structure, but some key properties for
|
||||||
|
// sheets are the actor object, the data object, whether or not it's
|
||||||
|
// editable, the items array, and the effects array.
|
||||||
|
const context = super.getData();
|
||||||
|
|
||||||
|
// Use a safe clone of the actor data for further operations.
|
||||||
|
const actorData = this.actor.toObject(false);
|
||||||
|
|
||||||
|
// Add the actor's data to context.data for easier access, as well as flags.
|
||||||
|
context.system = actorData.system;
|
||||||
|
context.flags = actorData.flags;
|
||||||
|
context.config = CONFIG.TOTEM;
|
||||||
|
|
||||||
|
// Prepare character data and items.
|
||||||
|
if (actorData.type == 'character') {
|
||||||
|
this._prepareItems(context);
|
||||||
|
this._prepareCharacterData(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prepare NPC data and items.
|
||||||
|
if (actorData.type == 'npc') {
|
||||||
|
this._prepareItems(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add roll data for TinyMCE editors.
|
||||||
|
context.rollData = context.actor.getRollData();
|
||||||
|
|
||||||
|
// Prepare active effects
|
||||||
|
context.effects = prepareActiveEffectCategories(this.actor.effects);
|
||||||
|
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Organize and classify Items for Character sheets.
|
||||||
|
*
|
||||||
|
* @param {Object} actorData The actor to prepare.
|
||||||
|
*
|
||||||
|
* @return {undefined}
|
||||||
|
*/
|
||||||
|
_prepareCharacterData(context) {
|
||||||
|
// Handle ability scores.
|
||||||
|
for (let [k, v] of Object.entries(context.system.abilities)) {
|
||||||
|
v.label = game.i18n.localize(context.system.abilities[k].label) ?? k;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Organize and classify Items for Character sheets.
|
||||||
|
*
|
||||||
|
* @param {Object} actorData The actor to prepare.
|
||||||
|
*
|
||||||
|
* @return {undefined}
|
||||||
|
*/
|
||||||
|
_prepareItems(context) {
|
||||||
|
// Initialize containers.
|
||||||
|
const gear = [];
|
||||||
|
const features = [];
|
||||||
|
const spells = {
|
||||||
|
0: [],
|
||||||
|
1: [],
|
||||||
|
2: [],
|
||||||
|
3: [],
|
||||||
|
4: [],
|
||||||
|
5: [],
|
||||||
|
6: [],
|
||||||
|
7: [],
|
||||||
|
8: [],
|
||||||
|
9: []
|
||||||
|
};
|
||||||
|
|
||||||
|
// Iterate through items, allocating to containers
|
||||||
|
for (let i of context.items) {
|
||||||
|
i.img = i.img || DEFAULT_TOKEN;
|
||||||
|
// Append to gear.
|
||||||
|
if (i.type === 'item') {
|
||||||
|
gear.push(i);
|
||||||
|
}
|
||||||
|
// Append to features.
|
||||||
|
else if (i.type === 'feature') {
|
||||||
|
features.push(i);
|
||||||
|
}
|
||||||
|
// Append to spells.
|
||||||
|
else if (i.type === 'spell') {
|
||||||
|
if (i.system.spellLevel != undefined) {
|
||||||
|
spells[i.system.spellLevel].push(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assign and return
|
||||||
|
context.gear = gear;
|
||||||
|
context.features = features;
|
||||||
|
context.spells = spells;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
|
||||||
|
/** @override */
|
||||||
|
activateListeners(html) {
|
||||||
|
super.activateListeners(html);
|
||||||
|
|
||||||
|
// Render the item sheet for viewing/editing prior to the editable check.
|
||||||
|
html.find('.item-edit').click(ev => {
|
||||||
|
const li = $(ev.currentTarget).parents(".item");
|
||||||
|
const item = this.actor.items.get(li.data("itemId"));
|
||||||
|
item.sheet.render(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
// -------------------------------------------------------------
|
||||||
|
// Everything below here is only needed if the sheet is editable
|
||||||
|
if (!this.isEditable) return;
|
||||||
|
|
||||||
|
// Add Inventory Item
|
||||||
|
html.find('.item-create').click(this._onItemCreate.bind(this));
|
||||||
|
|
||||||
|
// Delete Inventory Item
|
||||||
|
html.find('.item-delete').click(ev => {
|
||||||
|
const li = $(ev.currentTarget).parents(".item");
|
||||||
|
const item = this.actor.items.get(li.data("itemId"));
|
||||||
|
item.delete();
|
||||||
|
li.slideUp(200, () => this.render(false));
|
||||||
|
});
|
||||||
|
|
||||||
|
// Active Effect management
|
||||||
|
html.find(".effect-control").click(ev => onManageActiveEffect(ev, this.actor));
|
||||||
|
|
||||||
|
// Rollable abilities.
|
||||||
|
html.find('.rollable').click(this._onRoll.bind(this));
|
||||||
|
|
||||||
|
// Drag events for macros.
|
||||||
|
if (this.actor.isOwner) {
|
||||||
|
let handler = ev => this._onDragStart(ev);
|
||||||
|
html.find('li.item').each((i, li) => {
|
||||||
|
if (li.classList.contains("inventory-header")) return;
|
||||||
|
li.setAttribute("draggable", true);
|
||||||
|
li.addEventListener("dragstart", handler, false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle creating a new Owned Item for the actor using initial data defined in the HTML dataset
|
||||||
|
* @param {Event} event The originating click event
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
async _onItemCreate(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
const header = event.currentTarget;
|
||||||
|
// Get the type of item to create.
|
||||||
|
const type = header.dataset.type;
|
||||||
|
// Grab any data associated with this control.
|
||||||
|
const data = duplicate(header.dataset);
|
||||||
|
// Initialize a default name.
|
||||||
|
const name = `New ${type.capitalize()}`;
|
||||||
|
// Prepare the item object.
|
||||||
|
const itemData = {
|
||||||
|
name: name,
|
||||||
|
type: type,
|
||||||
|
system: data
|
||||||
|
};
|
||||||
|
// Remove the type from the dataset since it's in the itemData.type prop.
|
||||||
|
delete itemData.system["type"];
|
||||||
|
|
||||||
|
// Finally, create the item!
|
||||||
|
return await Item.create(itemData, {parent: this.actor});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle clickable rolls.
|
||||||
|
* @param {Event} event The originating click event
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
_onRoll(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
const element = event.currentTarget;
|
||||||
|
const dataset = element.dataset;
|
||||||
|
|
||||||
|
// Handle item rolls.
|
||||||
|
if (dataset.rollType) {
|
||||||
|
if (dataset.rollType == 'item') {
|
||||||
|
const itemId = element.closest('.item').dataset.itemId;
|
||||||
|
const item = this.actor.items.get(itemId);
|
||||||
|
if (item) return item.roll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle rolls that supply the formula directly.
|
||||||
|
if (dataset.roll) {
|
||||||
|
let label = dataset.label ? `[ability] ${dataset.label}` : '';
|
||||||
|
let roll = new Roll(dataset.roll, this.actor.getRollData());
|
||||||
|
roll.toMessage({
|
||||||
|
speaker: ChatMessage.getSpeaker({ actor: this.actor }),
|
||||||
|
flavor: label,
|
||||||
|
rollMode: game.settings.get('core', 'rollMode'),
|
||||||
|
});
|
||||||
|
return roll;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,231 @@
|
|||||||
|
import {onManageActiveEffect, prepareActiveEffectCategories} from "../system/effects.mjs";
|
||||||
|
import { TotemActorSheet } from "./actor-sheet.mjs";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extend the basic ActorSheet with some very simple modifications
|
||||||
|
* @extends {TotemActorSheet}
|
||||||
|
*/
|
||||||
|
export class TotemNpcSheet extends TotemActorSheet {
|
||||||
|
|
||||||
|
/** @override */
|
||||||
|
static get defaultOptions() {
|
||||||
|
return mergeObject(super.defaultOptions, {
|
||||||
|
classes: ["totem", "sheet", "actor"],
|
||||||
|
template: "systems/totem/templates/actor/actor-sheet.html",
|
||||||
|
width: 600,
|
||||||
|
height: 600,
|
||||||
|
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "features" }]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @override */
|
||||||
|
get template() {
|
||||||
|
return `systems/totem/templates/actor/actor-${this.actor.type}-sheet.html`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
|
||||||
|
/** @override */
|
||||||
|
getData() {
|
||||||
|
// Retrieve the data structure from the base sheet. You can inspect or log
|
||||||
|
// the context variable to see the structure, but some key properties for
|
||||||
|
// sheets are the actor object, the data object, whether or not it's
|
||||||
|
// editable, the items array, and the effects array.
|
||||||
|
const context = super.getData();
|
||||||
|
|
||||||
|
// Use a safe clone of the actor data for further operations.
|
||||||
|
const actorData = this.actor.toObject(false);
|
||||||
|
|
||||||
|
// Add the actor's data to context.data for easier access, as well as flags.
|
||||||
|
context.system = actorData.system;
|
||||||
|
context.flags = actorData.flags;
|
||||||
|
context.config = CONFIG.TOTEM;
|
||||||
|
|
||||||
|
// Prepare character data and items.
|
||||||
|
if (actorData.type == 'character') {
|
||||||
|
this._prepareItems(context);
|
||||||
|
this._prepareCharacterData(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prepare NPC data and items.
|
||||||
|
if (actorData.type == 'npc') {
|
||||||
|
this._prepareItems(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add roll data for TinyMCE editors.
|
||||||
|
context.rollData = context.actor.getRollData();
|
||||||
|
|
||||||
|
// Prepare active effects
|
||||||
|
context.effects = prepareActiveEffectCategories(this.actor.effects);
|
||||||
|
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Organize and classify Items for Character sheets.
|
||||||
|
*
|
||||||
|
* @param {Object} actorData The actor to prepare.
|
||||||
|
*
|
||||||
|
* @return {undefined}
|
||||||
|
*/
|
||||||
|
_prepareCharacterData(context) {
|
||||||
|
// Handle ability scores.
|
||||||
|
for (let [k, v] of Object.entries(context.system.abilities)) {
|
||||||
|
v.label = game.i18n.localize(context.system.abilities[k].label) ?? k;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Organize and classify Items for Character sheets.
|
||||||
|
*
|
||||||
|
* @param {Object} actorData The actor to prepare.
|
||||||
|
*
|
||||||
|
* @return {undefined}
|
||||||
|
*/
|
||||||
|
_prepareItems(context) {
|
||||||
|
// Initialize containers.
|
||||||
|
const gear = [];
|
||||||
|
const features = [];
|
||||||
|
const spells = {
|
||||||
|
0: [],
|
||||||
|
1: [],
|
||||||
|
2: [],
|
||||||
|
3: [],
|
||||||
|
4: [],
|
||||||
|
5: [],
|
||||||
|
6: [],
|
||||||
|
7: [],
|
||||||
|
8: [],
|
||||||
|
9: []
|
||||||
|
};
|
||||||
|
|
||||||
|
// Iterate through items, allocating to containers
|
||||||
|
for (let i of context.items) {
|
||||||
|
i.img = i.img || DEFAULT_TOKEN;
|
||||||
|
// Append to gear.
|
||||||
|
if (i.type === 'item') {
|
||||||
|
gear.push(i);
|
||||||
|
}
|
||||||
|
// Append to features.
|
||||||
|
else if (i.type === 'feature') {
|
||||||
|
features.push(i);
|
||||||
|
}
|
||||||
|
// Append to spells.
|
||||||
|
else if (i.type === 'spell') {
|
||||||
|
if (i.system.spellLevel != undefined) {
|
||||||
|
spells[i.system.spellLevel].push(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assign and return
|
||||||
|
context.gear = gear;
|
||||||
|
context.features = features;
|
||||||
|
context.spells = spells;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
|
||||||
|
/** @override */
|
||||||
|
activateListeners(html) {
|
||||||
|
super.activateListeners(html);
|
||||||
|
|
||||||
|
// Render the item sheet for viewing/editing prior to the editable check.
|
||||||
|
html.find('.item-edit').click(ev => {
|
||||||
|
const li = $(ev.currentTarget).parents(".item");
|
||||||
|
const item = this.actor.items.get(li.data("itemId"));
|
||||||
|
item.sheet.render(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
// -------------------------------------------------------------
|
||||||
|
// Everything below here is only needed if the sheet is editable
|
||||||
|
if (!this.isEditable) return;
|
||||||
|
|
||||||
|
// Add Inventory Item
|
||||||
|
html.find('.item-create').click(this._onItemCreate.bind(this));
|
||||||
|
|
||||||
|
// Delete Inventory Item
|
||||||
|
html.find('.item-delete').click(ev => {
|
||||||
|
const li = $(ev.currentTarget).parents(".item");
|
||||||
|
const item = this.actor.items.get(li.data("itemId"));
|
||||||
|
item.delete();
|
||||||
|
li.slideUp(200, () => this.render(false));
|
||||||
|
});
|
||||||
|
|
||||||
|
// Active Effect management
|
||||||
|
html.find(".effect-control").click(ev => onManageActiveEffect(ev, this.actor));
|
||||||
|
|
||||||
|
// Rollable abilities.
|
||||||
|
html.find('.rollable').click(this._onRoll.bind(this));
|
||||||
|
|
||||||
|
// Drag events for macros.
|
||||||
|
if (this.actor.isOwner) {
|
||||||
|
let handler = ev => this._onDragStart(ev);
|
||||||
|
html.find('li.item').each((i, li) => {
|
||||||
|
if (li.classList.contains("inventory-header")) return;
|
||||||
|
li.setAttribute("draggable", true);
|
||||||
|
li.addEventListener("dragstart", handler, false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle creating a new Owned Item for the actor using initial data defined in the HTML dataset
|
||||||
|
* @param {Event} event The originating click event
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
async _onItemCreate(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
const header = event.currentTarget;
|
||||||
|
// Get the type of item to create.
|
||||||
|
const type = header.dataset.type;
|
||||||
|
// Grab any data associated with this control.
|
||||||
|
const data = duplicate(header.dataset);
|
||||||
|
// Initialize a default name.
|
||||||
|
const name = `New ${type.capitalize()}`;
|
||||||
|
// Prepare the item object.
|
||||||
|
const itemData = {
|
||||||
|
name: name,
|
||||||
|
type: type,
|
||||||
|
system: data
|
||||||
|
};
|
||||||
|
// Remove the type from the dataset since it's in the itemData.type prop.
|
||||||
|
delete itemData.system["type"];
|
||||||
|
|
||||||
|
// Finally, create the item!
|
||||||
|
return await Item.create(itemData, {parent: this.actor});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle clickable rolls.
|
||||||
|
* @param {Event} event The originating click event
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
_onRoll(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
const element = event.currentTarget;
|
||||||
|
const dataset = element.dataset;
|
||||||
|
|
||||||
|
// Handle item rolls.
|
||||||
|
if (dataset.rollType) {
|
||||||
|
if (dataset.rollType == 'item') {
|
||||||
|
const itemId = element.closest('.item').dataset.itemId;
|
||||||
|
const item = this.actor.items.get(itemId);
|
||||||
|
if (item) return item.roll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle rolls that supply the formula directly.
|
||||||
|
if (dataset.roll) {
|
||||||
|
let label = dataset.label ? `[ability] ${dataset.label}` : '';
|
||||||
|
let roll = new Roll(dataset.roll, this.actor.getRollData());
|
||||||
|
roll.toMessage({
|
||||||
|
speaker: ChatMessage.getSpeaker({ actor: this.actor }),
|
||||||
|
flavor: label,
|
||||||
|
rollMode: game.settings.get('core', 'rollMode'),
|
||||||
|
});
|
||||||
|
return roll;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -49,7 +49,7 @@ TOTEM.skillCategories = {
|
|||||||
"animal": {
|
"animal": {
|
||||||
"label":"TOTEM.skillCategory.animal"
|
"label":"TOTEM.skillCategory.animal"
|
||||||
},
|
},
|
||||||
"machine": {
|
"tool": {
|
||||||
"label":"TOTEM.skillCategory.machine"
|
"label":"TOTEM.skillCategory.machine"
|
||||||
},
|
},
|
||||||
"weapon": {
|
"weapon": {
|
||||||
@@ -58,7 +58,7 @@ TOTEM.skillCategories = {
|
|||||||
"survival": {
|
"survival": {
|
||||||
"label":"TOTEM.skillCategory.survival"
|
"label":"TOTEM.skillCategory.survival"
|
||||||
},
|
},
|
||||||
"earth": {
|
"world": {
|
||||||
"label":"TOTEM.skillCategory.earth"
|
"label":"TOTEM.skillCategory.earth"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
/**
|
||||||
|
* Define a set of template paths to pre-load
|
||||||
|
* Pre-loaded templates are compiled and cached for fast access when rendering
|
||||||
|
* @return {Promise}
|
||||||
|
*/
|
||||||
|
export const preloadHandlebarsTemplates = async function() {
|
||||||
|
return loadTemplates([
|
||||||
|
|
||||||
|
// Actor partials.
|
||||||
|
"systems/totem/templates/actor/parts/actor-traits.html",
|
||||||
|
"systems/totem/templates/actor/parts/actor-background.html",
|
||||||
|
"systems/totem/templates/actor/parts/actor-skills.html",
|
||||||
|
"systems/totem/templates/actor/parts/actor-items.html",
|
||||||
|
"systems/totem/templates/actor/parts/actor-effects.html",
|
||||||
|
]);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export const registerHandlebarsHelpers = function () {
|
||||||
|
Handlebars.registerHelper('concat', (...args) => args.slice(0, -1).join(''));
|
||||||
|
Handlebars.registerHelper('lower', e => e.toLocaleLowerCase());
|
||||||
|
|
||||||
|
Handlebars.registerHelper('toLowerCase', function(str) {
|
||||||
|
return str.toLowerCase();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Ifis not equal
|
||||||
|
Handlebars.registerHelper('ifne', function (v1, v2, options) {
|
||||||
|
if (v1 !== v2) return options.fn(this);
|
||||||
|
else return options.inverse(this);
|
||||||
|
});
|
||||||
|
|
||||||
|
// if equal
|
||||||
|
Handlebars.registerHelper('ife', function (v1, v2, options) {
|
||||||
|
if (v1 === v2) return options.fn(this);
|
||||||
|
else return options.inverse(this);
|
||||||
|
});
|
||||||
|
// if equal
|
||||||
|
Handlebars.registerHelper('ifgt', function (v1, v2, options) {
|
||||||
|
if (v1 > v2) return options.fn(this);
|
||||||
|
else return options.inverse(this);
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
export const registerHandlebarsHelpers = function () {
|
|
||||||
Handlebars.registerHelper('concat', (...args) => args.slice(0, -1).join(''));
|
|
||||||
Handlebars.registerHelper('lower', e => e.toLocaleLowerCase());
|
|
||||||
|
|
||||||
Handlebars.registerHelper('toLowerCase', function(str) {
|
|
||||||
return str.toLowerCase();
|
|
||||||
});
|
|
||||||
|
|
||||||
// Ifis not equal
|
|
||||||
Handlebars.registerHelper('ifne', function (v1, v2, options) {
|
|
||||||
if (v1 !== v2) return options.fn(this);
|
|
||||||
else return options.inverse(this);
|
|
||||||
});
|
|
||||||
|
|
||||||
// if equal
|
|
||||||
Handlebars.registerHelper('ife', function (v1, v2, options) {
|
|
||||||
if (v1 === v2) return options.fn(this);
|
|
||||||
else return options.inverse(this);
|
|
||||||
});
|
|
||||||
// if equal
|
|
||||||
Handlebars.registerHelper('ifgt', function (v1, v2, options) {
|
|
||||||
if (v1 > v2) return options.fn(this);
|
|
||||||
else return options.inverse(this);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
/**
|
|
||||||
* Define a set of template paths to pre-load
|
|
||||||
* Pre-loaded templates are compiled and cached for fast access when rendering
|
|
||||||
* @return {Promise}
|
|
||||||
*/
|
|
||||||
export const preloadHandlebarsTemplates = async function() {
|
|
||||||
return loadTemplates([
|
|
||||||
|
|
||||||
// Actor partials.
|
|
||||||
"systems/totem/templates/actor/parts/actor-traits.html",
|
|
||||||
"systems/totem/templates/actor/parts/actor-background.html",
|
|
||||||
"systems/totem/templates/actor/parts/actor-skills.html",
|
|
||||||
"systems/totem/templates/actor/parts/actor-items.html",
|
|
||||||
"systems/totem/templates/actor/parts/actor-cephalie.html",
|
|
||||||
"systems/totem/templates/actor/parts/actor-effects.html",
|
|
||||||
]);
|
|
||||||
};
|
|
||||||
+28
-7
@@ -1,15 +1,21 @@
|
|||||||
import { registerHandlebarsHelpers } from "./system/helpers.mjs";
|
|
||||||
import { registerHooks } from "./system/hooks.mjs";
|
import { registerHooks } from "./system/hooks.mjs";
|
||||||
import { registerSettings } from "./system/settings.mjs";
|
import { registerSettings } from "./system/settings.mjs";
|
||||||
|
|
||||||
// Import document classes.
|
// Import document classes.
|
||||||
import { TotemActor } from "./documents/actor.mjs";
|
import { TotemActor } from "./documents/actor.mjs";
|
||||||
|
import { TotemCharacter } from "./documents/character.mjs";
|
||||||
|
import { TotemNpc } from "./documents/npc.mjs";
|
||||||
|
import { TotemCreature } from "./documents/creature.mjs";
|
||||||
|
|
||||||
|
import { TotemCharacterSheet } from "./sheets/character-sheet.mjs";
|
||||||
|
import { TotemNpcSheet } from "./sheets/npc-sheet.mjs";
|
||||||
|
import { TotemCreatureSheet } from "./sheets/creature-sheet.mjs";
|
||||||
|
|
||||||
import { TotemItem } from "./documents/item.mjs";
|
import { TotemItem } from "./documents/item.mjs";
|
||||||
// Import sheet classes.
|
|
||||||
import { TotemActorSheet } from "./sheets/actor-sheet.mjs";
|
|
||||||
import { TotemItemSheet } from "./sheets/item-sheet.mjs";
|
import { TotemItemSheet } from "./sheets/item-sheet.mjs";
|
||||||
|
|
||||||
// Import helper/utility classes and constants.
|
// Import helper/utility classes and constants.
|
||||||
import { preloadHandlebarsTemplates } from "./helpers/templates.mjs";
|
import { preloadHandlebarsTemplates, registerHandlebarsHelpers } from "./system/handlebars-manager.mjs";
|
||||||
import { TOTEM } from "./system/config.mjs";
|
import { TOTEM } from "./system/config.mjs";
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@@ -21,7 +27,9 @@ Hooks.once('init', async function() {
|
|||||||
// Add utility classes to the global game object so that they're more easily
|
// Add utility classes to the global game object so that they're more easily
|
||||||
// accessible in global contexts.
|
// accessible in global contexts.
|
||||||
game.totem = {
|
game.totem = {
|
||||||
TotemActor,
|
TotemCharacter,
|
||||||
|
TotemNpc,
|
||||||
|
TotemCreature,
|
||||||
TotemItem,
|
TotemItem,
|
||||||
rollItemMacro
|
rollItemMacro
|
||||||
};
|
};
|
||||||
@@ -34,7 +42,7 @@ Hooks.once('init', async function() {
|
|||||||
* @type {String}
|
* @type {String}
|
||||||
*/
|
*/
|
||||||
CONFIG.Combat.initiative = {
|
CONFIG.Combat.initiative = {
|
||||||
formula: "1d20 + @abilities.dex.mod",
|
formula: "1d10 + @abilities.dex.mod",
|
||||||
decimals: 2
|
decimals: 2
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -44,7 +52,20 @@ Hooks.once('init', async function() {
|
|||||||
|
|
||||||
// Register sheet application classes
|
// Register sheet application classes
|
||||||
Actors.unregisterSheet("core", ActorSheet);
|
Actors.unregisterSheet("core", ActorSheet);
|
||||||
Actors.registerSheet("totem", TotemActorSheet, { makeDefault: true });
|
Actors.registerSheet('totem', TotemCharacterSheet, {
|
||||||
|
types: ['character'],
|
||||||
|
makeDefault: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
Actors.registerSheet('totem', TotemNpcSheet, {
|
||||||
|
types: ['npc'],
|
||||||
|
makeDefault: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
Actors.registerSheet('totem', TotemCreatureSheet, {
|
||||||
|
types: ['creature'],
|
||||||
|
makeDefault: true,
|
||||||
|
}); // Register vehicle Sheet
|
||||||
Items.unregisterSheet("core", ItemSheet);
|
Items.unregisterSheet("core", ItemSheet);
|
||||||
Items.registerSheet("totem", TotemItemSheet, { makeDefault: true });
|
Items.registerSheet("totem", TotemItemSheet, { makeDefault: true });
|
||||||
|
|
||||||
|
|||||||
+11
-11
@@ -187,7 +187,7 @@
|
|||||||
"value": 0,
|
"value": 0,
|
||||||
"min": 0,
|
"min": 0,
|
||||||
"max": 5,
|
"max": 5,
|
||||||
"category": "machine",
|
"category": "tool",
|
||||||
"rarity":2
|
"rarity":2
|
||||||
},
|
},
|
||||||
"diy": {
|
"diy": {
|
||||||
@@ -195,7 +195,7 @@
|
|||||||
"value": 0,
|
"value": 0,
|
||||||
"min": 0,
|
"min": 0,
|
||||||
"max": 5,
|
"max": 5,
|
||||||
"category": "machine",
|
"category": "tool",
|
||||||
"rarity":0
|
"rarity":0
|
||||||
},
|
},
|
||||||
"mecanical": {
|
"mecanical": {
|
||||||
@@ -203,7 +203,7 @@
|
|||||||
"value": 0,
|
"value": 0,
|
||||||
"min": 0,
|
"min": 0,
|
||||||
"max": 5,
|
"max": 5,
|
||||||
"category": "machine",
|
"category": "tool",
|
||||||
"rarity":2
|
"rarity":2
|
||||||
},
|
},
|
||||||
"driving": {
|
"driving": {
|
||||||
@@ -211,7 +211,7 @@
|
|||||||
"value": 0,
|
"value": 0,
|
||||||
"min": 0,
|
"min": 0,
|
||||||
"max": 5,
|
"max": 5,
|
||||||
"category": "machine",
|
"category": "tool",
|
||||||
"rarity":1
|
"rarity":1
|
||||||
},
|
},
|
||||||
"technology": {
|
"technology": {
|
||||||
@@ -219,7 +219,7 @@
|
|||||||
"value": 0,
|
"value": 0,
|
||||||
"min": 0,
|
"min": 0,
|
||||||
"max": 5,
|
"max": 5,
|
||||||
"category": "machine",
|
"category": "tool",
|
||||||
"rarity":2
|
"rarity":2
|
||||||
},
|
},
|
||||||
"firearms": {
|
"firearms": {
|
||||||
@@ -307,7 +307,7 @@
|
|||||||
"value": 0,
|
"value": 0,
|
||||||
"min": 0,
|
"min": 0,
|
||||||
"max": 5,
|
"max": 5,
|
||||||
"category": "earth",
|
"category": "world",
|
||||||
"rarity":0
|
"rarity":0
|
||||||
},
|
},
|
||||||
"flora": {
|
"flora": {
|
||||||
@@ -315,7 +315,7 @@
|
|||||||
"value": 0,
|
"value": 0,
|
||||||
"min": 0,
|
"min": 0,
|
||||||
"max": 5,
|
"max": 5,
|
||||||
"category": "earth",
|
"category": "world",
|
||||||
"rarity":0
|
"rarity":0
|
||||||
},
|
},
|
||||||
"road": {
|
"road": {
|
||||||
@@ -323,7 +323,7 @@
|
|||||||
"value": 0,
|
"value": 0,
|
||||||
"min": 0,
|
"min": 0,
|
||||||
"max": 5,
|
"max": 5,
|
||||||
"category": "earth",
|
"category": "world",
|
||||||
"rarity":0
|
"rarity":0
|
||||||
},
|
},
|
||||||
"toxics": {
|
"toxics": {
|
||||||
@@ -331,7 +331,7 @@
|
|||||||
"value": 0,
|
"value": 0,
|
||||||
"min": 0,
|
"min": 0,
|
||||||
"max": 5,
|
"max": 5,
|
||||||
"category": "earth",
|
"category": "world",
|
||||||
"rarity":0
|
"rarity":0
|
||||||
},
|
},
|
||||||
"remains": {
|
"remains": {
|
||||||
@@ -339,7 +339,7 @@
|
|||||||
"value": 0,
|
"value": 0,
|
||||||
"min": 0,
|
"min": 0,
|
||||||
"max": 5,
|
"max": 5,
|
||||||
"category": "earth",
|
"category": "world",
|
||||||
"rarity":0
|
"rarity":0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -394,7 +394,7 @@
|
|||||||
"templates": ["base"],
|
"templates": ["base"],
|
||||||
"quantity": 1,
|
"quantity": 1,
|
||||||
"weight": 0,
|
"weight": 0,
|
||||||
"formula": "d20 + @str.mod + ceil(@lvl / 2)"
|
"formula": "d10 + @str.mod + ceil(@lvl / 2)"
|
||||||
},
|
},
|
||||||
"feature": {
|
"feature": {
|
||||||
"templates": ["base"]
|
"templates": ["base"]
|
||||||
|
|||||||
@@ -62,7 +62,7 @@
|
|||||||
|
|
||||||
{{#ife skill.category sckey }}
|
{{#ife skill.category sckey }}
|
||||||
<div class="ability flexrow flex-group-center">
|
<div class="ability flexrow flex-group-center">
|
||||||
<label style="flex:80%;" for="system.skills.{{skey}}.value" class="resource-label rollable flexlarge align-left" data-roll="d20+@skills.{{skey}}.mod" data-label="{{skill.label}}">{{ localize skill.label}}</label>
|
<label style="flex:80%;" for="system.skills.{{skey}}.value" class="resource-label rollable flexlarge align-left" data-roll="+@skills.{{skey}}d10" data-label="{{skill.label}}">{{ localize skill.label}} ({{skill.rarity}})</label>
|
||||||
<input type="text" name="system.skills.{{skey}}.value" value="{{skill.value}}" data-dtype="Number"/>
|
<input type="text" name="system.skills.{{skey}}.value" value="{{skill.value}}" data-dtype="Number"/>
|
||||||
</div>
|
</div>
|
||||||
{{/ife}}
|
{{/ife}}
|
||||||
|
|||||||
Reference in New Issue
Block a user