Add Templates Html + Gulp Sass + Css + Basic Tree and Files
- Add Templates Html - Gulp Sass - Css - Basic Tree and Files
This commit is contained in:
34
system/scripts/actor-l5r5e.js
Normal file
34
system/scripts/actor-l5r5e.js
Normal file
@@ -0,0 +1,34 @@
|
||||
|
||||
|
||||
/**
|
||||
* Extends the actor to process special things from L5R.
|
||||
*/
|
||||
export class ActorL5r5e extends Actor {
|
||||
|
||||
/** @override */
|
||||
static async create(data, options={}) {
|
||||
if(!Object.keys(data).includes("type")) data.type = "character";
|
||||
await super.create(data, options);
|
||||
}
|
||||
|
||||
prepareData() {
|
||||
super.prepareData();
|
||||
|
||||
const actorData = this.data;
|
||||
const data = actorData.data;
|
||||
const isCharacter = actorData.type === "character";
|
||||
|
||||
if (isCharacter) {
|
||||
data.endurance = (Number(data.rings.earth) + Number(data.rings.fire)) * 2;
|
||||
data.composure = (Number(data.rings.earth) + Number(data.rings.water)) * 2;
|
||||
data.focus = Number(data.rings.air) + Number(data.rings.fire);
|
||||
data.vigilante = Math.floor((Number(data.rings.air) + Number(data.rings.water)) / 2);
|
||||
data.void_points.max = data.rings.void;
|
||||
|
||||
// Make sure void points are never greater than max
|
||||
if (data.void_points.current > data.void_points.max) {
|
||||
data.void_points.current = data.void_points.max;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
142
system/scripts/actors/actor-sheet.js
Normal file
142
system/scripts/actors/actor-sheet.js
Normal file
@@ -0,0 +1,142 @@
|
||||
|
||||
export class ActorSheetL5r5e extends ActorSheet {
|
||||
|
||||
static get defaultOptions() {
|
||||
return mergeObject(super.defaultOptions, {
|
||||
classes: ["l5r5e", "sheet", "actor"],
|
||||
template: "systems/l5r5e/templates/sheets/actor-sheet.html",
|
||||
width: 600,
|
||||
height: 600,
|
||||
tabs: [{navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "description"}],
|
||||
dragDrop: [{dragSelector: ".item-list .item", dropSelector: null}]
|
||||
});
|
||||
}
|
||||
|
||||
getData() {
|
||||
const sheetData = super.getData();
|
||||
|
||||
this._prepareItems(sheetData);
|
||||
|
||||
const feats = sheetData.items.filter((item) => item.type === "feat");
|
||||
|
||||
sheetData.data.feats = feats;
|
||||
|
||||
return sheetData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the actor.
|
||||
* @param event
|
||||
* @param formData
|
||||
*/
|
||||
_updateObject(event, formData) {
|
||||
return this.object.update(formData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare item data to be displayed in the actor sheet.
|
||||
* @param sheetData Data of the actor been displayed in the sheet.
|
||||
*/
|
||||
_prepareItems(sheetData) {
|
||||
for (let item of sheetData.items) {
|
||||
if (item.type === "weapon") {
|
||||
item.isWeapon = true;
|
||||
item.isEquipment = true;
|
||||
} else if (item.type === "feat"){
|
||||
item.isFeat = true;
|
||||
}
|
||||
else {
|
||||
item.isEquipment = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_prepareFeats() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribe to events from the sheet.
|
||||
* @param html HTML content of the sheet.
|
||||
*/
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
|
||||
// Everything below here is only needed if the sheet is editable
|
||||
if (!this.options.editable) return;
|
||||
|
||||
// Update Inventory Item
|
||||
html.find('.item-edit').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
const itemId = li.data("itemId");
|
||||
const item = this.actor.getOwnedItem(itemId);
|
||||
item.sheet.render(true);
|
||||
});
|
||||
|
||||
// Delete Inventory Item
|
||||
html.find('.item-delete').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
const itemId = li.data("itemId");
|
||||
this.actor.deleteOwnedItem(itemId);
|
||||
});
|
||||
|
||||
html.find('.feat-add').click(ev => {
|
||||
this._createFeat();
|
||||
});
|
||||
|
||||
html.find('.feat-delete').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".feat");
|
||||
const featId = li.data("featId");
|
||||
console.log("Remove feat" + featId + " clicked");
|
||||
|
||||
this.actor.deleteOwnedItem(featId);
|
||||
});
|
||||
|
||||
html.find('.feat-edit').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".feat");
|
||||
const featId = li.data("featId");
|
||||
const feat = this.actor.getOwnedItem(featId);
|
||||
feat.sheet.render(true);
|
||||
});
|
||||
|
||||
html.find('.skill-name').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".skill");
|
||||
const skillId = li.data("skill");
|
||||
|
||||
this._onSkillClicked(skillId);
|
||||
});
|
||||
|
||||
html.find('.adquisition-add').click(ev => {
|
||||
this._createFeat();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new feat for the character and shows a window to edit it.
|
||||
*/
|
||||
async _createFeat() {
|
||||
const data = {
|
||||
name: game.i18n.localize('L5r5e.FeatPlaceholderName'),
|
||||
type: "feat"
|
||||
};
|
||||
const created = await this.actor.createEmbeddedEntity("OwnedItem", data);
|
||||
const feat = this.actor.getOwnedItem(created._id);
|
||||
|
||||
// Default values
|
||||
//feat.rank = 1;
|
||||
//feat.xp_used = 0;
|
||||
|
||||
feat.sheet.render(true);
|
||||
|
||||
return feat;
|
||||
}
|
||||
|
||||
/**
|
||||
* React to a skill from the skills list been clicked.
|
||||
* @param {string} skillId Unique ID of the skill been clicked.
|
||||
*/
|
||||
async _onSkillClicked(skillId) {
|
||||
console.log("Clicked on skill " + skillId);
|
||||
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
17
system/scripts/dice-l5r5e.js
Normal file
17
system/scripts/dice-l5r5e.js
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Establish each L5r5e dice type here as extensions of DiceTerm.
|
||||
* @extends {DiceTerm}
|
||||
*/
|
||||
|
||||
export { AbilityDie } from "./dice/dietype/AbilityDie.js";
|
||||
export { RingsDie } from "./dice/dietype/RingsDie.js";
|
||||
|
||||
/**
|
||||
* New extension of the core DicePool class for evaluating rolls with the L5r5e DiceTerms
|
||||
*/
|
||||
export { RollL5r5e } from "./dice/roll.js";
|
||||
|
||||
/**
|
||||
* Dice pool utility specializing in the L5r5e special dice
|
||||
*/
|
||||
export { DicePoolL5r5e } from "./dice/pool.js";
|
||||
63
system/scripts/dice/dietype/AbilityDie.js
Normal file
63
system/scripts/dice/dietype/AbilityDie.js
Normal file
@@ -0,0 +1,63 @@
|
||||
export class AbilityDie extends DiceTerm {
|
||||
constructor(termData) {
|
||||
super(termData);
|
||||
this.faces = 8;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
/** @override */
|
||||
static DENOMINATION = "a";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/** @override */
|
||||
get formula() {
|
||||
return `${this.number}${this.constructor.DENOMINATION}${this.modifiers.join("")}`;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/** @override */
|
||||
evaluate({ minimize = false, maximize = false } = {}) {
|
||||
if (this._evaluated) {
|
||||
throw new Error(`This ${this.constructor.name} has already been evaluated and is immutable`);
|
||||
}
|
||||
|
||||
// Roll the initial number of dice
|
||||
for (let n = 1; n <= this.number; n++) {
|
||||
this.roll({ minimize, maximize });
|
||||
}
|
||||
|
||||
// Apply modifiers
|
||||
this._evaluateModifiers();
|
||||
|
||||
// Combine all FFG results.
|
||||
this.ffg = { success: 0, failure: 0, advantage: 0, threat: 0, triumph: 0, despair: 0, light: 0, dark: 0 };
|
||||
this.results.forEach((result) => {
|
||||
this.ffg.success += parseInt(result.ffg.success);
|
||||
this.ffg.failure += parseInt(result.ffg.failure);
|
||||
this.ffg.advantage += parseInt(result.ffg.advantage);
|
||||
this.ffg.threat += parseInt(result.ffg.threat);
|
||||
this.ffg.triumph += parseInt(result.ffg.triumph);
|
||||
this.ffg.despair += parseInt(result.ffg.despair);
|
||||
this.ffg.light += parseInt(result.ffg.light);
|
||||
this.ffg.dark += parseInt(result.ffg.dark);
|
||||
});
|
||||
|
||||
// Return the evaluated term
|
||||
this._evaluated = true;
|
||||
this._isFFG = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/** @override */
|
||||
roll(options) {
|
||||
const roll = super.roll(options);
|
||||
roll.ffg = CONFIG.FFG.ABILITY_RESULTS[roll.result];
|
||||
return roll;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/** @override */
|
||||
static getResultLabel(result) {
|
||||
return CONFIG.FFG.ABILITY_RESULTS[result].label;
|
||||
}
|
||||
}
|
||||
63
system/scripts/dice/dietype/RingsDie.js
Normal file
63
system/scripts/dice/dietype/RingsDie.js
Normal file
@@ -0,0 +1,63 @@
|
||||
export class RingsDie extends DiceTerm {
|
||||
constructor(termData) {
|
||||
super(termData);
|
||||
this.faces = 12;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
/** @override */
|
||||
static DENOMINATION = "p";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/** @override */
|
||||
get formula() {
|
||||
return `${this.number}${this.constructor.DENOMINATION}${this.modifiers.join("")}`;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/** @override */
|
||||
evaluate({ minimize = false, maximize = false } = {}) {
|
||||
if (this._evaluated) {
|
||||
throw new Error(`This ${this.constructor.name} has already been evaluated and is immutable`);
|
||||
}
|
||||
|
||||
// Roll the initial number of dice
|
||||
for (let n = 1; n <= this.number; n++) {
|
||||
this.roll({ minimize, maximize });
|
||||
}
|
||||
|
||||
// Apply modifiers
|
||||
this._evaluateModifiers();
|
||||
|
||||
// Combine all FFG results.
|
||||
this.ffg = { success: 0, failure: 0, advantage: 0, threat: 0, triumph: 0, despair: 0, light: 0, dark: 0 };
|
||||
this.results.forEach((result) => {
|
||||
this.ffg.success += parseInt(result.ffg.success);
|
||||
this.ffg.failure += parseInt(result.ffg.failure);
|
||||
this.ffg.advantage += parseInt(result.ffg.advantage);
|
||||
this.ffg.threat += parseInt(result.ffg.threat);
|
||||
this.ffg.triumph += parseInt(result.ffg.triumph);
|
||||
this.ffg.despair += parseInt(result.ffg.despair);
|
||||
this.ffg.light += parseInt(result.ffg.light);
|
||||
this.ffg.dark += parseInt(result.ffg.dark);
|
||||
});
|
||||
|
||||
// Return the evaluated term
|
||||
this._evaluated = true;
|
||||
this._isFFG = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/** @override */
|
||||
roll(options) {
|
||||
const roll = super.roll(options);
|
||||
roll.ffg = CONFIG.FFG.PROFICIENCY_RESULTS[roll.result];
|
||||
return roll;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/** @override */
|
||||
static getResultLabel(result) {
|
||||
return CONFIG.FFG.PROFICIENCY_RESULTS[result].label;
|
||||
}
|
||||
}
|
||||
8
system/scripts/dice/pool.js
Normal file
8
system/scripts/dice/pool.js
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
|
||||
/**
|
||||
* Dice pool utility specializing in the FFG special dice
|
||||
*/
|
||||
export class DicePoolL5r5e {
|
||||
|
||||
}
|
||||
8
system/scripts/dice/roll.js
Normal file
8
system/scripts/dice/roll.js
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
|
||||
/**
|
||||
* New extension of the core DicePool class for evaluating rolls with the FFG DiceTerms
|
||||
*/
|
||||
export class RollL5r5e extends Roll {
|
||||
|
||||
}
|
||||
51
system/scripts/items/feat-sheet.js
Normal file
51
system/scripts/items/feat-sheet.js
Normal file
@@ -0,0 +1,51 @@
|
||||
import { L5RItemSheet } from "./item-sheet.js";
|
||||
|
||||
/**
|
||||
* @extends {ItemSheet}
|
||||
*/
|
||||
export class L5RFeatSheet extends L5RItemSheet {
|
||||
|
||||
/** @override */
|
||||
static get defaultOptions() {
|
||||
return mergeObject(super.defaultOptions, {
|
||||
classes: ["l5r", "sheet", "feat"],
|
||||
template: "systems/l5r/templates/item/feat-sheet.html",
|
||||
width: 520,
|
||||
height: 480,
|
||||
tabs: [{navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "description"}]
|
||||
});
|
||||
}
|
||||
|
||||
/** @override */
|
||||
getData() {
|
||||
const sheetData = super.getData();
|
||||
sheetData.data.dtypes = ["String", "Number", "Boolean"];
|
||||
|
||||
sheetData.data.isFeat = true;
|
||||
sheetData.data.isEquipment = false;
|
||||
|
||||
return sheetData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribe to events from the sheet.
|
||||
* @param html HTML content of the sheet.
|
||||
*/
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
|
||||
// Everything below here is only needed if the sheet is editable
|
||||
if (!this.options.editable) return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update feat with the data from the sheet.
|
||||
* @param event
|
||||
* @param formData
|
||||
*/
|
||||
_updateObject(event, formData) {
|
||||
|
||||
// Update the Item
|
||||
return this.object.update(formData);
|
||||
}
|
||||
}
|
||||
47
system/scripts/items/item-sheet.js
Normal file
47
system/scripts/items/item-sheet.js
Normal file
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* Extend the basic ItemSheet with some very simple modifications
|
||||
* @extends {ItemSheet}
|
||||
*/
|
||||
export class L5RItemSheet extends ItemSheet {
|
||||
|
||||
/** @override */
|
||||
static get defaultOptions() {
|
||||
return mergeObject(super.defaultOptions, {
|
||||
classes: ["l5r", "sheet", "item"],
|
||||
template: "systems/l5r/templates/item/item-sheet.html",
|
||||
width: 520,
|
||||
height: 480,
|
||||
tabs: [{navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "description"}]
|
||||
});
|
||||
}
|
||||
|
||||
getData() {
|
||||
const sheetData = super.getData();
|
||||
|
||||
sheetData.data.dtypes = ["String", "Number", "Boolean"];
|
||||
|
||||
sheetData.data.isEquipment = true;
|
||||
|
||||
return sheetData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribe to events from the sheet.
|
||||
* @param html HTML content of the sheet.
|
||||
*/
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
|
||||
// Everything below here is only needed if the sheet is editable
|
||||
if (!this.options.editable) return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the item with data from the sheet.
|
||||
* @param event
|
||||
* @param formData
|
||||
*/
|
||||
_updateObject(event, formData) {
|
||||
return this.object.update(formData);
|
||||
}
|
||||
}
|
||||
4
system/scripts/items/item.js
Normal file
4
system/scripts/items/item.js
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
export class L5RItem extends Item {
|
||||
|
||||
}
|
||||
48
system/scripts/items/weapon-sheet.js
Normal file
48
system/scripts/items/weapon-sheet.js
Normal file
@@ -0,0 +1,48 @@
|
||||
import { L5RItemSheet } from "./item-sheet.js";
|
||||
|
||||
/**
|
||||
* @extends {ItemSheet}
|
||||
*/
|
||||
export class L5RWeaponSheet extends L5RItemSheet {
|
||||
|
||||
/** @override */
|
||||
static get defaultOptions() {
|
||||
return mergeObject(super.defaultOptions, {
|
||||
classes: ["l5r", "sheet", "weapon"],
|
||||
template: "systems/l5r/templates/item/weapon-sheet.html",
|
||||
width: 520,
|
||||
height: 480,
|
||||
tabs: [{navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "description"}]
|
||||
});
|
||||
}
|
||||
|
||||
getData() {
|
||||
const sheetData = super.getData();
|
||||
sheetData.data.dtypes = ["String", "Number", "Boolean"];
|
||||
|
||||
sheetData.data.isWeapon = true;
|
||||
sheetData.data.isEquipment = true;
|
||||
|
||||
return sheetData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribe to events from the sheet.
|
||||
* @param html HTML content of the sheet.
|
||||
*/
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
|
||||
// Everything below here is only needed if the sheet is editable
|
||||
if (!this.options.editable) return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update item with values from the sheet.
|
||||
* @param event
|
||||
* @param formData
|
||||
*/
|
||||
_updateObject(event, formData) {
|
||||
return this.object.update(formData);
|
||||
}
|
||||
}
|
||||
75
system/scripts/main-l5r5e.js
Normal file
75
system/scripts/main-l5r5e.js
Normal file
@@ -0,0 +1,75 @@
|
||||
// Import Modules
|
||||
import { RegisterSettings } from './settings.js';
|
||||
import { PreloadTemplates } from './preloadTemplates.js';
|
||||
import { ActorL5r5e } from "./actor-l5r5e.js";
|
||||
import { ActorSheetL5r5e } from './sheets/actor-sheet.js';
|
||||
|
||||
// Import Dice Types
|
||||
|
||||
/* ------------------------------------ */
|
||||
/* Initialize system */
|
||||
/* ------------------------------------ */
|
||||
Hooks.once('init', async function() {
|
||||
console.log('l5r5e | Initializing l5r5e');
|
||||
|
||||
// Assign custom classes and constants here
|
||||
CONFIG.Actor.entityClass = ActorL5r5e;
|
||||
CONFIG.Actor.sheetClasses = ActorSheetL5r5e;
|
||||
|
||||
// Register custom system settings
|
||||
RegisterSettings();
|
||||
|
||||
// Preload Handlebars templates
|
||||
await PreloadTemplates();
|
||||
|
||||
// Register custom sheets (if any)
|
||||
// Actors sheet
|
||||
Actors.unregisterSheet("core", ActorSheet);
|
||||
Actors.registerSheet("l5r5e", ActorSheetL5r5e, { types: ["character"], makeDefault: true });
|
||||
|
||||
Handlebars.registerHelper('localizeSkillCategory', function(skillName) {
|
||||
const key = 'L5r5e.Skills.' + skillName + '.Title';
|
||||
return game.i18n.localize(key);
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('localizeSkill', function(skillCategory, skillName) {
|
||||
const key = 'L5r5e.Skills.' + skillCategory + '.' + skillName;
|
||||
return game.i18n.localize(key);
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('localizeRing', function(ringName) {
|
||||
const key = 'L5r5e.Rings.' + ringName.charAt(0).toUpperCase() + ringName.slice(1);
|
||||
return game.i18n.localize(key);
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('localizeRingTip', function(ringName) {
|
||||
const key = 'L5r5e.Rings.' + ringName.charAt(0).toUpperCase() + ringName.slice(1) + "Tip";
|
||||
return game.i18n.localize(key);
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('localizeStanceTip', function(ringName) {
|
||||
const key = 'L5r5e.Conflict.Stances.' + ringName.charAt(0).toUpperCase() + ringName.slice(1) + "Tip";
|
||||
return game.i18n.localize(key);
|
||||
});
|
||||
});
|
||||
|
||||
/* ------------------------------------ */
|
||||
/* Setup system */
|
||||
/* ------------------------------------ */
|
||||
Hooks.once('setup', function() {
|
||||
// Do anything after initialization but before
|
||||
// ready
|
||||
});
|
||||
|
||||
/* ------------------------------------ */
|
||||
/* Actor Dialog */
|
||||
/* ------------------------------------ */
|
||||
|
||||
/* ------------------------------------ */
|
||||
/* When ready */
|
||||
/* ------------------------------------ */
|
||||
Hooks.once('ready', function() {
|
||||
// Do anything once the system is ready
|
||||
});
|
||||
|
||||
// Add any additional hooks if necessary
|
||||
25
system/scripts/preloadTemplates.js
Normal file
25
system/scripts/preloadTemplates.js
Normal file
@@ -0,0 +1,25 @@
|
||||
export const PreloadTemplates = async function() {
|
||||
const templatePaths = [
|
||||
// Add paths to "systems/l5r5e/templates"
|
||||
'systems/l5r5e/templates/sheets/actor/rings.html',
|
||||
'systems/l5r5e/templates/sheets/actor/identity.html',
|
||||
'systems/l5r5e/templates/sheets/actor/category.html',
|
||||
'systems/l5r5e/templates/sheets/actor/skill.html',
|
||||
'systems/l5r5e/templates/sheets/actor/social.html',
|
||||
'systems/l5r5e/templates/sheets/actor/conflict.html',
|
||||
'systems/l5r5e/templates/sheets/actor/stance.html',
|
||||
'systems/l5r5e/templates/sheets/actor/feats.html',
|
||||
'systems/l5r5e/templates/sheets/actor/experience.html',
|
||||
'systems/l5r5e/templates/sheets/actor/adquisition.html',
|
||||
// items
|
||||
'systems/l5r5e/templates/item/weapon-sheet.html',
|
||||
'systems/l5r5e/templates/item/items.html',
|
||||
'systems/l5r5e/templates/item/item-entry.html',
|
||||
'systems/l5r5e/templates/item/weapons.html',
|
||||
'systems/l5r5e/templates/item/weapon-entry.html',
|
||||
'systems/l5r5e/templates/item/feat-sheet.html',
|
||||
'systems/l5r5e/templates/item/feat-entry.html'
|
||||
];
|
||||
|
||||
return loadTemplates(templatePaths);
|
||||
}
|
||||
4
system/scripts/settings.js
Normal file
4
system/scripts/settings.js
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
export const RegisterSettings = function() {
|
||||
// Register any custom system settings here
|
||||
}
|
||||
142
system/scripts/sheets/actor-sheet.js
Normal file
142
system/scripts/sheets/actor-sheet.js
Normal file
@@ -0,0 +1,142 @@
|
||||
|
||||
export class ActorSheetL5r5e extends ActorSheet {
|
||||
|
||||
static get defaultOptions() {
|
||||
return mergeObject(super.defaultOptions, {
|
||||
classes: ["l5r5e", "sheet", "actor"],
|
||||
template: "systems/l5r5e/templates/sheets/actor-sheet.html",
|
||||
width: 600,
|
||||
height: 600,
|
||||
tabs: [{navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "description"}],
|
||||
dragDrop: [{dragSelector: ".item-list .item", dropSelector: null}]
|
||||
});
|
||||
}
|
||||
|
||||
getData() {
|
||||
const sheetData = super.getData();
|
||||
|
||||
this._prepareItems(sheetData);
|
||||
|
||||
const feats = sheetData.items.filter((item) => item.type === "feat");
|
||||
|
||||
sheetData.data.feats = feats;
|
||||
|
||||
return sheetData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the actor.
|
||||
* @param event
|
||||
* @param formData
|
||||
*/
|
||||
_updateObject(event, formData) {
|
||||
return this.object.update(formData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare item data to be displayed in the actor sheet.
|
||||
* @param sheetData Data of the actor been displayed in the sheet.
|
||||
*/
|
||||
_prepareItems(sheetData) {
|
||||
for (let item of sheetData.items) {
|
||||
if (item.type === "weapon") {
|
||||
item.isWeapon = true;
|
||||
item.isEquipment = true;
|
||||
} else if (item.type === "feat"){
|
||||
item.isFeat = true;
|
||||
}
|
||||
else {
|
||||
item.isEquipment = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_prepareFeats() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribe to events from the sheet.
|
||||
* @param html HTML content of the sheet.
|
||||
*/
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
|
||||
// Everything below here is only needed if the sheet is editable
|
||||
if (!this.options.editable) return;
|
||||
|
||||
// Update Inventory Item
|
||||
html.find('.item-edit').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
const itemId = li.data("itemId");
|
||||
const item = this.actor.getOwnedItem(itemId);
|
||||
item.sheet.render(true);
|
||||
});
|
||||
|
||||
// Delete Inventory Item
|
||||
html.find('.item-delete').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
const itemId = li.data("itemId");
|
||||
this.actor.deleteOwnedItem(itemId);
|
||||
});
|
||||
|
||||
html.find('.feat-add').click(ev => {
|
||||
this._createFeat();
|
||||
});
|
||||
|
||||
html.find('.feat-delete').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".feat");
|
||||
const featId = li.data("featId");
|
||||
console.log("Remove feat" + featId + " clicked");
|
||||
|
||||
this.actor.deleteOwnedItem(featId);
|
||||
});
|
||||
|
||||
html.find('.feat-edit').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".feat");
|
||||
const featId = li.data("featId");
|
||||
const feat = this.actor.getOwnedItem(featId);
|
||||
feat.sheet.render(true);
|
||||
});
|
||||
|
||||
html.find('.skill-name').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".skill");
|
||||
const skillId = li.data("skill");
|
||||
|
||||
this._onSkillClicked(skillId);
|
||||
});
|
||||
|
||||
html.find('.adquisition-add').click(ev => {
|
||||
this._createFeat();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new feat for the character and shows a window to edit it.
|
||||
*/
|
||||
async _createFeat() {
|
||||
const data = {
|
||||
name: game.i18n.localize('L5r5e.FeatPlaceholderName'),
|
||||
type: "feat"
|
||||
};
|
||||
const created = await this.actor.createEmbeddedEntity("OwnedItem", data);
|
||||
const feat = this.actor.getOwnedItem(created._id);
|
||||
|
||||
// Default values
|
||||
//feat.rank = 1;
|
||||
//feat.xp_used = 0;
|
||||
|
||||
feat.sheet.render(true);
|
||||
|
||||
return feat;
|
||||
}
|
||||
|
||||
/**
|
||||
* React to a skill from the skills list been clicked.
|
||||
* @param {string} skillId Unique ID of the skill been clicked.
|
||||
*/
|
||||
async _onSkillClicked(skillId) {
|
||||
console.log("Clicked on skill " + skillId);
|
||||
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user