Initial import

This commit is contained in:
2021-05-28 18:16:02 +02:00
commit 2f5722e0df
45 changed files with 14637 additions and 0 deletions

228
module/actor/actor-sheet.js Normal file
View File

@@ -0,0 +1,228 @@
/**
* Extend the basic ActorSheet with some very simple modifications
* @extends {ActorSheet}
*/
export class frostgraveActorSheet extends ActorSheet {
/** @override */
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
classes: ["frostgrave", "sheet", "actor"],
template: "systems/frostgrave/templates/actor/actor-sheet.html",
width: 650,
height: 650,
tabs: [{
navSelector: ".sheet-tabs",
contentSelector: ".sheet-body",
initial: "items",
}, ],
});
}
/* -------------------------------------------- */
/** @override */
getData() {
const data = super.getData();
data.dtypes = ["String", "Number", "Boolean"];
//for (let attr of Object.values(data.data.attributes)) {
// attr.isCheckbox = attr.dtype === "Boolean";
// }
// Prepare items.
if (this.actor.data.type == "character") {
this._prepareCharacterItems(data);
}
return data;
}
/** @override */
activateListeners(html) {
super.activateListeners(html);
// Everything below here is only needed if the sheet is editable
if (!this.options.editable) return;
// Add Inventory Item
html.find(".item-create").click(this._onItemCreate.bind(this));
// Edit Inventory Item
html.find(".item-edit").click((ev) => {
const card = $(ev.currentTarget).parents(".item-card");
const item = this.actor.getOwnedItem(card.data("item-id"));
item.sheet.render(true);
});
// Delete Inventory Item
html.find(".item-delete").click((ev) => {
const card = $(ev.currentTarget).parents(".item-card");
this.actor.deleteOwnedItem(card.data("item-id"));
});
// Rollable abilities.
html.find(".rollable").click(this._onRoll.bind(this));
}
/* -------------------------------------------- */
/**
* 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
*/
_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,
data: data,
};
// Remove the type from the dataset since it's in the itemData.type prop.
delete itemData.data["type"];
// Finally, create the item!
return this.actor.createOwnedItem(itemData);
}
/**
* Handle clickable rolls.
* @param {Event} event The originating click event
* @private
*/
_onRoll(event) {
event.preventDefault();
const element = event.currentTarget;
const dataset = element.dataset;
if (dataset.roll) {
let roll = new Roll(dataset.roll, this.actor.data.data);
let damage = parseInt(roll.roll().total) + parseInt(dataset.bonus);
let rollflavor = `${dataset.label} Roll: ` + roll.total;
if (dataset.label == "Combat" || dataset.label == "Shooting") {
let damageflavor = `<br>Damage: ` + damage;
rollflavor = rollflavor + damageflavor;
}
roll.toMessage({
speaker: ChatMessage.getSpeaker({
actor: this.actor
}),
flavor: rollflavor,
});
}
if (dataset.spell) {
let alignment = dataset.alignment;
let empowerment = this.actor.data.data.empowerment;
let alignmentmod;
let selfdamage;
let castresult;
if (alignment == "Native") {
alignmentmod = 0;
} else if (alignment == "Aligned") {
alignmentmod = 2;
} else if (alignment == "Neutral") {
alignmentmod = 4;
} else {
alignmentmod = 6;
};
let difficulty = dataset.bcn - dataset.improved + alignmentmod;
let roll = new Roll(`1d20+` + empowerment);
//let roll = new Roll(`(1d20+` + empowerment + `)ms>=` + difficulty);
roll.roll();
let rollresult = difficulty - roll.total;
if (rollresult >= 20) {
selfdamage = 5;
} else if (rollresult >= 10) {
selfdamage = 2;
} else if (rollresult >= 5) {
selfdamage = 1;
} else {
selfdamage = 0;
};
selfdamage = selfdamage + empowerment;
if (rollresult <= 0) {
castresult = '<strong style="color: green; font-size: 18px;">SUCCESS</strong>';
} else {
castresult = '<strong style="color: red; font-size: 18px;">FAILURE</strong>';
};
let rollflavor = `Casting <strong>${dataset.label}</strong> vs Difficulty <strong>` + difficulty + `</strong><br>` + castresult +
`<br>BCN: ${dataset.bcn} | Alignment: +` + alignmentmod + ` | Improved: -${dataset.improved}
<br>Empowerment: ` + empowerment + ` | Self Damage: ` + selfdamage;
roll.toMessage({
speaker: ChatMessage.getSpeaker({
actor: this.actor
}),
flavor: rollflavor,
});
}
}
/**
* Organize and classify Items for Character sheets.
*
* @param {Object} actorData The actor to prepare.
*
* @return {undefined}
*/
_prepareCharacterItems(sheetData) {
const actorData = sheetData.actor;
// Initialize containers.
const gear = [];
const features = [];
const spells = [];
// Iterate through items, allocating to containers
// let totalWeight = 0;
for (let i of sheetData.items) {
let item = i.data;
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") {
spells.push(i);
}
}
// Assign and return
actorData.gear = gear;
actorData.features = features;
actorData.spells = spells;
}
}

33
module/actor/actor.js Normal file
View File

@@ -0,0 +1,33 @@
/**
* Extend the base Actor entity by defining a custom roll data structure which is ideal for the Simple system.
* @extends {Actor}
*/
export class frostgraveActor extends Actor {
/**
* Augment the basic actor data with additional dynamic data.
*/
prepareData() {
super.prepareData();
const actorData = this.data;
const data = actorData.data;
const flags = actorData.flags;
// Make separate methods for each Actor type (character, npc, etc.) to keep
// things organized.
if (actorData.type === 'character') this._prepareCharacterData(actorData);
}
/**
* Prepare Character type specific data
*/
_prepareCharacterData(actorData) {
const data = actorData.data;
// Make modifications to data here. For example:
data.exptotal = data.expscenario + data.expbanked;
}
}

236
module/actor/dist/actor-sheet.dev.js vendored Normal file
View File

@@ -0,0 +1,236 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.frostgraveActorSheet = void 0;
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
/**
* Extend the basic ActorSheet with some very simple modifications
* @extends {ActorSheet}
*/
var frostgraveActorSheet =
/*#__PURE__*/
function (_ActorSheet) {
_inherits(frostgraveActorSheet, _ActorSheet);
function frostgraveActorSheet() {
_classCallCheck(this, frostgraveActorSheet);
return _possibleConstructorReturn(this, _getPrototypeOf(frostgraveActorSheet).apply(this, arguments));
}
_createClass(frostgraveActorSheet, [{
key: "getData",
/* -------------------------------------------- */
/** @override */
value: function getData() {
var data = _get(_getPrototypeOf(frostgraveActorSheet.prototype), "getData", this).call(this);
data.dtypes = ["String", "Number", "Boolean"]; //for (let attr of Object.values(data.data.attributes)) {
// attr.isCheckbox = attr.dtype === "Boolean";
// }
// Prepare items.
if (this.actor.data.type == "character") {
this._prepareCharacterItems(data);
}
return data;
}
/** @override */
}, {
key: "activateListeners",
value: function activateListeners(html) {
var _this = this;
_get(_getPrototypeOf(frostgraveActorSheet.prototype), "activateListeners", this).call(this, html); // Everything below here is only needed if the sheet is editable
if (!this.options.editable) return; // Add Inventory Item
html.find(".item-create").click(this._onItemCreate.bind(this)); // Edit Inventory Item
html.find(".item-edit").click(function (ev) {
var card = $(ev.currentTarget).parents(".item-card");
var item = _this.actor.getOwnedItem(card.data("item-id"));
item.sheet.render(true);
}); // Delete Inventory Item
html.find(".item-delete").click(function (ev) {
var card = $(ev.currentTarget).parents(".item-card");
_this.actor.deleteOwnedItem(card.data("item-id"));
}); // Rollable abilities.
html.find(".rollable").click(this._onRoll.bind(this));
}
/* -------------------------------------------- */
/**
* 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
*/
}, {
key: "_onItemCreate",
value: function _onItemCreate(event) {
event.preventDefault();
var header = event.currentTarget; // Get the type of item to create.
var type = header.dataset.type; // Grab any data associated with this control.
var data = duplicate(header.dataset); // Initialize a default name.
var name = "New ".concat(type.capitalize()); // Prepare the item object.
var itemData = {
name: name,
type: type,
data: data
}; // Remove the type from the dataset since it's in the itemData.type prop.
delete itemData.data["type"]; // Finally, create the item!
return this.actor.createOwnedItem(itemData);
}
/**
* Handle clickable rolls.
* @param {Event} event The originating click event
* @private
*/
}, {
key: "_onRoll",
value: function _onRoll(event) {
event.preventDefault();
var element = event.currentTarget;
var dataset = element.dataset;
if (dataset.roll) {
var roll = new Roll(dataset.roll, this.actor.data.data);
var damage = parseInt(roll.roll().total) + parseInt(dataset.bonus);
var rollflavor = "".concat(dataset.label, " Roll: ") + roll.total;
if (dataset.label == "Combat" || dataset.label == "Shooting") {
var damageflavor = "<br>Damage: " + damage;
rollflavor = rollflavor + damageflavor;
}
roll.toMessage({
speaker: ChatMessage.getSpeaker({
actor: this.actor
}),
flavor: rollflavor
});
}
}
/**
* Organize and classify Items for Character sheets.
*
* @param {Object} actorData The actor to prepare.
*
* @return {undefined}
*/
}, {
key: "_prepareCharacterItems",
value: function _prepareCharacterItems(sheetData) {
var actorData = sheetData.actor; // Initialize containers.
var gear = [];
var features = [];
var spells = []; // Iterate through items, allocating to containers
// let totalWeight = 0;
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = sheetData.items[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var i = _step.value;
var item = i.data;
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") {
spells.push(i);
}
} // Assign and return
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator["return"] != null) {
_iterator["return"]();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
actorData.gear = gear;
actorData.features = features;
actorData.spells = spells;
}
}], [{
key: "defaultOptions",
/** @override */
get: function get() {
return mergeObject(_get(_getPrototypeOf(frostgraveActorSheet), "defaultOptions", this), {
classes: ["frostgrave", "sheet", "actor"],
template: "systems/frostgrave/templates/actor/actor-sheet.html",
width: 600,
height: 650,
tabs: [{
navSelector: ".sheet-tabs",
contentSelector: ".sheet-body",
initial: "items"
}]
});
}
}]);
return frostgraveActorSheet;
}(ActorSheet);
exports.frostgraveActorSheet = frostgraveActorSheet;

77
module/actor/dist/actor.dev.js vendored Normal file
View File

@@ -0,0 +1,77 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.frostgraveActor = void 0;
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
/**
* Extend the base Actor entity by defining a custom roll data structure which is ideal for the Simple system.
* @extends {Actor}
*/
var frostgraveActor =
/*#__PURE__*/
function (_Actor) {
_inherits(frostgraveActor, _Actor);
function frostgraveActor() {
_classCallCheck(this, frostgraveActor);
return _possibleConstructorReturn(this, _getPrototypeOf(frostgraveActor).apply(this, arguments));
}
_createClass(frostgraveActor, [{
key: "prepareData",
/**
* Augment the basic actor data with additional dynamic data.
*/
value: function prepareData() {
_get(_getPrototypeOf(frostgraveActor.prototype), "prepareData", this).call(this);
var actorData = this.data;
var data = actorData.data;
var flags = actorData.flags; // Make separate methods for each Actor type (character, npc, etc.) to keep
// things organized.
if (actorData.type === 'character') this._prepareCharacterData(actorData);
}
/**
* Prepare Character type specific data
*/
}, {
key: "_prepareCharacterData",
value: function _prepareCharacterData(actorData) {
var data = actorData.data; // Make modifications to data here. For example:
data.exptotal = data.expscenario + data.expbanked;
}
}]);
return frostgraveActor;
}(Actor);
exports.frostgraveActor = frostgraveActor;

