forked from public/foundryvtt-reve-de-dragon
Increase support
This commit is contained in:
@ -2,6 +2,9 @@
|
||||
* Extend the basic ActorSheet with some very simple modifications
|
||||
* @extends {ActorSheet}
|
||||
*/
|
||||
|
||||
import { RdDUtility } from "./rdd-utility.js";
|
||||
|
||||
export class RdDActorSheet extends ActorSheet {
|
||||
|
||||
/** @override */
|
||||
@ -16,6 +19,15 @@ export class RdDActorSheet extends ActorSheet {
|
||||
});
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
_checkNull(items) {
|
||||
if (items && items.length) {
|
||||
return items;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
getData() {
|
||||
@ -33,7 +45,7 @@ export class RdDActorSheet extends ActorSheet {
|
||||
data.competenceByCategory = {};
|
||||
if (data.itemsByType.competence) {
|
||||
for (const item of data.itemsByType.competence) {
|
||||
console.log("Push...", item, item.data.categorie);
|
||||
//console.log("Push...", item, item.data.categorie);
|
||||
let list = data.competenceByCategory[item.data.categorie];
|
||||
if (!list) {
|
||||
list = [];
|
||||
@ -76,6 +88,12 @@ export class RdDActorSheet extends ActorSheet {
|
||||
li.slideUp(200, () => this.render(false));
|
||||
});
|
||||
|
||||
// Roll Skill
|
||||
html.find('.competence-label a').click((event) => {
|
||||
let compName = event.currentTarget.text;
|
||||
this.actor.rollCompetence( compName);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
@ -2,7 +2,13 @@
|
||||
* Extend the base Actor entity by defining a custom roll data structure which is ideal for the Simple system.
|
||||
* @extends {Actor}
|
||||
*/
|
||||
|
||||
import { RdDUtility } from "./rdd-utility.js";
|
||||
|
||||
export class RdDActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
prepareData() {
|
||||
super.prepareData();
|
||||
|
||||
@ -21,6 +27,33 @@ export class RdDActor extends Actor {
|
||||
_prepareCharacterData(actorData) {
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
rollCompetence( compName ) {
|
||||
|
||||
let compItem = RdDUtility.findCompetence( this.data.items, compName);
|
||||
console.log("Roll !", compItem );
|
||||
renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-competence.html', compItem).then(dlg =>
|
||||
{
|
||||
new Dialog(
|
||||
{
|
||||
title: "Test de compétence",
|
||||
content: dlg,
|
||||
buttons:
|
||||
{
|
||||
rollButton:
|
||||
{
|
||||
label: "Lancer"
|
||||
//callback: html => dialogOptions.callback(html, roll)
|
||||
}
|
||||
},
|
||||
default: "rollButton"
|
||||
}).render(true);
|
||||
});
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/** @override */
|
||||
getRollData() {
|
||||
|
17
module/rdd-utility.js
Normal file
17
module/rdd-utility.js
Normal file
@ -0,0 +1,17 @@
|
||||
/* Common useful functions shared between objects */
|
||||
|
||||
export class RdDUtility {
|
||||
|
||||
static findCompetence(compList, compName)
|
||||
{
|
||||
for (const item of compList) {
|
||||
if (item.name == compName) {
|
||||
console.log("Found item !", item);
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ RDD.level_category = {
|
||||
import { RdDActor } from "./actor.js";
|
||||
import { RdDItemSheet } from "./item-sheet.js";
|
||||
import { RdDActorSheet } from "./actor-sheet.js";
|
||||
|
||||
import { RdDUtility } from "./rdd-utility.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
// Handlers management
|
||||
@ -34,7 +34,9 @@ const preloadHandlebarsTemplates = async function () {
|
||||
'systems/foundryvtt-reve-de-dragon/templates/item-competence-sheet.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/competence-categorie.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/competence-carac-defaut.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/competence-base.html'
|
||||
'systems/foundryvtt-reve-de-dragon/templates/competence-base.html',
|
||||
// Dialogs
|
||||
'systems/foundryvtt-reve-de-dragon/templates/dialog-competence.html'
|
||||
];
|
||||
|
||||
return loadTemplates(templatePaths);
|
||||
@ -68,13 +70,4 @@ Hooks.once("init", async function() {
|
||||
Items.unregisterSheet("core", ItemSheet);
|
||||
Items.registerSheet("foundryvtt-reve-de-dragon", RdDItemSheet, {makeDefault: true});
|
||||
|
||||
// Register system settings
|
||||
game.settings.register("foundryvtt-reve-de-dragon", "macroShorthand", {
|
||||
name: "Shortened Macro Syntax",
|
||||
hint: "Enable a shortened macro syntax which allows referencing attributes directly, for example @str instead of @attributes.str.value. Disable this setting if you need the ability to reference the full attribute model, for example @attributes.str.label.",
|
||||
scope: "world",
|
||||
type: Boolean,
|
||||
default: true,
|
||||
config: true
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user