diff --git a/src/acks.js b/src/acks.js index 098df0c..a2d1469 100644 --- a/src/acks.js +++ b/src/acks.js @@ -54,7 +54,9 @@ Hooks.once("init", async function () { makeDefault: true, }); Items.unregisterSheet("core", ItemSheet); - Items.registerSheet("acks", AcksItemSheet, { makeDefault: true }); + Items.registerSheet("acks", AcksItemSheet, { + makeDefault: true, + }); await preloadHandlebarsTemplates(); }); @@ -87,8 +89,8 @@ Hooks.on("renderSidebarTab", async (object, html) => { }); Hooks.on("createCombatant", async (combatant, options, userId) => { - let init = game.settings.get("acks", "initiative"); - if (init == "group") { + const init = game.settings.get("acks", "initiative"); + if (init === "group") { await AcksCombat.addCombatant(combatant, options, userId); } }); diff --git a/src/module/dialog/character-modifiers.js b/src/module/dialog/character-modifiers.js index 6211943..1c7efa6 100644 --- a/src/module/dialog/character-modifiers.js +++ b/src/module/dialog/character-modifiers.js @@ -1,6 +1,4 @@ // eslint-disable-next-line no-unused-vars -import { AcksActor } from '../actor/entity.js'; - export class AcksCharacterModifiers extends FormApplication { static get defaultOptions() { const options = super.defaultOptions; @@ -29,8 +27,10 @@ export class AcksCharacterModifiers extends FormApplication { * @return {Object} */ getData() { - let data = this.object.data; + const data = this.object.data; + data.user = game.user; + return data; } diff --git a/src/module/dialog/entity-tweaks.js b/src/module/dialog/entity-tweaks.js index 61e4f25..70a1299 100644 --- a/src/module/dialog/entity-tweaks.js +++ b/src/module/dialog/entity-tweaks.js @@ -1,6 +1,4 @@ // eslint-disable-next-line no-unused-vars -import { AcksActor } from '../actor/entity.js'; - export class AcksEntityTweaks extends FormApplication { static get defaultOptions() { const options = super.defaultOptions; @@ -28,12 +26,15 @@ export class AcksEntityTweaks extends FormApplication { * @return {Object} */ getData() { - let data = this.object.data; + const data = this.object.data; + if (this.object.data.type === 'character') { data.isCharacter = true; } + data.user = game.user; data.config = CONFIG.ACKS; + return data; } @@ -52,9 +53,11 @@ export class AcksEntityTweaks extends FormApplication { */ async _updateObject(event, formData) { event.preventDefault(); - // Update the actor + + // Update the actor. this.object.update(formData); - // Re-draw the updated sheet + + // Render the updated sheet. this.object.sheet.render(true); } } diff --git a/src/module/dialog/party-sheet.js b/src/module/dialog/party-sheet.js index 341adbc..f140dd6 100644 --- a/src/module/dialog/party-sheet.js +++ b/src/module/dialog/party-sheet.js @@ -30,12 +30,14 @@ export class AcksPartySheet extends FormApplication { const settings = { ascending: game.settings.get('acks', 'ascendingAC') }; - let data = { + + const data = { data: this.object, config: CONFIG.ACKS, user: game.user, settings: settings }; + return data; } @@ -64,7 +66,7 @@ export class AcksPartySheet extends FormApplication { `; let pcs = this.object.documents.filter((actor) => { - return actor.getFlag('acks', 'party') && actor.data.type == "character"; + return actor.getFlag('acks', 'party') && actor.data.type === "character"; }); new Dialog({ diff --git a/src/module/helpers.js b/src/module/helpers.js index 49472f5..7dd4479 100644 --- a/src/module/helpers.js +++ b/src/module/helpers.js @@ -33,7 +33,7 @@ export const registerHelpers = async function () { Handlebars.registerHelper("mult", function (lh, rh) { return parseFloat(lh) * parseFloat(rh); }); - + Handlebars.registerHelper("multround", function (lh, rh) { return Math.round(parseFloat(lh) * parseFloat(rh) * 100) / 100; }) @@ -47,8 +47,8 @@ export const registerHelpers = async function () { }); Handlebars.registerHelper("getTagIcon", function (tag) { - let idx = Object.keys(CONFIG.ACKS.tags).find(k => (CONFIG.ACKS.tags[k] == tag)); - return CONFIG.ACKS.tag_images[idx]; + const index = Object.keys(CONFIG.ACKS.tags).find(k => (CONFIG.ACKS.tags[k] == tag)); + return CONFIG.ACKS.tag_images[index]; }); Handlebars.registerHelper("counter", function (status, value, max) { diff --git a/src/module/item/entity.js b/src/module/item/entity.js index f5361f7..63050cb 100644 --- a/src/module/item/entity.js +++ b/src/module/item/entity.js @@ -280,7 +280,7 @@ export class AcksItem extends Item { const token = this.actor.token; const templateData = { actor: this.actor, - tokenId: token ? `${token.scene._id}.${token.id}` : null, + tokenId: token ? `${token.parent.id}.${token.id}` : null, item: this.data, data: this.getChatData(), labels: this.labels, @@ -297,11 +297,11 @@ export class AcksItem extends Item { // Basic chat message data const chatData = { - user: game.user._id, + user: game.user.id, type: CONST.CHAT_MESSAGE_TYPES.OTHER, content: html, speaker: { - actor: this.actor._id, + actor: this.actor.id, token: this.actor.token, alias: this.actor.name, }, @@ -311,7 +311,7 @@ export class AcksItem extends Item { let rollMode = game.settings.get("core", "rollMode"); if (["gmroll", "blindroll"].includes(rollMode)) chatData["whisper"] = ChatMessage.getWhisperRecipients("GM"); - if (rollMode === "selfroll") chatData["whisper"] = [game.user._id]; + if (rollMode === "selfroll") chatData["whisper"] = [game.user.id]; if (rollMode === "blindroll") chatData["blind"] = true; // Create the chat message @@ -395,7 +395,7 @@ export class AcksItem extends Item { const [sceneId, tokenId] = tokenKey.split("."); const scene = game.scenes.get(sceneId); if (!scene) return null; - const tokenData = scene.getEmbeddedEntity("Token", tokenId); + const tokenData = scene.tokens.get(tokenId); if (!tokenData) return null; const token = new Token(tokenData); return token.actor; diff --git a/src/templates/chat/item-card.html b/src/templates/chat/item-card.html index 1191cdf..f4dc9ac 100644 --- a/src/templates/chat/item-card.html +++ b/src/templates/chat/item-card.html @@ -1,4 +1,4 @@ -