57
module/frostgrave.js Normal file
View File

@@ -0,0 +1,57 @@
// Import Modules
import { frostgraveActor } from "./actor/actor.js";
import { frostgraveActorSheet } from "./actor/actor-sheet.js";
import { frostgraveItem } from "./item/item.js";
import { frostgraveItemSheet } from "./item/item-sheet.js";
import { preloadHandlebarsTemplates } from "./templates.js";
Hooks.once("init", async function () {
game.frostgrave = {
frostgraveActor,
frostgraveItem,
};
/**
* Set an initiative formula for the system
* @type {String}
*/
CONFIG.Combat.initiative = {
formula: "1d20",
decimals: 2,
};
// Define custom Entity classes
CONFIG.Actor.entityClass = frostgraveActor;
CONFIG.Item.entityClass = frostgraveItem;
// Register sheet application classes
Actors.unregisterSheet("core", ActorSheet);
Actors.registerSheet("frostgrave", frostgraveActorSheet, {
makeDefault: true,
});
Items.unregisterSheet("core", ItemSheet);
Items.registerSheet("frostgrave", frostgraveItemSheet, {
types: ["item", "feature", "spell"],
makeDefault: true,
});
// If you need to add Handlebars helpers, here are a few useful examples:
Handlebars.registerHelper("concat", function () {
var outStr = "";
for (var arg in arguments) {
if (typeof arguments[arg] != "object") {
outStr += arguments[arg];
}
}
return outStr;
});
Handlebars.registerHelper("toLowerCase", function (str) {
return str.toLowerCase();
});
// Preload Handlebars Templates
preloadHandlebarsTemplates();
});

117
module/item/dist/item-sheet.dev.js vendored Normal file
View File

@@ -0,0 +1,117 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.frostgraveItemSheet = void 0;
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
/**
* Extend the basic ItemSheet with some very simple modifications
* @extends {ItemSheet}
*/
var frostgraveItemSheet =
/*#__PURE__*/
function (_ItemSheet) {
_inherits(frostgraveItemSheet, _ItemSheet);
function frostgraveItemSheet() {
_classCallCheck(this, frostgraveItemSheet);
return _possibleConstructorReturn(this, _getPrototypeOf(frostgraveItemSheet).apply(this, arguments));
}
_createClass(frostgraveItemSheet, [{
key: "getData",
/* -------------------------------------------- */
/** @override */
value: function getData() {
var data = _get(_getPrototypeOf(frostgraveItemSheet.prototype), "getData", this).call(this);
return data;
}
/* -------------------------------------------- */
/** @override */
}, {
key: "setPosition",
value: function setPosition() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var position = _get(_getPrototypeOf(frostgraveItemSheet.prototype), "setPosition", this).call(this, options);
var sheetBody = this.element.find(".sheet-body");
var bodyHeight = position.height - 192;
sheetBody.css("height", bodyHeight);
return position;
}
/* -------------------------------------------- */
/** @override */
}, {
key: "activateListeners",
value: function activateListeners(html) {
_get(_getPrototypeOf(frostgraveItemSheet.prototype), "activateListeners", this).call(this, html); // Everything below here is only needed if the sheet is editable
if (!this.options.editable) return; // Roll handlers, click handlers, etc. would go here.
}
}, {
key: "template",
/** @override */
get: function get() {
var path = "systems/frostgrave/templates/item"; // Return a single sheet for all item types.
// return `${path}/item-sheet.html`;
// Alternatively, you could use the following return statement to do a
// unique item sheet by type, like `weapon-sheet.html`.
return "".concat(path, "/item-").concat(this.item.data.type, "-sheet.html");
}
}], [{
key: "defaultOptions",
/** @override */
get: function get() {
return mergeObject(_get(_getPrototypeOf(frostgraveItemSheet), "defaultOptions", this), {
classes: ["frostgrave", "sheet", "item"],
width: 450,
height: 500,
tabs: [{
navSelector: ".sheet-tabs",
contentSelector: ".sheet-body",
initial: "attributes"
}]
});
}
}]);
return frostgraveItemSheet;
}(ItemSheet);
exports.frostgraveItemSheet = frostgraveItemSheet;

