Fix item rolls

master
John Downey 2022-04-09 17:57:07 -05:00
parent 337f578a51
commit e1d9c59889
7 changed files with 29 additions and 22 deletions

View File

@ -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);
}
});

View File

@ -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;
}

View File

@ -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);
}
}

View File

@ -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({

View File

@ -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) {

View File

@ -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;

View File

@ -1,4 +1,4 @@
<div class="acks chat-card item-card" data-actor-id="{{actor._id}}" data-item-id="{{item._id}}"
<div class="acks chat-card item-card" data-actor-id="{{actor.id}}" data-item-id="{{item._id}}"
{{#if tokenId}}data-token-id="{{tokenId}}" {{/if}}>
<header class="card-header flexrow">
<img src="{{item.img}}" title="{{item.name}}" width="36" height="36" />