cleanup
This commit is contained in:
parent
26233d61ea
commit
05933af152
10 changed files with 22 additions and 15 deletions
|
@ -8,11 +8,11 @@ import evaluateCheck from "../../src/module/rolls/check-evaluation";
|
||||||
class StubGame {
|
class StubGame {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.i18n = {
|
this.i18n = {
|
||||||
localize: (a: string) => a,
|
localize: (key: string) => key,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
i18n: {
|
i18n: {
|
||||||
localize: (a: string) => string;
|
localize: (key: string) => string;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
"DS4.UserInteractionAddEffect": "Neuer Effekt",
|
"DS4.UserInteractionAddEffect": "Neuer Effekt",
|
||||||
"DS4.UserInteractionEditEffect": "Effekt bearbeiten",
|
"DS4.UserInteractionEditEffect": "Effekt bearbeiten",
|
||||||
"DS4.UserInteractionDeleteEffect": "Effekt löschen",
|
"DS4.UserInteractionDeleteEffect": "Effekt löschen",
|
||||||
"DS4.EntityImageAltText": "Bild von {name}",
|
"DS4.DocumentImageAltText": "Bild von {name}",
|
||||||
"DS4.RollableImageRollableTitle": "Für {name} würfeln",
|
"DS4.RollableImageRollableTitle": "Für {name} würfeln",
|
||||||
"DS4.DiceOverlayImageAltText": "Bild eines W20",
|
"DS4.DiceOverlayImageAltText": "Bild eines W20",
|
||||||
"DS4.NotOwned": "Nicht besessen",
|
"DS4.NotOwned": "Nicht besessen",
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
"DS4.UserInteractionAddEffect": "Add Effect",
|
"DS4.UserInteractionAddEffect": "Add Effect",
|
||||||
"DS4.UserInteractionEditEffect": "Edit Effect",
|
"DS4.UserInteractionEditEffect": "Edit Effect",
|
||||||
"DS4.UserInteractionDeleteEffect": "Delete Effect",
|
"DS4.UserInteractionDeleteEffect": "Delete Effect",
|
||||||
"DS4.EntityImageAltText": "Image of {name}",
|
"DS4.DocumentImageAltText": "Image of {name}",
|
||||||
"DS4.RollableImageRollableTitle": "Roll for {name}",
|
"DS4.RollableImageRollableTitle": "Roll for {name}",
|
||||||
"DS4.DiceOverlayImageAltText": "Image of a d20",
|
"DS4.DiceOverlayImageAltText": "Image of a d20",
|
||||||
"DS4.NotOwned": "No owner",
|
"DS4.NotOwned": "No owner",
|
||||||
|
|
|
@ -102,7 +102,7 @@ export class DS4ActorSheet extends ActorSheet<ActorSheet.Options, DS4ActorSheetD
|
||||||
html.find(".item-edit").on("click", (ev) => {
|
html.find(".item-edit").on("click", (ev) => {
|
||||||
const li = $(ev.currentTarget).parents(".item");
|
const li = $(ev.currentTarget).parents(".item");
|
||||||
const id = li.data("itemId");
|
const id = li.data("itemId");
|
||||||
const item = this.actor.getEmbeddedDocument("Item", id) as DS4Item; // TODO: Improve in upstream
|
const item = this.actor.items.get(id);
|
||||||
if (!item) {
|
if (!item) {
|
||||||
throw new Error(getGame().i18n.format("DS4.ErrorActorDoesNotHaveItem", { id, actor: this.actor.name }));
|
throw new Error(getGame().i18n.format("DS4.ErrorActorDoesNotHaveItem", { id, actor: this.actor.name }));
|
||||||
}
|
}
|
||||||
|
@ -157,7 +157,10 @@ export class DS4ActorSheet extends ActorSheet<ActorSheet.Options, DS4ActorSheetD
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
const el: HTMLFormElement = $(ev.currentTarget).get(0);
|
const el: HTMLFormElement = $(ev.currentTarget).get(0);
|
||||||
const id = $(ev.currentTarget).parents(".item").data("itemId");
|
const id = $(ev.currentTarget).parents(".item").data("itemId");
|
||||||
const item = this.actor.getEmbeddedDocument("Item", id) as DS4Item; // TODO: Improve in upstream
|
const item = this.actor.items.get(id);
|
||||||
|
if (!item) {
|
||||||
|
throw new Error(getGame().i18n.format("DS4.ErrorActorDoesNotHaveItem", { id, actor: this.actor.name }));
|
||||||
|
}
|
||||||
const itemObject = item.toObject();
|
const itemObject = item.toObject();
|
||||||
const property: string | undefined = $(ev.currentTarget).data("property");
|
const property: string | undefined = $(ev.currentTarget).data("property");
|
||||||
|
|
||||||
|
@ -172,7 +175,7 @@ export class DS4ActorSheet extends ActorSheet<ActorSheet.Options, DS4ActorSheetD
|
||||||
// Set new value
|
// Set new value
|
||||||
const newValue = this.getValue(el);
|
const newValue = this.getValue(el);
|
||||||
foundry.utils.setProperty(itemObject, property, newValue);
|
foundry.utils.setProperty(itemObject, property, newValue);
|
||||||
this.actor.updateEmbeddedDocuments("Item", [{ ...itemObject }]); // TODO: Improve in upstream
|
item.update({ ...itemObject });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -237,7 +240,10 @@ export class DS4ActorSheet extends ActorSheet<ActorSheet.Options, DS4ActorSheetD
|
||||||
protected onRollItem(event: JQuery.ClickEvent): void {
|
protected onRollItem(event: JQuery.ClickEvent): void {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const id = $(event.currentTarget).parents(".item").data("itemId");
|
const id = $(event.currentTarget).parents(".item").data("itemId");
|
||||||
const item = this.actor.getEmbeddedDocument("Item", id, { strict: true }) as DS4Item; // TODO: improve in upstream types
|
const item = this.actor.items.get(id);
|
||||||
|
if (!item) {
|
||||||
|
throw new Error(getGame().i18n.format("DS4.ErrorActorDoesNotHaveItem", { id, actor: this.actor.name }));
|
||||||
|
}
|
||||||
item.roll().catch((e) => notifications.error(e, { log: true }));
|
item.roll().catch((e) => notifications.error(e, { log: true }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,7 @@ export class DS4ItemSheet extends ItemSheet<ItemSheet.Options, DS4ItemSheetData>
|
||||||
|
|
||||||
switch (a.dataset["action"]) {
|
switch (a.dataset["action"]) {
|
||||||
case "create":
|
case "create":
|
||||||
return this._createActiveEffect();
|
return this.createActiveEffect();
|
||||||
case "edit":
|
case "edit":
|
||||||
const id = li.data("effectId");
|
const id = li.data("effectId");
|
||||||
const effect = this.item.effects.get(id);
|
const effect = this.item.effects.get(id);
|
||||||
|
@ -97,7 +97,7 @@ export class DS4ItemSheet extends ItemSheet<ItemSheet.Options, DS4ItemSheetData>
|
||||||
/**
|
/**
|
||||||
* Create a new ActiveEffect for the item using default data.
|
* Create a new ActiveEffect for the item using default data.
|
||||||
*/
|
*/
|
||||||
protected async _createActiveEffect(): Promise<ActiveEffect | undefined> {
|
protected async createActiveEffect(): Promise<ActiveEffect | undefined> {
|
||||||
const createData = {
|
const createData = {
|
||||||
label: "New Effect",
|
label: "New Effect",
|
||||||
icon: "icons/svg/aura.svg",
|
icon: "icons/svg/aura.svg",
|
||||||
|
|
|
@ -20,7 +20,7 @@ export async function createRollCheckMacro(check: Check, slot: string): Promise<
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getOrCreateRollCheckMacro(check: Check): Promise<Macro | undefined> {
|
async function getOrCreateRollCheckMacro(check: Check): Promise<Macro | undefined> {
|
||||||
const command = `getGame().ds4.macros.rollCheck("${check}");`;
|
const command = `game.ds4.macros.rollCheck("${check}");`;
|
||||||
|
|
||||||
const existingMacro = getGame().macros?.find(
|
const existingMacro = getGame().macros?.find(
|
||||||
(m) => m.name === DS4.i18n.checks[check] && m.data.command === command,
|
(m) => m.name === DS4.i18n.checks[check] && m.data.command === command,
|
||||||
|
|
|
@ -18,7 +18,7 @@ export async function createRollItemMacro(itemData: foundry.data.ItemData["_sour
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getOrCreateRollItemMacro(itemData: foundry.data.ItemData["_source"]): Promise<Macro | undefined> {
|
async function getOrCreateRollItemMacro(itemData: foundry.data.ItemData["_source"]): Promise<Macro | undefined> {
|
||||||
const command = `getGame().ds4.macros.rollItem("${itemData._id}");`;
|
const command = `game.ds4.macros.rollItem("${itemData._id}");`;
|
||||||
|
|
||||||
const existingMacro = getGame().macros?.find((m) => m.name === itemData.name && m.data.command === command);
|
const existingMacro = getGame().macros?.find((m) => m.name === itemData.name && m.data.command === command);
|
||||||
if (existingMacro) {
|
if (existingMacro) {
|
||||||
|
|
|
@ -35,11 +35,11 @@ export async function migrateActors(getActorUpdateData: ActorUpdateDataGetter):
|
||||||
try {
|
try {
|
||||||
const updateData = getActorUpdateData(actor.toObject());
|
const updateData = getActorUpdateData(actor.toObject());
|
||||||
if (updateData) {
|
if (updateData) {
|
||||||
logger.info(`Migrating Actor entity ${actor.name} (${actor.id})`);
|
logger.info(`Migrating Actor document ${actor.name} (${actor.id})`);
|
||||||
await actor.update(updateData);
|
await actor.update(updateData);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
err.message = `Error during migration of Actor entity ${actor.name} (${actor.id}), continuing anyways.`;
|
err.message = `Error during migration of Actor document ${actor.name} (${actor.id}), continuing anyways.`;
|
||||||
logger.error(err);
|
logger.error(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
{{!-- image --}}
|
{{!-- image --}}
|
||||||
{{> systems/ds4/templates/sheets/actor/components/rollable-image.hbs rollable=itemData.data.rollable
|
{{> systems/ds4/templates/sheets/actor/components/rollable-image.hbs rollable=itemData.data.rollable
|
||||||
src=itemData.img alt=(localize "DS4.EntityImageAltText" name=itemData.name) title=itemData.name
|
src=itemData.img alt=(localize "DS4.DocumentImageAltText" name=itemData.name) title=itemData.name
|
||||||
rollableTitle=(localize "DS4.RollableImageRollableTitle" name=itemData.name) rollableClass="rollable-item"}}
|
rollableTitle=(localize "DS4.RollableImageRollableTitle" name=itemData.name) rollableClass="rollable-item"}}
|
||||||
|
|
||||||
{{!-- amount --}}
|
{{!-- amount --}}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
"target": "ES2020",
|
"target": "ES2020",
|
||||||
"lib": ["DOM", "ES2020"],
|
"lib": ["DOM", "ES2020"],
|
||||||
"types": ["@league-of-foundry-developers/foundry-vtt-types"],
|
"types": ["@league-of-foundry-developers/foundry-vtt-types"],
|
||||||
|
"esModuleInterop": true,
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"forceConsistentCasingInFileNames": true,
|
"forceConsistentCasingInFileNames": true,
|
||||||
"strict": true,
|
"strict": true,
|
||||||
|
|
Loading…
Reference in a new issue