61
module/item/item-sheet.js Normal file
View File

@@ -0,0 +1,61 @@
/**
* Extend the basic ItemSheet with some very simple modifications
* @extends {ItemSheet}
*/
export class frostgraveItemSheet extends ItemSheet {
/** @override */
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
classes: ["frostgrave", "sheet", "item"],
width: 450,
height: 500,
tabs: [{
navSelector: ".sheet-tabs",
contentSelector: ".sheet-body",
initial: "attributes",
}, ],
});
}
/** @override */
get template() {
const path = "systems/frostgrave/templates/item";
// Return a single sheet for all item types.
// return `${path}/item-sheet.html`;
// Alternatively, you could use the following return statement to do a
// unique item sheet by type, like `weapon-sheet.html`.
return `${path}/item-${this.item.data.type}-sheet.html`;
}
/* -------------------------------------------- */
/** @override */
getData() {
const data = super.getData();
return data;
}
/* -------------------------------------------- */
/** @override */
setPosition(options = {}) {
const position = super.setPosition(options);
const sheetBody = this.element.find(".sheet-body");
const bodyHeight = position.height - 192;
sheetBody.css("height", bodyHeight);
return position;
}
/* -------------------------------------------- */
/** @override */
activateListeners(html) {
super.activateListeners(html);
// Everything below here is only needed if the sheet is editable
if (!this.options.editable) return;
// Roll handlers, click handlers, etc. would go here.
}
}

37
module/item/item.js Normal file
View File

@@ -0,0 +1,37 @@
/**
* Extend the basic Item with some very simple modifications.
* @extends {Item}
*/
export class frostgraveItem extends Item {
/**
* Augment the basic Item data model with additional dynamic data.
*/
prepareData() {
super.prepareData();
// Get the Item's data
const itemData = this.data;
const actorData = this.actor ? this.actor.data : {};
const data = itemData.data;
}
/**
* Handle clickable rolls.
* @param {Event} event The originating click event
* @private
*/
async roll() {
// Basic template rendering data
const token = this.actor.token;
const item = this.data;
const actorData = this.actor ? this.actor.data.data : {};
const itemData = item.data;
let roll = new Roll("d20+@stats.fight.value", actorData);
let label = `Rolling ${item.name}`;
roll.roll().toMessage({
speaker: ChatMessage.getSpeaker({ actor: this.actor }),
flavor: label,
});
}
}

28
module/templates.js Normal file
View File

@@ -0,0 +1,28 @@
/**
* 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() {
// Define template paths to load
const templatePaths = [
// Actor Sheet Partials
"systems/frostgrave/templates/actor/partials/actor-header.html",
"systems/frostgrave/templates/actor/partials/actor-stats.html",
"systems/frostgrave/templates/actor/partials/actor-tab-navigation.html",
"systems/frostgrave/templates/actor/partials/actor-tab-notes.html",
"systems/frostgrave/templates/actor/partials/actor-tab-experience.html",
"systems/frostgrave/templates/actor/partials/actor-tab-homebase.html",
"systems/frostgrave/templates/actor/partials/actor-tab-items.html",
"systems/frostgrave/templates/actor/partials/actor-tab-spells.html"
// Item Sheet Partials
];
// Load the template parts
return loadTemplates(templatePaths);
};