Add additional checks when editing items or effects
This commit is contained in:
parent
965c7c3ecf
commit
2158026437
4 changed files with 21 additions and 4 deletions
|
@ -200,6 +200,9 @@
|
||||||
"DS4.RollDialogCancelButton": "Abbrechen",
|
"DS4.RollDialogCancelButton": "Abbrechen",
|
||||||
"DS4.ErrorUnexpectedHtmlType": "Typfehler: Erwartet wurde '{exType}', tatsächlich erhalten wurde '{realType}'.",
|
"DS4.ErrorUnexpectedHtmlType": "Typfehler: Erwartet wurde '{exType}', tatsächlich erhalten wurde '{realType}'.",
|
||||||
"DS4.ErrorCouldNotFindForm": "Konnte HTML Element '{htmlElement}' nicht finden.",
|
"DS4.ErrorCouldNotFindForm": "Konnte HTML Element '{htmlElement}' nicht finden.",
|
||||||
|
"DS4.ErrorActorDoesNotHaveItem": "Der Aktor '{actor}' hat kein Item mit der ID '{id}'.",
|
||||||
|
"DS4.ErrorUnexpectedError": "Es gab einen unerwarteten Fehler im Dungeonslayers 4 System. Für mehr Details schauen Sie bitte in die Konsole (F12).",
|
||||||
|
"DS4.ErrorItemDoesNotHaveEffect": "Das Item '{item}' hat keinen Effekt mit der ID '{id}'.",
|
||||||
"DS4.RollDialogTargetLabel": "Probenwert",
|
"DS4.RollDialogTargetLabel": "Probenwert",
|
||||||
"DS4.RollDialogModifierLabel": "SL-Modifikator",
|
"DS4.RollDialogModifierLabel": "SL-Modifikator",
|
||||||
"DS4.RollDialogCoupLabel": "Immersieg bis",
|
"DS4.RollDialogCoupLabel": "Immersieg bis",
|
||||||
|
|
|
@ -200,6 +200,9 @@
|
||||||
"DS4.RollDialogCancelButton": "Cancel",
|
"DS4.RollDialogCancelButton": "Cancel",
|
||||||
"DS4.ErrorUnexpectedHtmlType": "Type Error: Expected '{exType}' but got '{realType}'.",
|
"DS4.ErrorUnexpectedHtmlType": "Type Error: Expected '{exType}' but got '{realType}'.",
|
||||||
"DS4.ErrorCouldNotFindForm": "Could not find HTML element '{htmlElement}'.",
|
"DS4.ErrorCouldNotFindForm": "Could not find HTML element '{htmlElement}'.",
|
||||||
|
"DS4.ErrorActorDoesNotHaveItem": "The actor '{actor}' does not have any item with the id '{id}'.",
|
||||||
|
"DS4.ErrorUnexpectedError": "There was an unexpected error in the Dungeonslayers 4 system. For more details, please take a look at the console (F12).",
|
||||||
|
"DS4.ErrorItemDoesNotHaveEffect": "The item '{item}' does not have any effect with the id '{id}'.",
|
||||||
"DS4.RollDialogTargetLabel": "Check Target Number",
|
"DS4.RollDialogTargetLabel": "Check Target Number",
|
||||||
"DS4.RollDialogModifierLabel": "Game Master Modifier",
|
"DS4.RollDialogModifierLabel": "Game Master Modifier",
|
||||||
"DS4.RollDialogCoupLabel": "Coup to",
|
"DS4.RollDialogCoupLabel": "Coup to",
|
||||||
|
|
|
@ -72,8 +72,15 @@ export class DS4ActorSheet extends ActorSheet<ActorSheet.Data<DS4Actor>> {
|
||||||
// Update Inventory Item
|
// Update Inventory Item
|
||||||
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 item = this.actor.getOwnedItem(li.data("itemId"));
|
const id = li.data("itemId");
|
||||||
item.sheet?.render(true);
|
const item = this.actor.getOwnedItem(id);
|
||||||
|
if (!item) {
|
||||||
|
throw new Error(game.i18n.format("DS4.ErrorActorDoesNotHaveItem", { id, actor: this.actor.name }));
|
||||||
|
}
|
||||||
|
if (!item.sheet) {
|
||||||
|
throw new Error(game.i18n.localize("DS4.ErrorUnexpectedError"));
|
||||||
|
}
|
||||||
|
item.sheet.render(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Delete Inventory Item
|
// Delete Inventory Item
|
||||||
|
|
|
@ -92,8 +92,12 @@ export class DS4ItemSheet extends ItemSheet<ItemSheet.Data<DS4Item>> {
|
||||||
case "create":
|
case "create":
|
||||||
return this._createActiveEffect();
|
return this._createActiveEffect();
|
||||||
case "edit":
|
case "edit":
|
||||||
const effect = this.item.effects.get(li.data("effectId"));
|
const id = li.data("effectId");
|
||||||
return effect?.sheet.render(true);
|
const effect = this.item.effects.get(id);
|
||||||
|
if (!effect) {
|
||||||
|
throw new Error(game.i18n.format("DS4.ErrorItemDoesNotHaveEffect", { id, item: this.item.name }));
|
||||||
|
}
|
||||||
|
return effect.sheet.render(true);
|
||||||
case "delete": {
|
case "delete": {
|
||||||
return this.item.deleteEmbeddedEntity("ActiveEffect", li.data("effectId"));
|
return this.item.deleteEmbeddedEntity("ActiveEffect", li.data("effectId"));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue