From c13ebb0b7689276f32000f607c815a26f8f5731a Mon Sep 17 00:00:00 2001 From: Gesina Schwalbe Date: Sat, 23 Jan 2021 23:44:49 +0100 Subject: [PATCH 01/53] add buttons in overviews now on bottom --- src/templates/actor/partials/items-overview.hbs | 7 +++---- .../partials/special-creature-abilites-overview.hbs | 5 +++-- src/templates/actor/partials/spells-overview.hbs | 6 ++++-- .../actor/partials/talents-abilities-overview.hbs | 13 ++++++------- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/templates/actor/partials/items-overview.hbs b/src/templates/actor/partials/items-overview.hbs index 55b34411..b51a97cb 100644 --- a/src/templates/actor/partials/items-overview.hbs +++ b/src/templates/actor/partials/items-overview.hbs @@ -15,9 +15,8 @@ {{#*inline "ifHasItemOfType"}} {{#if (and (ne itemsArray undefined) (gt itemsArray.length 0))}} {{> @partial-block}} -{{else}} -{{> systems/ds4/templates/actor/partials/overview-add-button.hbs dataType=dataType }} {{/if}} +{{> systems/ds4/templates/actor/partials/overview-add-button.hbs dataType=dataType }} {{/inline}} @@ -48,8 +47,8 @@ {{> @partial-block }} {{!-- description --}}
{{localize 'DS4.Description'}}
- {{!-- add button --}} - {{> systems/ds4/templates/actor/partials/overview-add-button.hbs dataType=dataType }} + {{!-- control buttons placeholder --}} +
{{/inline}} diff --git a/src/templates/actor/partials/special-creature-abilites-overview.hbs b/src/templates/actor/partials/special-creature-abilites-overview.hbs index 28637149..078fa287 100644 --- a/src/templates/actor/partials/special-creature-abilites-overview.hbs +++ b/src/templates/actor/partials/special-creature-abilites-overview.hbs @@ -42,8 +42,8 @@
{{localize 'DS4.ItemName'}}
{{!-- description --}}
{{localize 'DS4.Description'}}
- {{!-- add button --}} - {{> systems/ds4/templates/actor/partials/overview-add-button.hbs dataType=dataType }} + {{!-- control buttons placeholder --}} +
{{/inline}} @@ -58,4 +58,5 @@ {{> baseItemListEntry item=item}} {{/each}} + {{> systems/ds4/templates/actor/partials/overview-add-button.hbs dataType='specialCreatureAbility' }} \ No newline at end of file diff --git a/src/templates/actor/partials/spells-overview.hbs b/src/templates/actor/partials/spells-overview.hbs index 8bcd33e3..e19e863f 100644 --- a/src/templates/actor/partials/spells-overview.hbs +++ b/src/templates/actor/partials/spells-overview.hbs @@ -55,8 +55,8 @@
{{!-- description --}} {{!--
{{localize 'DS4.Description'}}
--}} - {{!-- add button --}} - {{> systems/ds4/templates/actor/partials/overview-add-button.hbs dataType='spell' }} + {{!-- control buttons placeholder --}} +
{{#each itemsByType.spell as |item id|}}
  • @@ -90,4 +90,6 @@
  • {{/each}} + {{!-- add button --}} + {{> systems/ds4/templates/actor/partials/overview-add-button.hbs dataType='spell' }} \ No newline at end of file diff --git a/src/templates/actor/partials/talents-abilities-overview.hbs b/src/templates/actor/partials/talents-abilities-overview.hbs index e40b2aa7..19bac512 100644 --- a/src/templates/actor/partials/talents-abilities-overview.hbs +++ b/src/templates/actor/partials/talents-abilities-overview.hbs @@ -15,9 +15,8 @@ {{#*inline "ifHasItemOfType"}} {{#if (and (ne itemsArray undefined) (gt itemsArray.length 0))}} {{> @partial-block}} -{{else}} - {{> systems/ds4/templates/actor/partials/overview-add-button.hbs dataType=dataType }} {{/if}} +{{> systems/ds4/templates/actor/partials/overview-add-button.hbs dataType=dataType }} {{/inline}} @@ -98,7 +97,7 @@ {{/inline}} {{!-- -!-- Render a list header for a base item list entries from a given item. +!-- Render a list header for a base item list entry from a given item. !-- The partial assumes a variable dataType to be given in the context. !-- !-- @param dataType: the string item type for the list @@ -111,8 +110,8 @@
    {{localize 'DS4.ItemName'}}
    {{!-- description --}}
    {{localize 'DS4.Description'}}
    - {{!-- add button --}} - {{> systems/ds4/templates/actor/partials/overview-add-button.hbs dataType=dataType }} + {{!-- control buttons placeholder --}} +
    {{/inline}} @@ -133,8 +132,8 @@
    {{localize 'DS4.TalentRank'}}
    {{!-- description --}}
    {{localize 'DS4.Description'}}
    - {{!-- add button --}} - {{> systems/ds4/templates/actor/partials/overview-add-button.hbs dataType='talent' }} + {{!-- control buttons placeholder --}} +
    {{#each itemsByType.talent as |item id|}} {{> talentListEntry item=item}} From 4c8bd29e2e068b08ee96266d7f9972e9e96eecc0 Mon Sep 17 00:00:00 2001 From: Gesina Schwalbe Date: Sat, 23 Jan 2021 23:49:45 +0100 Subject: [PATCH 02/53] added unit to char height & weigt title --- src/lang/de.json | 4 ++-- src/lang/en.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lang/de.json b/src/lang/de.json index f81a5f29..a2ce52d7 100644 --- a/src/lang/de.json +++ b/src/lang/de.json @@ -144,9 +144,9 @@ "DS4.CharacterProfileBirthday": "Geburtstag", "DS4.CharacterProfileBirthplace": "Geburtsort", "DS4.CharacterProfileAge": "Alter", - "DS4.CharacterProfileHeight": "Größe", + "DS4.CharacterProfileHeight": "Größe [cm]", "DS4.CharacterProfileHairColor": "Haarfarbe", - "DS4.CharacterProfileWeight": "Gewicht", + "DS4.CharacterProfileWeight": "Gewicht [kg]", "DS4.CharacterProfileEyeColor": "Augenfarbe", "DS4.CharacterProfileSpecialCharacteristics": "Besondere Eigenschaften", "DS4.CharacterCurrencyGold": "Gold", diff --git a/src/lang/en.json b/src/lang/en.json index ee1927ee..8c754fbd 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -144,9 +144,9 @@ "DS4.CharacterProfileBirthday": "Birthday", "DS4.CharacterProfileBirthplace": "Birthplace", "DS4.CharacterProfileAge": "Age", - "DS4.CharacterProfileHeight": "Height", + "DS4.CharacterProfileHeight": "Height [m]", "DS4.CharacterProfileHairColor": "Hair Color", - "DS4.CharacterProfileWeight": "Weight", + "DS4.CharacterProfileWeight": "Weight [kg]", "DS4.CharacterProfileEyeColor": "Eye Color", "DS4.CharacterProfileSpecialCharacteristics": "Special Characteristics", "DS4.CharacterCurrencyGold": "Gold", From b1e7f61ed57bd48761d58ecf38be97a2972b8bea Mon Sep 17 00:00:00 2001 From: Gesina Schwalbe Date: Sun, 24 Jan 2021 01:20:55 +0100 Subject: [PATCH 03/53] changed char special characteristics to textarea --- src/templates/actor/character-sheet.hbs | 32 ++++++++++++------------ src/templates/actor/partials/profile.hbs | 8 +++++- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/templates/actor/character-sheet.hbs b/src/templates/actor/character-sheet.hbs index 0fb538f9..d425326c 100644 --- a/src/templates/actor/character-sheet.hbs +++ b/src/templates/actor/character-sheet.hbs @@ -84,24 +84,24 @@ {{localize 'DS4.HeadingBiography'}} - {{!-- Sheet Body --}} -
    - {{!-- Items Tab --}} - {{> systems/ds4/templates/actor/partials/character-inventory.hbs}} +{{!-- Sheet Body (remove indentation to avoid annoying Handlebars auto-indent) --}} +
    +{{!-- Items Tab --}} +{{> systems/ds4/templates/actor/partials/character-inventory.hbs}} - {{!-- Spells Tab --}} - {{> systems/ds4/templates/actor/partials/spells-overview.hbs}} +{{!-- Spells Tab --}} +{{> systems/ds4/templates/actor/partials/spells-overview.hbs}} - {{!-- Talents Tab --}} - {{> systems/ds4/templates/actor/partials/talents-abilities-overview.hbs}} +{{!-- Talents Tab --}} +{{> systems/ds4/templates/actor/partials/talents-abilities-overview.hbs}} - {{! Profile Tab --}} - {{> systems/ds4/templates/actor/partials/profile.hbs}} +{{! Profile Tab --}} +{{> systems/ds4/templates/actor/partials/profile.hbs owner=owner}} - {{!-- Biography Tab --}} -
    - {{editor content=data.profile.biography target="data.profile.biography" button=true owner=owner - editable=editable}} -
    -
    +{{!-- Biography Tab --}} +
    +{{editor content=data.profile.biography target="data.profile.biography" button=true owner=owner +editable=editable}} +
    +
    diff --git a/src/templates/actor/partials/profile.hbs b/src/templates/actor/partials/profile.hbs index be95eeb5..2359d8fb 100644 --- a/src/templates/actor/partials/profile.hbs +++ b/src/templates/actor/partials/profile.hbs @@ -1,7 +1,7 @@
    {{#each data.profile as |profile-data-value profile-data-key|}} - {{#if (ne profile-data-key 'biography')}} + {{#if (and (ne profile-data-key 'biography') (ne profile-data-key 'specialCharacteristics'))}}
    {{/if}} {{/each}} +
    + + +
    From a8158894ddda1e4886e4dc8dc3cc58a848f03b57 Mon Sep 17 00:00:00 2001 From: Gesina Schwalbe Date: Sun, 24 Jan 2021 11:06:07 +0100 Subject: [PATCH 04/53] added thin space between value and unit in spells --- src/templates/actor/partials/spells-overview.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/templates/actor/partials/spells-overview.hbs b/src/templates/actor/partials/spells-overview.hbs index e19e863f..356ef30d 100644 --- a/src/templates/actor/partials/spells-overview.hbs +++ b/src/templates/actor/partials/spells-overview.hbs @@ -13,7 +13,7 @@
    {{#if unitDatum.value }} - {{unitDatum.value}}{{lookup unitAbbrs unitDatum.unit}} + {{unitDatum.value}} {{lookup unitAbbrs unitDatum.unit}} {{else}}-{{/if}}
    {{/inline}} From 0b1c342ecfc0302306aa753a09c71f1cb0a4d1b2 Mon Sep 17 00:00:00 2001 From: Gesina Schwalbe Date: Sun, 24 Jan 2021 13:11:08 +0100 Subject: [PATCH 05/53] select text of input fields when focused - the content of input fields of relevant sheets and dialogs are now selected upon focus - autofocus the Gamemaster roll modifier in the roll dialog --- src/module/ds4.ts | 18 ++++++++++++++++++ src/templates/roll/roll-options.hbs | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/module/ds4.ts b/src/module/ds4.ts index 81115a4c..a20f18e5 100644 --- a/src/module/ds4.ts +++ b/src/module/ds4.ts @@ -133,3 +133,21 @@ Hooks.once("setup", function () { Hooks.once("ready", function () { migration.migrate(); }); + +/** + * Select the text of input elements in given sheets via onfocus listener. + * The hook names are of the form "render"+sheet_superclassname and are called within + * the render() method of the foundry Application class. + * Note: The render hooks of all classes in the class hierarchy are called, + * so e.g. for a Dialog, both "renderDialog" and "renderApplication" are called + * (in this order). + */ +["renderApplication", "renderActorSheet", "renderItemSheet"].forEach((hookName: string) => { + Hooks.on(hookName, (app: Dialog, html: JQueryStatic, data: any) => { + $(html) + .find("input") + .on("focus", (ev: JQuery.FocusEvent) => { + ev.currentTarget.select(); + }); + }); +}); diff --git a/src/templates/roll/roll-options.hbs b/src/templates/roll/roll-options.hbs index 8c3e7dc3..153d463d 100644 --- a/src/templates/roll/roll-options.hbs +++ b/src/templates/roll/roll-options.hbs @@ -2,7 +2,7 @@ - + From 159f5b852941ce5825eab68365a58bb507031dcf Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Sun, 24 Jan 2021 03:19:31 +0100 Subject: [PATCH 06/53] make it possible to pass rollMode to createCheckRoll --- src/module/rolls/check-factory.ts | 35 ++++++++++++++--------------- src/templates/roll/roll-options.hbs | 8 ++++--- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/module/rolls/check-factory.ts b/src/module/rolls/check-factory.ts index c972120c..57e0ac56 100644 --- a/src/module/rolls/check-factory.ts +++ b/src/module/rolls/check-factory.ts @@ -28,7 +28,7 @@ class CheckFactory { private gmModifier: number, passedOptions: Partial = {}, ) { - this.checkOptions = new DefaultCheckOptions().mergeWith(passedOptions); + this.checkOptions = defaultCheckOptions.mergeWith(passedOptions); } private checkOptions: DS4CheckFactoryOptions; @@ -45,7 +45,6 @@ class CheckFactory { const roll = new rollCls(formula); const rollModeTemplate = this.checkOptions.rollMode; - console.log(rollModeTemplate); return roll.toMessage({}, { rollMode: rollModeTemplate, create: true }); } @@ -76,8 +75,8 @@ class CheckFactory { /** * Asks the user for all unknown/necessary information and passes them on to perform a roll. - * @param targetValue {number} The Check Target Number ("CTN") - * @param options {Partial} Options changing the behaviour of the roll and message. + * @param targetValue The Check Target Number ("CTN") + * @param options Options changing the behaviour of the roll and message. */ export async function createCheckRoll( targetValue: number, @@ -86,6 +85,8 @@ export async function createCheckRoll( // Ask for additional required data; const gmModifierData = await askGmModifier(targetValue, options); + const newTargetValue = gmModifierData.checkTargetValue ?? targetValue; + const gmModifier = gmModifierData.gmModifier ?? 0; const newOptions: Partial = { maxCritSuccess: gmModifierData.maxCritSuccess ?? options.maxCritSuccess ?? undefined, minCritFailure: gmModifierData.minCritFailure ?? options.minCritFailure ?? undefined, @@ -94,7 +95,7 @@ export async function createCheckRoll( }; // Create Factory - const cf = new CheckFactory(gmModifierData.checkTargetValue, gmModifierData.gmModifier, newOptions); + const cf = new CheckFactory(newTargetValue, gmModifier, newOptions); // Possibly additional processing @@ -108,13 +109,13 @@ export async function createCheckRoll( * @notes * At the moment, this asks for more data than it will do after some iterations. * - * @returns {Promise} The data given by the user. + * @returns The data given by the user. */ async function askGmModifier( targetValue: number, options: Partial = {}, { template, title }: { template?: string; title?: string } = {}, -): Promise { +): Promise> { // Render model interface and return value const usedTemplate = template ?? "systems/ds4/templates/roll/roll-options.hbs"; const usedTitle = title ?? game.i18n.localize("DS4.RollDialogDefaultTitle"); @@ -124,7 +125,7 @@ async function askGmModifier( checkTargetValue: targetValue, maxCritSuccess: options.maxCritSuccess ?? defaultCheckOptions.maxCritSuccess, minCritFailure: options.minCritFailure ?? defaultCheckOptions.minCritFailure, - rollModes: rollModes, + rollMode: options.rollMode, config: DS4, }; const renderedHtml = await renderTemplate(usedTemplate, templateData); @@ -167,22 +168,20 @@ async function askGmModifier( ).render(true); }); const dialogForm = await dialogPromise; - return parseDialogFormData(dialogForm, targetValue); + return parseDialogFormData(dialogForm); } /** * Extracts Dialog data from the returned DOM element. - * @param formData {HTMLFormElement} The filed dialog - * @param targetValue {number} The previously known target value (slated for removal once data automation is available) + * @param formData The filed dialog */ -function parseDialogFormData(formData: HTMLFormElement, targetValue: number): IntermediateGmModifierData { +function parseDialogFormData(formData: HTMLFormElement): Partial { return { - checkTargetValue: parseInt(formData["ctv"]?.value) ?? targetValue, - gmModifier: parseInt(formData["gmmod"]?.value) ?? 0, - maxCritSuccess: parseInt(formData["maxcoup"]?.value) ?? defaultCheckOptions.maxCritSuccess, - minCritFailure: parseInt(formData["minfumble"]?.value) ?? defaultCheckOptions.minCritFailure, - useSlayingDice: false, - rollMode: formData["visibility"]?.value ?? defaultCheckOptions.rollMode, + checkTargetValue: parseInt(formData["ctv"]?.value), + gmModifier: parseInt(formData["gmmod"]?.value), + maxCritSuccess: parseInt(formData["maxcoup"]?.value), + minCritFailure: parseInt(formData["minfumble"]?.value), + rollMode: formData["visibility"]?.value, }; } diff --git a/src/templates/roll/roll-options.hbs b/src/templates/roll/roll-options.hbs index 8c3e7dc3..b842c3a1 100644 --- a/src/templates/roll/roll-options.hbs +++ b/src/templates/roll/roll-options.hbs @@ -9,8 +9,10 @@ - + \ No newline at end of file From 867c417737c0f415b973ff9e0c3ad059307f42f5 Mon Sep 17 00:00:00 2001 From: Gesina Schwalbe Date: Sun, 24 Jan 2021 16:11:59 +0100 Subject: [PATCH 07/53] removed unnecessary partial arg in char sheet The argument was accidentally introduced before. --- src/templates/actor/character-sheet.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/templates/actor/character-sheet.hbs b/src/templates/actor/character-sheet.hbs index d425326c..75be93ff 100644 --- a/src/templates/actor/character-sheet.hbs +++ b/src/templates/actor/character-sheet.hbs @@ -96,7 +96,7 @@ {{> systems/ds4/templates/actor/partials/talents-abilities-overview.hbs}} {{! Profile Tab --}} -{{> systems/ds4/templates/actor/partials/profile.hbs owner=owner}} +{{> systems/ds4/templates/actor/partials/profile.hbs}} {{!-- Biography Tab --}}
    From 3ddabcaaac797287b0bdcae342210501ac652cdb Mon Sep 17 00:00:00 2001 From: Gesina Schwalbe Date: Sun, 24 Jan 2021 17:39:11 +0100 Subject: [PATCH 08/53] fixed some German translations --- src/lang/de.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/lang/de.json b/src/lang/de.json index f81a5f29..455c97c4 100644 --- a/src/lang/de.json +++ b/src/lang/de.json @@ -12,11 +12,11 @@ "DS4.HeadingSpells": "Zaubersprüche", "DS4.HeadingDescription": "Beschreibung", "DS4.HeadingSpecialCreatureAbilites": "Besondere Fähigkeiten", - "DS4.AttackType": "Angriffs Typ", + "DS4.AttackType": "Angriffstyp", "DS4.AttackTypeAbbr": "AT", - "DS4.WeaponBonus": "Waffen Bonus", + "DS4.WeaponBonus": "Waffenbonus", "DS4.WeaponBonusAbbr": "WB", - "DS4.OpponentDefense": "Gegner Abwehr", + "DS4.OpponentDefense": "Gegnerabwehr", "DS4.OpponentDefenseAbbr": "GA", "DS4.AttackTypeMelee": "Schlagen", "DS4.AttackTypeRanged": "Schießen", @@ -61,9 +61,9 @@ "DS4.ItemTypeSpecialCreatureAbilityPlural": "Besondere Kreaturenfähigkeiten", "DS4.ArmorType": "Panzerungstyp", "DS4.ArmorTypeAbbr": "PAT", - "DS4.ArmorMaterialType": "Material Typ", + "DS4.ArmorMaterialType": "Materialtyp", "DS4.ArmorMaterialTypeAbbr": "Mat.", - "DS4.ArmorValue": "Panzerungs Wert", + "DS4.ArmorValue": "Panzerungswert", "DS4.ArmorValueAbbr": "PA", "DS4.ArmorTypeBody": "Körper", "DS4.ArmorTypeBodyAbbr": "Körper", @@ -125,7 +125,7 @@ "DS4.CombatValuesTargetedSpellcasting": "Zielzaubern", "DS4.CharacterBaseInfoRace": "Volk", "DS4.CharacterBaseInfoClass": "Klasse", - "DS4.CharacterBaseInfoHeroClass": "Helden Klasse", + "DS4.CharacterBaseInfoHeroClass": "Heldenklasse", "DS4.CharacterBaseInfoCulture": "Kultur", "DS4.CharacterProgressionLevel": "Stufe", "DS4.CharacterProgressionExperiencePoints": "Erfahrungspunkte", @@ -193,7 +193,7 @@ "DS4.UnitCustom": "individuell", "DS4.UnitCustomAbbr": " ", "DS4.RollDialogDefaultTitle": "Proben-Optionen", - "DS4.RollDialogOkButton": "Ok", + "DS4.RollDialogOkButton": "OK", "DS4.RollDialogCancelButton": "Abbrechen", "DS4.ErrorUnexpectedHtmlType": "Typfehler: Erwartet wurde {exType}, tatsächlich erhalten wurde {realType}", "DS4.RollDialogTargetLabel": "Probenwert", From 3ba5c0d6409950681ccb72a09c53ae0cbff53ad3 Mon Sep 17 00:00:00 2001 From: Gesina Schwalbe Date: Sun, 24 Jan 2021 17:40:08 +0100 Subject: [PATCH 09/53] localized effect control buttons --- src/lang/de.json | 3 +++ src/lang/en.json | 3 +++ src/templates/item/partials/effects.hbs | 10 ++++++---- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/lang/de.json b/src/lang/de.json index 455c97c4..d7cb9c9d 100644 --- a/src/lang/de.json +++ b/src/lang/de.json @@ -2,6 +2,9 @@ "DS4.UserInteractionAddItem": "Neu", "DS4.UserInteractionEditItem": "Bearbeiten", "DS4.UserInteractionDeleteItem": "Löschen", + "DS4.UserInteractionAddEffect": "Neuer Effekt", + "DS4.UserInteractionEditEffect": "Effekt bearbeiten", + "DS4.UserInteractionDeleteEffect": "Effekt löschen", "DS4.NotOwned": "Nicht besessen", "DS4.HeadingBiography": "Biografie", "DS4.HeadingDetails": "Details", diff --git a/src/lang/en.json b/src/lang/en.json index ee1927ee..b3b7af82 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -2,6 +2,9 @@ "DS4.UserInteractionAddItem": "Add item", "DS4.UserInteractionEditItem": "Edit item", "DS4.UserInteractionDeleteItem": "Delete item", + "DS4.UserInteractionAddEffect": "Add Effect", + "DS4.UserInteractionEditEffect": "Edit Effect", + "DS4.UserInteractionDeleteEffect": "Delete Effect", "DS4.NotOwned": "No owner", "DS4.HeadingBiography": "Biography", "DS4.HeadingDetails": "Details", diff --git a/src/templates/item/partials/effects.hbs b/src/templates/item/partials/effects.hbs index b829bfac..a064313e 100644 --- a/src/templates/item/partials/effects.hbs +++ b/src/templates/item/partials/effects.hbs @@ -5,16 +5,18 @@
    Name
    {{#each item.effects as |effect id|}}
  • {{effect.label}}

    - - + + + +
  • {{/each}} From a5d91eca71b7f0df6790ccc6ed0b2887a698ec44 Mon Sep 17 00:00:00 2001 From: Gesina Schwalbe Date: Sun, 24 Jan 2021 17:45:39 +0100 Subject: [PATCH 10/53] localized edit & delete item buttons --- src/templates/actor/partials/overview-control-buttons.hbs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/templates/actor/partials/overview-control-buttons.hbs b/src/templates/actor/partials/overview-control-buttons.hbs index d10dbc3f..2c85899f 100644 --- a/src/templates/actor/partials/overview-control-buttons.hbs +++ b/src/templates/actor/partials/overview-control-buttons.hbs @@ -3,6 +3,6 @@ !-- The current item is defined by the data-item-id HTML property of the parent li element. --}}
    - - + +
    From d831f376e1b6c92929788f45d54816add4dd6f98 Mon Sep 17 00:00:00 2001 From: Gesina Schwalbe Date: Sun, 24 Jan 2021 17:47:47 +0100 Subject: [PATCH 11/53] moved localization mappings in CONFIG.DS4.i18nKeys - moved all mappings in CONFIG.DS4 that belong to localization into common parent CONFIG.DS4.i18nKeys - adapted logic in ds4.ts to not overwrite entries in CONFIG.DS4.i18nKeys - adapted calls to config in templates --- src/module/config.ts | 561 +++++++++--------- src/module/ds4.ts | 40 +- src/module/item/item-data.ts | 2 +- src/templates/actor/character-sheet.hbs | 12 +- src/templates/actor/creature-sheet.hbs | 14 +- .../actor/partials/attributes-traits.hbs | 4 +- .../actor/partials/character-inventory.hbs | 6 +- .../actor/partials/character-progression.hbs | 4 +- .../actor/partials/combat-values.hbs | 2 +- .../actor/partials/items-overview.hbs | 10 +- src/templates/actor/partials/profile.hbs | 4 +- .../actor/partials/spells-overview.hbs | 6 +- src/templates/item/armor-sheet.hbs | 4 +- src/templates/item/partials/details.hbs | 2 +- src/templates/item/partials/sheet-header.hbs | 2 +- src/templates/item/spell-sheet.hbs | 8 +- src/templates/item/weapon-sheet.hbs | 2 +- src/templates/roll/roll-options.hbs | 2 +- 18 files changed, 333 insertions(+), 352 deletions(-) diff --git a/src/module/config.ts b/src/module/config.ts index cd927290..5654c189 100644 --- a/src/module/config.ts +++ b/src/module/config.ts @@ -9,12 +9,293 @@ export const DS4 = { =============================================================================================`, /** - * Define the set of acttack types that can be performed with weapon items + * A dictionary of dictionaries each mapping keys to localized strings. + * To be filled with the localizations derived from i18nKeys. */ - attackTypes: { - melee: "DS4.AttackTypeMelee", - ranged: "DS4.AttackTypeRanged", - meleeRanged: "DS4.AttackTypeMeleeRanged", + i18n: { + // to be filled with the localized mappings from i18nKeys + }, + /** + * A dictionary of dictionaries each mapping keys to localization keys. + */ + i18nKeys: { + /** + * Define the set of acttack types that can be performed with weapon items + */ + attackTypes: { + melee: "DS4.AttackTypeMelee", + ranged: "DS4.AttackTypeRanged", + meleeRanged: "DS4.AttackTypeMeleeRanged", + }, + + /** + * Define the set of item availabilties + */ + itemAvailabilities: { + unset: "DS4.ItemAvailabilityUnset", + hamlet: "DS4.ItemAvailabilityHamlet", + village: "DS4.ItemAvailabilityVilage", + city: "DS4.ItemAvailabilityCity", + elves: "DS4.ItemAvailabilityElves", + dwarves: "DS4.ItemAvailabilityDwarves", + nowhere: "DS4.ItemAvailabilityNowhere", + }, + + /** + * Define the set of item types + */ + itemTypes: { + weapon: "DS4.ItemTypeWeapon", + armor: "DS4.ItemTypeArmor", + shield: "DS4.ItemTypeShield", + spell: "DS4.ItemTypeSpell", + trinket: "DS4.ItemTypeTrinket", + equipment: "DS4.ItemTypeEquipment", + talent: "DS4.ItemTypeTalent", + racialAbility: "DS4.ItemTypeRacialAbility", + language: "DS4.ItemTypeLanguage", + alphabet: "DS4.ItemTypeAlphabet", + specialCreatureAbility: "DS4.ItemTypeSpecialCreatureAbility", + }, + + /** + * Define the set of armor types, a character may only wear one item of each at any given time + */ + armorTypes: { + body: "DS4.ArmorTypeBody", + helmet: "DS4.ArmorTypeHelmet", + vambrace: "DS4.ArmorTypeVambrace", + greaves: "DS4.ArmorTypeGreaves", + vambraceGreaves: "DS4.ArmorTypeVambraceGreaves", + }, + + /** + * Define abbreviations for the armor types + */ + armorTypesAbbr: { + body: "DS4.ArmorTypeBodyAbbr", + helmet: "DS4.ArmorTypeHelmetAbbr", + vambrace: "DS4.ArmorTypeVambraceAbbr", + greaves: "DS4.ArmorTypeGreavesAbbr", + vambraceGreaves: "DS4.ArmorTypeVambraceGreavesAbbr", + }, + + /** + * Define the set of armor materials, used to determine if a characer may wear the armor without additional penalties + */ + armorMaterialTypes: { + cloth: "DS4.ArmorMaterialTypeCloth", + leather: "DS4.ArmorMaterialTypeLeather", + chain: "DS4.ArmorMaterialTypeChain", + plate: "DS4.ArmorMaterialTypePlate", + }, + + /** + * Define the abbreviations of armor materials + */ + armorMaterialTypesAbbr: { + cloth: "DS4.ArmorMaterialTypeClothAbbr", + leather: "DS4.ArmorMaterialTypeLeatherAbbr", + chain: "DS4.ArmorMaterialTypeChainAbbr", + plate: "DS4.ArmorMaterialTypePlateAbbr", + }, + + spellTypes: { + spellcasting: "DS4.SpellTypeSpellcasting", + targetedSpellcasting: "DS4.SpellTypeTargetedSpellcasting", + }, + + spellCategories: { + healing: "DS4.SpellCategoryHealing", + fire: "DS4.SpellCategoryFire", + ice: "DS4.SpellCategoryIce", + light: "DS4.SpellCategoryLight", + darkness: "DS4.SpellCategoryDarkness", + mindAffecting: "DS4.SpellCategoryMindAffecting", + electricity: "DS4.SpellCategoryElectricity", + none: "DS4.SpellCategoryNone", + unset: "DS4.SpellCategoryUnset", + }, + + /** + * Define the set of actor types + */ + actorTypes: { + character: "DS4.ActorTypeCharacter", + creature: "DS4.ActorTypeCreature", + }, + + /** + * Define the set of attributes an actor has + */ + attributes: { + body: "DS4.AttributeBody", + mobility: "DS4.AttributeMobility", + mind: "DS4.AttributeMind", + }, + + /** + * Define the set of traits an actor has + */ + traits: { + strength: "DS4.TraitStrength", + agility: "DS4.TraitAgility", + intellect: "DS4.TraitIntellect", + constitution: "DS4.TraitConstitution", + dexterity: "DS4.TraitDexterity", + aura: "DS4.TraitAura", + }, + + /** + * Define the set of combat values an actor has + */ + combatValues: { + hitPoints: "DS4.CombatValuesHitPoints", + defense: "DS4.CombatValuesDefense", + initiative: "DS4.CombatValuesInitiative", + movement: "DS4.CombatValuesMovement", + meleeAttack: "DS4.CombatValuesMeleeAttack", + rangedAttack: "DS4.CombatValuesRangedAttack", + spellcasting: "DS4.CombatValuesSpellcasting", + targetedSpellcasting: "DS4.CombatValuesTargetedSpellcasting", + }, + + /** + * Define the base info of a character + */ + characterBaseInfo: { + race: "DS4.CharacterBaseInfoRace", + class: "DS4.CharacterBaseInfoClass", + heroClass: "DS4.CharacterBaseInfoHeroClass", + culture: "DS4.CharacterBaseInfoCulture", + }, + + /** + * Define the progression info of a character + */ + characterProgression: { + level: "DS4.CharacterProgressionLevel", + experiencePoints: "DS4.CharacterProgressionExperiencePoints", + talentPoints: "DS4.CharacterProgressionTalentPoints", + progressPoints: "DS4.CharacterProgressionProgressPoints", + }, + + /** + * Define the language info of a character + */ + characterLanguage: { + languages: "DS4.CharacterLanguageLanguages", + alphabets: "DS4.CharacterLanguageAlphabets", + }, + + /** + * Define the profile info of a character + */ + characterProfile: { + biography: "DS4.CharacterProfileBiography", + gender: "DS4.CharacterProfileGender", + birthday: "DS4.CharacterProfileBirthday", + birthplace: "DS4.CharacterProfileBirthplace", + age: "DS4.CharacterProfileAge", + height: "DS4.CharacterProfileHeight", + hairColor: "DS4.CharacterProfileHairColor", + weight: "DS4.CharacterProfileWeight", + eyeColor: "DS4.CharacterProfileEyeColor", + specialCharacteristics: "DS4.CharacterProfileSpecialCharacteristics", + }, + /** + * Define currency elements of a character + */ + characterCurrency: { + gold: "DS4.CharacterCurrencyGold", + silver: "DS4.CharacterCurrencySilver", + copper: "DS4.CharacterCurrencyCopper", + }, + + /** + * Define the different creature types a creature can be + */ + creatureTypes: { + animal: "DS4.CreatureTypeAnimal", + construct: "DS4.CreatureTypeConstruct", + humanoid: "DS4.CreatureTypeHumanoid", + magicalEntity: "DS4.CreatureTypeMagicalEntity", + plantBeing: "DS4.CreatureTypePlantBeing", + undead: "DS4.CreatureTypeUndead", + }, + + /** + * Define the different size categories creatures fall into + */ + creatureSizeCategories: { + tiny: "DS4.CreatureSizeCategoryTiny", + small: "DS4.CreatureSizeCategorySmall", + normal: "DS4.CreatureSizeCategoryNormal", + large: "DS4.CreatureSizeCategoryLarge", + huge: "DS4.CreatureSizeCategoryHuge", + colossal: "DS4.CreatureSizeCategoryColossal", + }, + + /** + * Define the base info of a creature + */ + creatureBaseInfo: { + loot: "DS4.CreatureBaseInfoLoot", + foeFactor: "DS4.CreatureBaseInfoFoeFactor", + creatureType: "DS4.CreatureBaseInfoCreatureType", + sizeCategory: "DS4.CreatureBaseInfoSizeCategory", + experiencePoints: "DS4.CreatureBaseInfoExperiencePoints", + description: "DS4.CreatureBaseInfoDescription", + }, + + /** + * Define translations for available distance units + */ + distanceUnits: { + meter: "DS4.UnitMeters", + kilometer: "DS4.UnitKilometers", + custom: "DS4.UnitCustom", + }, + /** + * Define abbreviations for available distance units + */ + distanceUnitsAbbr: { + meter: "DS4.UnitMetersAbbr", + kilometer: "DS4.UnitKilometersAbbr", + custom: "DS4.UnitCustomAbbr", + }, + + /** + * Define translations for available distance units + */ + temporalUnits: { + rounds: "DS4.UnitRounds", + minutes: "DS4.UnitMinutes", + hours: "DS4.UnitHours", + days: "DS4.UnitDays", + custom: "DS4.UnitCustom", + }, + + /** + * Define abbreviations for available units + */ + temporalUnitsAbbr: { + rounds: "DS4.UnitRoundsAbbr", + minutes: "DS4.UnitMinutesAbbr", + hours: "DS4.UnitHoursAbbr", + days: "DS4.UnitDaysAbbr", + custom: "DS4.UnitCustomAbbr", + }, + + /** + * Define localization strings for Chat Visibility + */ + chatVisibilities: { + roll: "DS4.ChatVisibilityRoll", + gmroll: "DS4.ChatVisibilityGmRoll", + blindroll: "DS4.ChatVisibilityBlindRoll", + selfroll: "DS4.ChatVisibilitySelfRoll", + }, }, /** @@ -34,182 +315,6 @@ export const DS4 = { targetedSpellcasting: "systems/ds4/assets/icons/official/combat-values/targeted-spellcasting.png", }, - /** - * Define the set of item availabilties - */ - itemAvailabilities: { - unset: "DS4.ItemAvailabilityUnset", - hamlet: "DS4.ItemAvailabilityHamlet", - village: "DS4.ItemAvailabilityVilage", - city: "DS4.ItemAvailabilityCity", - elves: "DS4.ItemAvailabilityElves", - dwarves: "DS4.ItemAvailabilityDwarves", - nowhere: "DS4.ItemAvailabilityNowhere", - }, - - /** - * Define the set of item types - */ - itemTypes: { - weapon: "DS4.ItemTypeWeapon", - armor: "DS4.ItemTypeArmor", - shield: "DS4.ItemTypeShield", - spell: "DS4.ItemTypeSpell", - trinket: "DS4.ItemTypeTrinket", - equipment: "DS4.ItemTypeEquipment", - talent: "DS4.ItemTypeTalent", - racialAbility: "DS4.ItemTypeRacialAbility", - language: "DS4.ItemTypeLanguage", - alphabet: "DS4.ItemTypeAlphabet", - specialCreatureAbility: "DS4.ItemTypeSpecialCreatureAbility", - }, - - /** - * Define the set of armor types, a character may only wear one item of each at any given time - */ - armorTypes: { - body: "DS4.ArmorTypeBody", - helmet: "DS4.ArmorTypeHelmet", - vambrace: "DS4.ArmorTypeVambrace", - greaves: "DS4.ArmorTypeGreaves", - vambraceGreaves: "DS4.ArmorTypeVambraceGreaves", - }, - - /** - * Define abbreviations for the armor types - */ - armorTypesAbbr: { - body: "DS4.ArmorTypeBodyAbbr", - helmet: "DS4.ArmorTypeHelmetAbbr", - vambrace: "DS4.ArmorTypeVambraceAbbr", - greaves: "DS4.ArmorTypeGreavesAbbr", - vambraceGreaves: "DS4.ArmorTypeVambraceGreavesAbbr", - }, - - /** - * Define the set of armor materials, used to determine if a characer may wear the armor without additional penalties - */ - armorMaterialTypes: { - cloth: "DS4.ArmorMaterialTypeCloth", - leather: "DS4.ArmorMaterialTypeLeather", - chain: "DS4.ArmorMaterialTypeChain", - plate: "DS4.ArmorMaterialTypePlate", - }, - - /** - * Define the abbreviations of armor materials - */ - armorMaterialTypesAbbr: { - cloth: "DS4.ArmorMaterialTypeClothAbbr", - leather: "DS4.ArmorMaterialTypeLeatherAbbr", - chain: "DS4.ArmorMaterialTypeChainAbbr", - plate: "DS4.ArmorMaterialTypePlateAbbr", - }, - - spellTypes: { - spellcasting: "DS4.SpellTypeSpellcasting", - targetedSpellcasting: "DS4.SpellTypeTargetedSpellcasting", - }, - - spellCategories: { - healing: "DS4.SpellCategoryHealing", - fire: "DS4.SpellCategoryFire", - ice: "DS4.SpellCategoryIce", - light: "DS4.SpellCategoryLight", - darkness: "DS4.SpellCategoryDarkness", - mindAffecting: "DS4.SpellCategoryMindAffecting", - electricity: "DS4.SpellCategoryElectricity", - none: "DS4.SpellCategoryNone", - unset: "DS4.SpellCategoryUnset", - }, - - /** - * Define the set of actor types - */ - actorTypes: { - character: "DS4.ActorTypeCharacter", - creature: "DS4.ActorTypeCreature", - }, - - /** - * Define the set of attributes an actor has - */ - attributes: { - body: "DS4.AttributeBody", - mobility: "DS4.AttributeMobility", - mind: "DS4.AttributeMind", - }, - - /** - * Define the set of traits an actor has - */ - traits: { - strength: "DS4.TraitStrength", - agility: "DS4.TraitAgility", - intellect: "DS4.TraitIntellect", - constitution: "DS4.TraitConstitution", - dexterity: "DS4.TraitDexterity", - aura: "DS4.TraitAura", - }, - - /** - * Define the set of combat values an actor has - */ - combatValues: { - hitPoints: "DS4.CombatValuesHitPoints", - defense: "DS4.CombatValuesDefense", - initiative: "DS4.CombatValuesInitiative", - movement: "DS4.CombatValuesMovement", - meleeAttack: "DS4.CombatValuesMeleeAttack", - rangedAttack: "DS4.CombatValuesRangedAttack", - spellcasting: "DS4.CombatValuesSpellcasting", - targetedSpellcasting: "DS4.CombatValuesTargetedSpellcasting", - }, - - /** - * Define the base info of a character - */ - characterBaseInfo: { - race: "DS4.CharacterBaseInfoRace", - class: "DS4.CharacterBaseInfoClass", - heroClass: "DS4.CharacterBaseInfoHeroClass", - culture: "DS4.CharacterBaseInfoCulture", - }, - - /** - * Define the progression info of a character - */ - characterProgression: { - level: "DS4.CharacterProgressionLevel", - experiencePoints: "DS4.CharacterProgressionExperiencePoints", - talentPoints: "DS4.CharacterProgressionTalentPoints", - progressPoints: "DS4.CharacterProgressionProgressPoints", - }, - - /** - * Define the language info of a character - */ - characterLanguage: { - languages: "DS4.CharacterLanguageLanguages", - alphabets: "DS4.CharacterLanguageAlphabets", - }, - - /** - * Define the profile info of a character - */ - characterProfile: { - biography: "DS4.CharacterProfileBiography", - gender: "DS4.CharacterProfileGender", - birthday: "DS4.CharacterProfileBirthday", - birthplace: "DS4.CharacterProfileBirthplace", - age: "DS4.CharacterProfileAge", - height: "DS4.CharacterProfileHeight", - hairColor: "DS4.CharacterProfileHairColor", - weight: "DS4.CharacterProfileWeight", - eyeColor: "DS4.CharacterProfileEyeColor", - specialCharacteristics: "DS4.CharacterProfileSpecialCharacteristics", - }, - /** * Define the profile info types for handlebars of a character */ @@ -225,98 +330,4 @@ export const DS4 = { eyeColor: "String", specialCharacteristics: "String", }, - - /** - * Define currency elements of a character - */ - characterCurrency: { - gold: "DS4.CharacterCurrencyGold", - silver: "DS4.CharacterCurrencySilver", - copper: "DS4.CharacterCurrencyCopper", - }, - - /** - * Define the different creature types a creature can be - */ - creatureTypes: { - animal: "DS4.CreatureTypeAnimal", - construct: "DS4.CreatureTypeConstruct", - humanoid: "DS4.CreatureTypeHumanoid", - magicalEntity: "DS4.CreatureTypeMagicalEntity", - plantBeing: "DS4.CreatureTypePlantBeing", - undead: "DS4.CreatureTypeUndead", - }, - - /** - * Define the different size categories creatures fall into - */ - creatureSizeCategories: { - tiny: "DS4.CreatureSizeCategoryTiny", - small: "DS4.CreatureSizeCategorySmall", - normal: "DS4.CreatureSizeCategoryNormal", - large: "DS4.CreatureSizeCategoryLarge", - huge: "DS4.CreatureSizeCategoryHuge", - colossal: "DS4.CreatureSizeCategoryColossal", - }, - - /** - * Define the base info of a creature - */ - creatureBaseInfo: { - loot: "DS4.CreatureBaseInfoLoot", - foeFactor: "DS4.CreatureBaseInfoFoeFactor", - creatureType: "DS4.CreatureBaseInfoCreatureType", - sizeCategory: "DS4.CreatureBaseInfoSizeCategory", - experiencePoints: "DS4.CreatureBaseInfoExperiencePoints", - description: "DS4.CreatureBaseInfoDescription", - }, - - /** - * Define translations for available distance units - */ - distanceUnits: { - meter: "DS4.UnitMeters", - kilometer: "DS4.UnitKilometers", - custom: "DS4.UnitCustom", - }, - /** - * Define abbreviations for available distance units - */ - distanceUnitsAbbr: { - meter: "DS4.UnitMetersAbbr", - kilometer: "DS4.UnitKilometersAbbr", - custom: "DS4.UnitCustomAbbr", - }, - - /** - * Define translations for available distance units - */ - temporalUnits: { - rounds: "DS4.UnitRounds", - minutes: "DS4.UnitMinutes", - hours: "DS4.UnitHours", - days: "DS4.UnitDays", - custom: "DS4.UnitCustom", - }, - - /** - * Define abbreviations for available units - */ - temporalUnitsAbbr: { - rounds: "DS4.UnitRoundsAbbr", - minutes: "DS4.UnitMinutesAbbr", - hours: "DS4.UnitHoursAbbr", - days: "DS4.UnitDaysAbbr", - custom: "DS4.UnitCustomAbbr", - }, - - /** - * Define localization strings for Chat Visibility - */ - chatVisibilities: { - roll: "DS4.ChatVisibilityRoll", - gmroll: "DS4.ChatVisibilityGmRoll", - blindroll: "DS4.ChatVisibilityBlindRoll", - selfroll: "DS4.ChatVisibilitySelfRoll", - }, }; diff --git a/src/module/ds4.ts b/src/module/ds4.ts index 81115a4c..a2f6ff2f 100644 --- a/src/module/ds4.ts +++ b/src/module/ds4.ts @@ -29,8 +29,8 @@ Hooks.once("init", async function () { CONFIG.Item.entityClass = DS4Item as typeof Item; // Define localized type labels - CONFIG.Actor.typeLabels = DS4.actorTypes; - CONFIG.Item.typeLabels = DS4.itemTypes; + CONFIG.Actor.typeLabels = DS4.i18nKeys.actorTypes; + CONFIG.Item.typeLabels = DS4.i18nKeys.itemTypes; // Configure Dice CONFIG.Dice.types = [Die, DS4Check]; @@ -84,46 +84,16 @@ async function registerHandlebarsPartials() { * This function runs after game data has been requested and loaded from the servers, so entities exist */ Hooks.once("setup", function () { - // Localize CONFIG objects once up-front - const toLocalize = [ - "attackTypes", - "itemAvailabilities", - "itemTypes", - "armorTypes", - "armorTypesAbbr", - "armorMaterialTypes", - "armorMaterialTypesAbbr", - "armorMaterialTypes", - "spellTypes", - "spellCategories", - "attributes", - "traits", - "combatValues", - "characterBaseInfo", - "characterProgression", - "characterLanguage", - "characterProfile", - "characterCurrency", - "creatureTypes", - "creatureSizeCategories", - "creatureBaseInfo", - "temporalUnits", - "temporalUnitsAbbr", - "distanceUnits", - "distanceUnitsAbbr", - "chatVisibilities", - ]; - // Exclude some from sorting where the default order matters const noSort = ["attributes", "traits", "combatValues", "creatureSizeCategories"]; // Localize and sort CONFIG objects - for (const o of toLocalize) { - const localized = Object.entries(CONFIG.DS4[o]).map((e) => { + for (const o of Object.keys(CONFIG.DS4.i18nKeys)) { + const localized = Object.entries(CONFIG.DS4.i18nKeys[o]).map((e) => { return [e[0], game.i18n.localize(e[1] as string)]; }); if (!noSort.includes(o)) localized.sort((a, b) => a[1].localeCompare(b[1])); - CONFIG.DS4[o] = localized.reduce((obj, e) => { + CONFIG.DS4.i18n[o] = localized.reduce((obj, e) => { obj[e[0]] = e[1]; return obj; }, {}); diff --git a/src/module/item/item-data.ts b/src/module/item/item-data.ts index d7467f8a..63951e46 100644 --- a/src/module/item/item-data.ts +++ b/src/module/item/item-data.ts @@ -1,7 +1,7 @@ import { ModifiableData } from "../common/common-data"; import { DS4 } from "../config"; -export type ItemType = keyof typeof DS4.itemTypes; +export type ItemType = keyof typeof DS4.i18nKeys.itemTypes; export type DS4ItemDataType = | DS4Weapon diff --git a/src/templates/actor/character-sheet.hbs b/src/templates/actor/character-sheet.hbs index 0fb538f9..d63758e3 100644 --- a/src/templates/actor/character-sheet.hbs +++ b/src/templates/actor/character-sheet.hbs @@ -13,20 +13,20 @@
    + for="data.baseInfo.race">{{config.i18n.characterBaseInfo.race}}
    + for="data.baseInfo.culture">{{config.i18n.characterBaseInfo.culture}}
    + for="data.progression.progressPoints.used">{{config.i18n.characterProgression.progressPoints}}
    + for="data.progression.talentPoints.used">{{config.i18n.characterProgression.talentPoints}}
    + for="data.baseInfo.class">{{config.i18n.characterBaseInfo.class}}
    + for="data.baseInfo.heroClass">{{config.i18n.characterBaseInfo.heroClass}} diff --git a/src/templates/actor/creature-sheet.hbs b/src/templates/actor/creature-sheet.hbs index 7571eaba..424dbcc2 100644 --- a/src/templates/actor/creature-sheet.hbs +++ b/src/templates/actor/creature-sheet.hbs @@ -6,10 +6,10 @@

    - +
    + for="data.baseInfo.foeFactor">{{config.i18n.creatureBaseInfo.foeFactor}}
    - +
    diff --git a/src/templates/actor/partials/attributes-traits.hbs b/src/templates/actor/partials/attributes-traits.hbs index 14fece65..9c12a6ae 100644 --- a/src/templates/actor/partials/attributes-traits.hbs +++ b/src/templates/actor/partials/attributes-traits.hbs @@ -42,11 +42,11 @@ {{!-- ======================================================================== --}}
    - {{#each config.attributes as |attribute-label attribute-key|}} + {{#each config.i18n.attributes as |attribute-label attribute-key|}} {{> attribute attribute-label=attribute-label attribute-key=attribute-key attribute-data=(lookup ../data.attributes attribute-key)}} {{/each}} - {{#each config.traits as |trait-label trait-key|}} + {{#each config.i18n.traits as |trait-label trait-key|}} {{> trait trait-label=trait-label trait-key=trait-key trait-data=(lookup ../data.traits trait-key)}} {{/each}}
    diff --git a/src/templates/actor/partials/character-inventory.hbs b/src/templates/actor/partials/character-inventory.hbs index 19a4009d..b27fff63 100644 --- a/src/templates/actor/partials/character-inventory.hbs +++ b/src/templates/actor/partials/character-inventory.hbs @@ -4,13 +4,13 @@

    {{localize 'DS4.CharacterCurrency'}}

    1. - + - + - +
    2. diff --git a/src/templates/actor/partials/character-progression.hbs b/src/templates/actor/partials/character-progression.hbs index fd0a3932..e890a024 100644 --- a/src/templates/actor/partials/character-progression.hbs +++ b/src/templates/actor/partials/character-progression.hbs @@ -1,6 +1,6 @@
      -

      +

      + for="data.progression.experiencePoints">{{config.i18n.characterProgression.experiencePoints}}

      - {{#each config.combatValues as |combat-value-label combat-value-key|}} + {{#each config.i18n.combatValues as |combat-value-label combat-value-key|}} {{> combat-value combat-value-key=combat-value-key combat-value-data=(lookup ../data.combatValues combat-value-key)}} {{/each}} diff --git a/src/templates/actor/partials/items-overview.hbs b/src/templates/actor/partials/items-overview.hbs index 55b34411..f8ca7d8f 100644 --- a/src/templates/actor/partials/items-overview.hbs +++ b/src/templates/actor/partials/items-overview.hbs @@ -111,7 +111,7 @@ {{#> itemListEntry item=item}}
      + title="{{lookup ../../config.i18n.attackTypes item.data.data.attackType}}" width="24" height="24" />
      {{ item.data.data.weaponBonus}}
      {{ item.data.data.opponentDefense}}
      @@ -135,11 +135,11 @@ {{/itemListHeader}} {{#each itemsByType.armor as |item id|}} {{#> itemListEntry item=item }} -
      - {{lookup ../../config.armorMaterialTypesAbbr item.data.data.armorMaterialType}} +
      + {{lookup ../../config.i18n.armorMaterialTypesAbbr item.data.data.armorMaterialType}}
      -
      - {{lookup ../../config.armorTypesAbbr item.data.data.armorType}} +
      + {{lookup ../../config.i18n.armorTypesAbbr item.data.data.armorType}}
      {{ item.data.data.armorValue}}
      {{/itemListEntry}} diff --git a/src/templates/actor/partials/profile.hbs b/src/templates/actor/partials/profile.hbs index be95eeb5..2a520d8b 100644 --- a/src/templates/actor/partials/profile.hbs +++ b/src/templates/actor/partials/profile.hbs @@ -4,10 +4,10 @@ {{#if (ne profile-data-key 'biography')}}
      + data-dtype="{{lookup ../config.i18n.characterProfileDTypes profile-data-key}}" />
      {{/if}} {{/each}} diff --git a/src/templates/actor/partials/spells-overview.hbs b/src/templates/actor/partials/spells-overview.hbs index 8bcd33e3..f82237ff 100644 --- a/src/templates/actor/partials/spells-overview.hbs +++ b/src/templates/actor/partials/spells-overview.hbs @@ -23,11 +23,11 @@ !-- directly handing over the latter two. --}} {{#*inline "temporalUnit"}} -{{> unit unitNames=config.temporalUnits unitAbbrs=config.temporalUnitsAbbr unitDatum=unitDatum localizationString=localizationString}} +{{> unit unitNames=config.i18n.temporalUnits unitAbbrs=config.i18n.temporalUnitsAbbr unitDatum=unitDatum localizationString=localizationString}} {{/inline}} {{#*inline "distanceUnit"}} -{{> unit unitNames=config.distanceUnits unitAbbrs=config.distanceUnitsAbbr unitDatum=unitDatum localizationString=localizationString}} +{{> unit unitNames=config.i18n.distanceUnits unitAbbrs=config.i18n.distanceUnitsAbbr unitDatum=unitDatum localizationString=localizationString}} {{/inline}} @@ -72,7 +72,7 @@ {{!-- spell type --}}
      + title="{{lookup ../config.i18n.spellTypes item.data.data.spellType}}" width="24" height="24" />
      {{!-- spell bonus --}} {{localize "DS4.ArmorType"}} {{#select data.armorMaterialType}} - {{#each config.armorMaterialTypes as |value key|}} + {{#each config.i18n.armorMaterialTypes as |value key|}} {{/each}} {{/select}} diff --git a/src/templates/item/partials/details.hbs b/src/templates/item/partials/details.hbs index 0408641a..69f7526a 100644 --- a/src/templates/item/partials/details.hbs +++ b/src/templates/item/partials/details.hbs @@ -11,7 +11,7 @@ -

      {{localize (lookup config.itemTypes item.type)}}

      +

      {{lookup config.i18n.itemTypes item.type}}

      {{> @partial-block}}
      \ No newline at end of file diff --git a/src/templates/item/spell-sheet.hbs b/src/templates/item/spell-sheet.hbs index 4e180755..4fdd6dc1 100644 --- a/src/templates/item/spell-sheet.hbs +++ b/src/templates/item/spell-sheet.hbs @@ -12,9 +12,9 @@ @@ -33,7 +33,7 @@ {{#select data.spellCategory}} - {{#each config.spellCategories as |value key|}} + {{#each config.i18n.spellCategories as |value key|}} {{/each}} {{/select}} diff --git a/src/templates/item/weapon-sheet.hbs b/src/templates/item/weapon-sheet.hbs index b92bf97f..65005984 100644 --- a/src/templates/item/weapon-sheet.hbs +++ b/src/templates/item/weapon-sheet.hbs @@ -5,7 +5,7 @@ {{#each rollModes as |rollMode|}} - + {{/each}} From 62ab89f83bb4d951366c223b44a784635bd2b638 Mon Sep 17 00:00:00 2001 From: Gesina Schwalbe Date: Sun, 24 Jan 2021 17:56:32 +0100 Subject: [PATCH 12/53] moved icon mappings in CONFIG.DS4.icons --- src/module/config.ts | 29 +++++++++++-------- .../actor/partials/items-overview.hbs | 2 +- .../actor/partials/spells-overview.hbs | 2 +- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/module/config.ts b/src/module/config.ts index 5654c189..0f1bd1e0 100644 --- a/src/module/config.ts +++ b/src/module/config.ts @@ -299,20 +299,25 @@ export const DS4 = { }, /** - * Define the file paths to icon images + * A dictionary of dictionaries mapping keys to icon file paths. */ - attackTypesIcons: { - melee: "systems/ds4/assets/icons/official/combat-values/melee-attack.png", - meleeRanged: "systems/ds4/assets/icons/official/combat-values/melee-ranged-attack.png", - ranged: "systems/ds4/assets/icons/official/combat-values/ranged-attack.png", - }, + icons: { + /** + * Define the file paths to icon images + */ + attackTypes: { + melee: "systems/ds4/assets/icons/official/combat-values/melee-attack.png", + meleeRanged: "systems/ds4/assets/icons/official/combat-values/melee-ranged-attack.png", + ranged: "systems/ds4/assets/icons/official/combat-values/ranged-attack.png", + }, - /** - * Define the file paths to icon images - */ - spellTypesIcons: { - spellcasting: "systems/ds4/assets/icons/official/combat-values/spellcasting.png", - targetedSpellcasting: "systems/ds4/assets/icons/official/combat-values/targeted-spellcasting.png", + /** + * Define the file paths to icon images + */ + spellTypes: { + spellcasting: "systems/ds4/assets/icons/official/combat-values/spellcasting.png", + targetedSpellcasting: "systems/ds4/assets/icons/official/combat-values/targeted-spellcasting.png", + }, }, /** diff --git a/src/templates/actor/partials/items-overview.hbs b/src/templates/actor/partials/items-overview.hbs index f8ca7d8f..b7d5fbf7 100644 --- a/src/templates/actor/partials/items-overview.hbs +++ b/src/templates/actor/partials/items-overview.hbs @@ -110,7 +110,7 @@ {{#each itemsByType.weapon as |item id|}} {{#> itemListEntry item=item}}
      -
      {{ item.data.data.weaponBonus}}
      diff --git a/src/templates/actor/partials/spells-overview.hbs b/src/templates/actor/partials/spells-overview.hbs index f82237ff..819cb45a 100644 --- a/src/templates/actor/partials/spells-overview.hbs +++ b/src/templates/actor/partials/spells-overview.hbs @@ -71,7 +71,7 @@ data-property="name" title="{{localize 'DS4.ItemName'}}" /> {{!-- spell type --}}
      -
      {{!-- spell bonus --}} From 637af7c4d0ad7f1bd4a9406ac5f9a859d40b0535 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Mon, 25 Jan 2021 01:25:45 +0100 Subject: [PATCH 13/53] make DefaultCheckOptions --- src/module/rolls/check-factory.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/module/rolls/check-factory.ts b/src/module/rolls/check-factory.ts index 57e0ac56..44339b47 100644 --- a/src/module/rolls/check-factory.ts +++ b/src/module/rolls/check-factory.ts @@ -4,10 +4,10 @@ import { DS4 } from "../config"; * Provides default values for all arguments the `CheckFactory` expects. */ class DefaultCheckOptions implements DS4CheckFactoryOptions { - maxCritSuccess = 1; - minCritFailure = 20; - useSlayingDice = false; - rollMode: DS4RollMode = "roll"; + readonly maxCritSuccess = 1; + readonly minCritFailure = 20; + readonly useSlayingDice = false; + readonly rollMode: DS4RollMode = "roll"; mergeWith(other: Partial): DS4CheckFactoryOptions { return { ...this, ...other } as DS4CheckFactoryOptions; From f4f7c471ac880b12d90f2e28a9b213b0b17fc146 Mon Sep 17 00:00:00 2001 From: ghost Date: Mon, 25 Jan 2021 00:35:58 +0000 Subject: [PATCH 14/53] release version 0.2.1 --- package-lock.json | 2 +- package.json | 2 +- src/system.json | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 70e4ebaa..d04c3937 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "test", - "version": "0.2.0", + "version": "0.2.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 1ab23503..02fa5092 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "private": true, "name": "test", "description": "An implementation of the Dungeonslayers 4 game system for Foundry Virtual Tabletop.", - "version": "0.2.0", + "version": "0.2.1", "license": "MIT", "homepage": "https://git.f3l.de/dungeonslayers/ds4", "repository": { diff --git a/src/system.json b/src/system.json index badc3e57..369b033f 100644 --- a/src/system.json +++ b/src/system.json @@ -2,7 +2,7 @@ "name": "ds4", "title": "Dungeonslayers 4", "description": "The Dungeonslayers 4 system for FoundryVTT. Dungeonslayers (© Christian Kennig) is licensed under CC BY-NC-SA 3.0 (https://creativecommons.org/licenses/by-nc-sa/3.0/de/deed.en).", - "version": "0.2.0", + "version": "0.2.1", "minimumCoreVersion": "0.7.9", "compatibleCoreVersion": "0.7.9", "templateVersion": 2, @@ -43,7 +43,7 @@ "primaryTokenAttribute": "combatValues.hitPoints", "url": "https://git.f3l.de/dungeonslayers/ds4", "manifest": "https://git.f3l.de/dungeonslayers/ds4/-/raw/latest/src/system.json?inline=false", - "download": "https://git.f3l.de/dungeonslayers/ds4/-/jobs/artifacts/0.2.0/download?job=build", + "download": "https://git.f3l.de/dungeonslayers/ds4/-/jobs/artifacts/0.2.1/download?job=build", "license": "MIT", "initiative": "@combatValues.initiative.total" } From 21706b7e130f5a03343d42c165fa382f689ff91c Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Mon, 25 Jan 2021 14:16:14 +0100 Subject: [PATCH 15/53] fix spelling mistakes in README --- README.md | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index be9e3eb5..ea6aae88 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,8 @@ An implementation of the Dungeonslayers 4 game system for [Foundry Virtual Tabletop](http://foundryvtt.com). -This system provides character sheet support for Actors and Items and mechanical -support for dice and rules necessary to -play games of Dungeponslayers 4. +This system provides sheet support for Actors and Items and mechanical support +for dice and rules necessary to play games of Dungeonslayers 4. ## Installation @@ -17,7 +16,7 @@ https://git.f3l.de/dungeonslayers/ds4/-/raw/latest/src/system.json?inline=false ## Development -### Prerequisits +### Prerequisites In order to build this system, recent versions of `node` and `npm` are required. We recommend using the latest lts version of `node`, which is `v14.15.4` at the @@ -83,16 +82,18 @@ npm test ## Contributing Code and content contributions are accepted. Please feel free to submit issues -to the issue tracker or submit merge requests for code changes. To create an issue send a mail to [git+dungeonslayers-ds4-155-issue-@git.f3l.de](mailto:git+dungeonslayers-ds4-155-issue-@git.f3l.de). +to the issue tracker or submit merge requests for code changes. To create an +issue, send a mail to [git+dungeonslayers-ds4-155-issue-@git.f3l.de](mailto:git+dungeonslayers-ds4-155-issue-@git.f3l.de). ## Licensing -[Dungeonslayers](http://dungeonslayers.de/) (© Christian Kennig) is licensed under [CC BY-NC-SA 3.0](https://creativecommons.org/licenses/by-nc-sa/3.0/de/deed.en). +[Dungeonslayers](http://dungeonslayers.de/) (© Christian Kennig) is licensed +under [CC BY-NC-SA 3.0](https://creativecommons.org/licenses/by-nc-sa/3.0/de/deed.en). -The icons in [src/assets/icons/official](src/assets/icons/official) are slightly modifed -versions of original Dungeonslayers icons, which have also been published under -CC BY-NC-SA 3.0. Hence the modified icons are also published under this -license. A copy of this license can be found under +The icons in [src/assets/icons/official](src/assets/icons/official) are slightly +modified versions of original Dungeonslayers icons, which have also been +published under CC BY-NC-SA 3.0. Hence the modified icons are also published +under this license. A copy of this license can be found under [src/assets/icons/official/LICENSE](src/assets/icons/official/LICENSE). Similarly, the compendium packs found in [src/packs](src/packs) are based on From 62cc5a0e7ce86a0c1d18aa2dd0ddb320e51bd222 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Tue, 26 Jan 2021 03:55:18 +0100 Subject: [PATCH 16/53] switch to foundry-vtt-types --- package-lock.json | 570 ++++++++++++++++++++- package.json | 4 +- src/module/actor/actor-data.ts | 5 +- src/module/actor/actor.ts | 8 +- src/module/actor/sheets/actor-sheet.ts | 46 +- src/module/actor/sheets/character-sheet.ts | 24 +- src/module/actor/sheets/creature-sheet.ts | 24 +- src/module/ds4.ts | 2 +- src/module/item/item-data.ts | 4 +- src/module/item/item-sheet.ts | 34 +- src/module/item/item.ts | 6 +- src/module/rolls/check-factory.ts | 65 ++- tsconfig.json | 5 +- 13 files changed, 713 insertions(+), 84 deletions(-) diff --git a/package-lock.json b/package-lock.json index d04c3937..c647856a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -110,6 +110,383 @@ "fastq": "^1.6.0" } }, + "@pixi/accessibility": { + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/@pixi/accessibility/-/accessibility-5.3.4.tgz", + "integrity": "sha512-g8hQnnVSYJ+gLrdQyCsDDSu+VehhVL9Pcr2fkQSC9VBhxiMIN+Paky8kOxC2LL5nsKRIUGGaTa6iHtiopPQQMw==", + "dev": true, + "requires": { + "@pixi/core": "5.3.4", + "@pixi/display": "5.3.4", + "@pixi/utils": "5.3.4" + } + }, + "@pixi/app": { + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/@pixi/app/-/app-5.3.4.tgz", + "integrity": "sha512-XT/EFyGslFdvdHY9ZS7yDAdLOj0U1UHeLxFr1kwiawuwIt/WsxNeH4jq2IijvZuQ3L5ON7Y7zQf54JEPv5fK0Q==", + "dev": true, + "requires": { + "@pixi/core": "5.3.4", + "@pixi/display": "5.3.4" + } + }, + "@pixi/constants": { + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/@pixi/constants/-/constants-5.3.4.tgz", + "integrity": "sha512-YsWjdMVMoJA8kG/0D4s9/DWWa2lPlexk0qNZOcV3tICaPG0IYfIhepfveMeMhIb0QrdSAsPbhYdcaxxgoaNF1A==", + "dev": true + }, + "@pixi/core": { + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/@pixi/core/-/core-5.3.4.tgz", + "integrity": "sha512-k6SRniy4pH7ZKAKC2HkbLSKPm+j7bF17fTO5+6xLSiVqLnfa7ChV51wNuoa30olVF3/d8ME2uraf7dsvXwomzw==", + "dev": true, + "requires": { + "@pixi/constants": "5.3.4", + "@pixi/math": "5.3.4", + "@pixi/runner": "5.3.4", + "@pixi/settings": "5.3.4", + "@pixi/ticker": "5.3.4", + "@pixi/utils": "5.3.4" + } + }, + "@pixi/display": { + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/@pixi/display/-/display-5.3.4.tgz", + "integrity": "sha512-RCi39Qi1L8mlIu1YvWvPI45WpKHRbpYlvSIT/414wmoaAoFZnaJ+qoVuqDCfzfNhWWirGAWpXniQjNRzkUZjcA==", + "dev": true, + "requires": { + "@pixi/math": "5.3.4", + "@pixi/settings": "5.3.4", + "@pixi/utils": "5.3.4" + } + }, + "@pixi/extract": { + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/@pixi/extract/-/extract-5.3.4.tgz", + "integrity": "sha512-HTGF5WKts4kF0v1rOU4YcLMUpb18FzcxKhaCwjXpqm3vANgjuGAUL9PxpmC4ecS03mkRa0+9vAXEUkJLQeNLPg==", + "dev": true, + "requires": { + "@pixi/core": "5.3.4", + "@pixi/math": "5.3.4", + "@pixi/utils": "5.3.4" + } + }, + "@pixi/filter-alpha": { + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/@pixi/filter-alpha/-/filter-alpha-5.3.4.tgz", + "integrity": "sha512-lgRCN8bDeHlMpRtQv/P5gCJ+9e3AufJVC2H0TdkCRmJqm1dB+rhKwxIeNINsjjz+kiuumOe88CxRbRd3CpEydg==", + "dev": true, + "requires": { + "@pixi/core": "5.3.4" + } + }, + "@pixi/filter-blur": { + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/@pixi/filter-blur/-/filter-blur-5.3.4.tgz", + "integrity": "sha512-PYPHc8MEsZWfmVQkm0UKO70dmZpcWyu/Bs0xJa5apsmCm6zXNzXfMh02lsXu82HrNQ+9iJT/mAKrrDABGn9vtg==", + "dev": true, + "requires": { + "@pixi/core": "5.3.4", + "@pixi/settings": "5.3.4" + } + }, + "@pixi/filter-color-matrix": { + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/@pixi/filter-color-matrix/-/filter-color-matrix-5.3.4.tgz", + "integrity": "sha512-9Iflvr1moc7ns5A/73lWVwLUbe+wb678NLA4X9SYXAJTiij4M1isDrULhk95TGUaWo4bbSBaov1vm8XbUZNG8w==", + "dev": true, + "requires": { + "@pixi/core": "5.3.4" + } + }, + "@pixi/filter-displacement": { + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/@pixi/filter-displacement/-/filter-displacement-5.3.4.tgz", + "integrity": "sha512-CldemXpcKr1GRT1Ll33TTFWtU6KDl4sYTvAwWTAEu8OhKedobBB/mRCIK9p1h7iZYtaj5MRYQjewmFKRrqyXrQ==", + "dev": true, + "requires": { + "@pixi/core": "5.3.4", + "@pixi/math": "5.3.4" + } + }, + "@pixi/filter-fxaa": { + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/@pixi/filter-fxaa/-/filter-fxaa-5.3.4.tgz", + "integrity": "sha512-GtIfaOsqQlsK+F1795V/JJIq5Uu15nasiCwGr+wVwHNGMBanAXt7AnSy8JHcgup3Eqx8FXRuM/AyD/4IYUquuA==", + "dev": true, + "requires": { + "@pixi/core": "5.3.4" + } + }, + "@pixi/filter-noise": { + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/@pixi/filter-noise/-/filter-noise-5.3.4.tgz", + "integrity": "sha512-pNq4T4LC2naWz0pZXF3RT9aA7XdLL4TuBjJsYrrBaJZraupbOo6Mp8VwxVJs8GThmMl7/U13GalOzVSb/HjzDg==", + "dev": true, + "requires": { + "@pixi/core": "5.3.4" + } + }, + "@pixi/graphics": { + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/@pixi/graphics/-/graphics-5.3.4.tgz", + "integrity": "sha512-W6cuFfzwgfx3zVFICu98cENgwjy+d2e6xNJ/yJI0q8QiwlZmpuSXHBCfZrtIWpp9VSJZe2KDIo1LUnLhCpp3Yg==", + "dev": true, + "requires": { + "@pixi/constants": "5.3.4", + "@pixi/core": "5.3.4", + "@pixi/display": "5.3.4", + "@pixi/math": "5.3.4", + "@pixi/sprite": "5.3.4", + "@pixi/utils": "5.3.4" + } + }, + "@pixi/interaction": { + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/@pixi/interaction/-/interaction-5.3.4.tgz", + "integrity": "sha512-7/JN7AtCuYmmWczrQROKSI9Z42p6C6p7B2wDVqNYYgROSaeGbGsZ8H0sa6nYLnIj4F3CaGSRoRnAMPz+CO70bw==", + "dev": true, + "requires": { + "@pixi/core": "5.3.4", + "@pixi/display": "5.3.4", + "@pixi/math": "5.3.4", + "@pixi/ticker": "5.3.4", + "@pixi/utils": "5.3.4" + } + }, + "@pixi/loaders": { + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/@pixi/loaders/-/loaders-5.3.4.tgz", + "integrity": "sha512-/dFznZnsivzq/MW7n/PPhMeznWFMMDYrac958OlxzSwrEAgtq6ZVLZbz7pCf9uhiifMnqwBGefphOFubj3Qorw==", + "dev": true, + "requires": { + "@pixi/core": "5.3.4", + "@pixi/utils": "5.3.4", + "resource-loader": "^3.0.1" + } + }, + "@pixi/math": { + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/@pixi/math/-/math-5.3.4.tgz", + "integrity": "sha512-UQ2jhdlCHIvAVf8EcHB3QuR5GhB49VdTccWmer96RZCeGkcZsPSUk1ldO1GZnIctcf0Iuvmq74G02dYbtC7JxQ==", + "dev": true + }, + "@pixi/mesh": { + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/@pixi/mesh/-/mesh-5.3.4.tgz", + "integrity": "sha512-y0Y52cwsqETc/35DMGVCzQmhPCrQ3ZhjWcW9JwQoHMy3PoNSN9QUqYjVjF2oEj5hxcJnGNo3GAXFZz2Uh/UReQ==", + "dev": true, + "requires": { + "@pixi/constants": "5.3.4", + "@pixi/core": "5.3.4", + "@pixi/display": "5.3.4", + "@pixi/math": "5.3.4", + "@pixi/settings": "5.3.4", + "@pixi/utils": "5.3.4" + } + }, + "@pixi/mesh-extras": { + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/@pixi/mesh-extras/-/mesh-extras-5.3.4.tgz", + "integrity": "sha512-mjc3RlgLGYUv2FUKrVv/Dfaj2KW5qhX9c6Ev+yJ4lg/sMblet5gtYuyKsmJMS/K6B8V8+oMlTfX9ozFCzq1oJQ==", + "dev": true, + "requires": { + "@pixi/constants": "5.3.4", + "@pixi/core": "5.3.4", + "@pixi/math": "5.3.4", + "@pixi/mesh": "5.3.4", + "@pixi/utils": "5.3.4" + } + }, + "@pixi/mixin-cache-as-bitmap": { + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/@pixi/mixin-cache-as-bitmap/-/mixin-cache-as-bitmap-5.3.4.tgz", + "integrity": "sha512-8ZAmzDK1fHXIzYFHFH72LUMRZerY1Pt71XI3UgsWExABS1aREe20oPLuVByLP94W7X/kTXz+zK+nt51O5MGKsA==", + "dev": true, + "requires": { + "@pixi/core": "5.3.4", + "@pixi/display": "5.3.4", + "@pixi/math": "5.3.4", + "@pixi/settings": "5.3.4", + "@pixi/sprite": "5.3.4", + "@pixi/utils": "5.3.4" + } + }, + "@pixi/mixin-get-child-by-name": { + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/@pixi/mixin-get-child-by-name/-/mixin-get-child-by-name-5.3.4.tgz", + "integrity": "sha512-PY1Qe6CKYu+UNSRAFIfRyhRfkrpsTMwh9sI6iXVVi712bM3JkZIwDfDF31TA4nYX8z7H49w+KCWY4PejZ8l2WA==", + "dev": true, + "requires": { + "@pixi/display": "5.3.4" + } + }, + "@pixi/mixin-get-global-position": { + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/@pixi/mixin-get-global-position/-/mixin-get-global-position-5.3.4.tgz", + "integrity": "sha512-yv+huwUAOfyXDEHbQp6W5/3RjQpwG6AhpgMY4b3XBMtvrp9R/5Wgw/YC/nea9kZ3Gb2u4Aqeco8U+tPIRNjeIA==", + "dev": true, + "requires": { + "@pixi/display": "5.3.4", + "@pixi/math": "5.3.4" + } + }, + "@pixi/particles": { + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/@pixi/particles/-/particles-5.3.4.tgz", + "integrity": "sha512-sX0BGGbS7yCwlam1mC5awW2BjU7QFmZv82E8ON/r9aAZS6InT25zOpMdvy0ImIIqBvF0Z1Qz1IT6pKEBxqMo9Q==", + "dev": true, + "requires": { + "@pixi/constants": "5.3.4", + "@pixi/core": "5.3.4", + "@pixi/display": "5.3.4", + "@pixi/math": "5.3.4", + "@pixi/utils": "5.3.4" + } + }, + "@pixi/polyfill": { + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/@pixi/polyfill/-/polyfill-5.3.4.tgz", + "integrity": "sha512-bxk8bhrfQ9Y2rU/L0ss2gIeXwmMlOciw+B5yVUDVLqzjE4y8Fm2619L4qu9v51Z9a+8JbyVE5c1eT7HJgx0g0w==", + "dev": true, + "requires": { + "es6-promise-polyfill": "^1.2.0", + "object-assign": "^4.1.1" + } + }, + "@pixi/prepare": { + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/@pixi/prepare/-/prepare-5.3.4.tgz", + "integrity": "sha512-MVMvNTrNYQidWXd4LSkgv+eqTzHtSViADA+Tvnemy9QMuWqbTfxFn4UMhrBjQIfG9+hwdIFS14pfFKt/BLHNrw==", + "dev": true, + "requires": { + "@pixi/core": "5.3.4", + "@pixi/display": "5.3.4", + "@pixi/graphics": "5.3.4", + "@pixi/settings": "5.3.4", + "@pixi/text": "5.3.4", + "@pixi/ticker": "5.3.4" + } + }, + "@pixi/runner": { + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/@pixi/runner/-/runner-5.3.4.tgz", + "integrity": "sha512-iPWHVhv2js+NhDQNmePkHfic8SilBT7H/pzRjMqHqvafTdl8Y+4g+hdQDalZJNr3Ixl77QPAYlOKhegBujn2mQ==", + "dev": true + }, + "@pixi/settings": { + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/@pixi/settings/-/settings-5.3.4.tgz", + "integrity": "sha512-Jqj1NLtYODCqK8ZKVccUBAaBDkn7SQ6b7N15FwxbiSgfbvwpynSKr6WQTxqMq29h42MKsic6BJcQrlGEbDNz5w==", + "dev": true, + "requires": { + "ismobilejs": "^1.1.0" + } + }, + "@pixi/sprite": { + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/@pixi/sprite/-/sprite-5.3.4.tgz", + "integrity": "sha512-vO+GMJWnumnVzc2R7jGcLlUeIXIek+SDqVQyPDPJ5T8sWTgFhanHCrgpKfplZIu08X/zvIZQxPfd332R0waeog==", + "dev": true, + "requires": { + "@pixi/constants": "5.3.4", + "@pixi/core": "5.3.4", + "@pixi/display": "5.3.4", + "@pixi/math": "5.3.4", + "@pixi/settings": "5.3.4", + "@pixi/utils": "5.3.4" + } + }, + "@pixi/sprite-animated": { + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/@pixi/sprite-animated/-/sprite-animated-5.3.4.tgz", + "integrity": "sha512-HaTelbvm2xekw9b9GdYbupM2RZ/muRZvstkmSqMZhiIViZekzKPa5WQJwnqZzVBjCg735j09G8aF4H2NpNqF9g==", + "dev": true, + "requires": { + "@pixi/core": "5.3.4", + "@pixi/sprite": "5.3.4", + "@pixi/ticker": "5.3.4" + } + }, + "@pixi/sprite-tiling": { + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/@pixi/sprite-tiling/-/sprite-tiling-5.3.4.tgz", + "integrity": "sha512-NMqpNuWEIic2n5EL/TrGmn1+bab4TwxcILnco4myvw9Sd/wLsaJx3XboegY7YCWCKhnl+Ax6cl8DMkk7OJkpJQ==", + "dev": true, + "requires": { + "@pixi/constants": "5.3.4", + "@pixi/core": "5.3.4", + "@pixi/display": "5.3.4", + "@pixi/math": "5.3.4", + "@pixi/sprite": "5.3.4", + "@pixi/utils": "5.3.4" + } + }, + "@pixi/spritesheet": { + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/@pixi/spritesheet/-/spritesheet-5.3.4.tgz", + "integrity": "sha512-gfCqOMD2XJHw1bMXxXbuYPnBbCBUvbzMN7Pw2po7U5R6bsk7WEoG7Hp3HjAPyPQvg36v2Db6dcz0//ZNNqm+EQ==", + "dev": true, + "requires": { + "@pixi/core": "5.3.4", + "@pixi/loaders": "5.3.4", + "@pixi/math": "5.3.4", + "@pixi/utils": "5.3.4" + } + }, + "@pixi/text": { + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/@pixi/text/-/text-5.3.4.tgz", + "integrity": "sha512-kmdK1KLrWY8PHGIIXKVRQmik3gWquiYz6DB0jqabi3j0gVp6h+CVDje01N6Nl75ZCQ/PjaWafzQvURypfX73ng==", + "dev": true, + "requires": { + "@pixi/core": "5.3.4", + "@pixi/math": "5.3.4", + "@pixi/settings": "5.3.4", + "@pixi/sprite": "5.3.4", + "@pixi/utils": "5.3.4" + } + }, + "@pixi/text-bitmap": { + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/@pixi/text-bitmap/-/text-bitmap-5.3.4.tgz", + "integrity": "sha512-uNJOYvy3sn0S5Bp6H113ZAmaQm68ojCXSuOBJzIMEV2cUuYLngW+7DqKOsHMMhNmcONs/OBq57SRrzDcr8WYdw==", + "dev": true, + "requires": { + "@pixi/core": "5.3.4", + "@pixi/display": "5.3.4", + "@pixi/loaders": "5.3.4", + "@pixi/math": "5.3.4", + "@pixi/mesh": "5.3.4", + "@pixi/settings": "5.3.4", + "@pixi/text": "5.3.4", + "@pixi/utils": "5.3.4" + } + }, + "@pixi/ticker": { + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/@pixi/ticker/-/ticker-5.3.4.tgz", + "integrity": "sha512-PmCAstgyI6vLPXKZVFlo4Zornry21BwFiTOp1dBUW3sIMky9Wx2fajjyVHIridCY6yaazt6Xu37khZf5qRgASw==", + "dev": true, + "requires": { + "@pixi/settings": "5.3.4" + } + }, + "@pixi/utils": { + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/@pixi/utils/-/utils-5.3.4.tgz", + "integrity": "sha512-HjUWFfAmPPKX0BSq20GWY//Vm+gC9O+wcn9sXMqOItCuf0DDFwxoBrUVaHNNnEVhM1Djpz/+YijCijmGdZeddA==", + "dev": true, + "requires": { + "@pixi/constants": "5.3.4", + "@pixi/settings": "5.3.4", + "earcut": "^2.1.5", + "eventemitter3": "^3.1.0", + "url": "^0.11.0" + } + }, "@types/fs-extra": { "version": "9.0.6", "resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-9.0.6.tgz", @@ -119,6 +496,12 @@ "@types/node": "*" } }, + "@types/howler": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/@types/howler/-/howler-2.2.1.tgz", + "integrity": "sha512-1MiSldngr+eAO4lDPtjzl4Nf2GmRh8VDHIpNBIkyd25L22JExVlI6w3fjSM7+FNc1e1WZAPNq7/flkw685byfg==", + "dev": true + }, "@types/jasmine": { "version": "3.6.2", "resolved": "https://registry.npmjs.org/@types/jasmine/-/jasmine-3.6.2.tgz", @@ -126,9 +509,9 @@ "dev": true }, "@types/jquery": { - "version": "3.5.5", - "resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-3.5.5.tgz", - "integrity": "sha512-6RXU9Xzpc6vxNrS6FPPapN1SxSHgQ336WC6Jj/N8q30OiaBZ00l1GBgeP7usjVZPivSkGUfL1z/WW6TX989M+w==", + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-3.5.1.tgz", + "integrity": "sha512-Tyctjh56U7eX2b9udu3wG853ASYP0uagChJcQJXLUXEU6C/JiW5qt5dl8ao01VRj1i5pgXPAf8f1mq4+FDLRQg==", "dev": true, "requires": { "@types/sizzle": "*" @@ -1821,6 +2204,12 @@ "object.defaults": "^1.1.0" } }, + "earcut": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/earcut/-/earcut-2.2.2.tgz", + "integrity": "sha512-eZoZPPJcUHnfRZ0PjLvx2qBordSiO8ofC3vt+qACLM95u+4DovnbYNpQtJh0DNsWj8RnxrQytD4WA8gj5cRIaQ==", + "dev": true + }, "ecc-jsbn": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", @@ -1935,6 +2324,12 @@ "es6-symbol": "^3.1.1" } }, + "es6-promise-polyfill": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/es6-promise-polyfill/-/es6-promise-polyfill-1.2.0.tgz", + "integrity": "sha1-84kl8jyz4+jObNqP93T867sJDN4=", + "dev": true + }, "es6-symbol": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz", @@ -2224,6 +2619,12 @@ "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", "dev": true }, + "eventemitter3": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-3.1.2.tgz", + "integrity": "sha512-tvtQIeLVHjDkJYnzf2dgVMxfuSGJeM/7UCG17TT4EumTfNtF+0nebF/4zWOIkCreAbtNqhGEboB6BWrwqNaw4Q==", + "dev": true + }, "execa": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/execa/-/execa-4.1.0.tgz", @@ -2717,14 +3118,27 @@ "mime-types": "^2.1.12" } }, - "foundry-pc-types": { - "version": "git+https://git.f3l.de/dungeonslayers/foundry-pc-types.git#ac45653fdec5fb935bf7db72889cb40cd6b80b20", - "from": "git+https://git.f3l.de/dungeonslayers/foundry-pc-types.git#f3l-fixes", + "foundry-vtt-types": { + "version": "github:kmoschcau/foundry-vtt-types#21f009f10de74856556ceadf71fb436089c663cc", + "from": "github:kmoschcau/foundry-vtt-types#foundry-0.7.9", "dev": true, "requires": { - "@types/jquery": "^3.5.1", + "@types/howler": "2.2.1", + "@types/jquery": "3.5.1", + "@types/node": "^14.14.21", "@types/socket.io-client": "^1.4.33", - "@types/tinymce": "^4.5.24" + "@types/tinymce": "^4.5.24", + "handlebars": "4.7.6", + "pixi.js": "5.3.4", + "utility-types": "^3.10.0" + }, + "dependencies": { + "@types/node": { + "version": "14.14.22", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.22.tgz", + "integrity": "sha512-g+f/qj/cNcqKkc3tFqlXOYjrmZA+jNBiDzbP3kH+B+otKFqAdPgVTGP1IeKRdMml/aE69as5S4FqtxAbl+LaMw==", + "dev": true + } } }, "fragment-cache": { @@ -3277,6 +3691,40 @@ "glogg": "^1.0.0" } }, + "handlebars": { + "version": "4.7.6", + "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.6.tgz", + "integrity": "sha512-1f2BACcBfiwAfStCKZNrUCgqNZkGsAT7UM3kkYtXuLo0KnaVfjKOyf7PRzB6++aK9STyT1Pd2ZCPe3EGOXleXA==", + "dev": true, + "requires": { + "minimist": "^1.2.5", + "neo-async": "^2.6.0", + "source-map": "^0.6.1", + "uglify-js": "^3.1.4", + "wordwrap": "^1.0.0" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + }, + "uglify-js": { + "version": "3.12.5", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.12.5.tgz", + "integrity": "sha512-SgpgScL4T7Hj/w/GexjnBHi3Ien9WS1Rpfg5y91WXMj9SY997ZCQU76mH4TpLwwfmMvoOU8wiaRkIf6NaH3mtg==", + "dev": true, + "optional": true + }, + "wordwrap": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", + "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", + "dev": true + } + } + }, "har-schema": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", @@ -3776,6 +4224,12 @@ "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", "dev": true }, + "ismobilejs": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ismobilejs/-/ismobilejs-1.1.1.tgz", + "integrity": "sha512-VaFW53yt8QO61k2WJui0dHf4SlL8lxBofUuUmwBo0ljPk0Drz2TiuDW4jo3wDcv41qy/SxrJ+VAzJ/qYqsmzRw==", + "dev": true + }, "isobject": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", @@ -4551,6 +5005,12 @@ "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", "dev": true }, + "mini-signals": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/mini-signals/-/mini-signals-1.2.0.tgz", + "integrity": "sha1-RbCAE8X65RokqhqTXNMXye1yHXQ=", + "dev": true + }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", @@ -4646,6 +5106,12 @@ "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", "dev": true }, + "neo-async": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz", + "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==", + "dev": true + }, "next-tick": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz", @@ -5072,6 +5538,12 @@ "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=", "dev": true }, + "parse-uri": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/parse-uri/-/parse-uri-1.0.3.tgz", + "integrity": "sha512-upMnGxNcm+45So85HoguwZTVZI9u11i36DdxJfGF2HYWS2eh3TIx7+/tTi7qrEq15qzGkVhsKjesau+kCk48pA==", + "dev": true + }, "pascalcase": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", @@ -5170,6 +5642,48 @@ "pinkie": "^2.0.0" } }, + "pixi.js": { + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/pixi.js/-/pixi.js-5.3.4.tgz", + "integrity": "sha512-CrAaQQRw+iTA75IEu57CEk6stFs587iWE3HwQG0rZL2ESW2uJvdsF/ieeS/hFk35QmlEsPRqmH1sf7t7FGtsyw==", + "dev": true, + "requires": { + "@pixi/accessibility": "5.3.4", + "@pixi/app": "5.3.4", + "@pixi/constants": "5.3.4", + "@pixi/core": "5.3.4", + "@pixi/display": "5.3.4", + "@pixi/extract": "5.3.4", + "@pixi/filter-alpha": "5.3.4", + "@pixi/filter-blur": "5.3.4", + "@pixi/filter-color-matrix": "5.3.4", + "@pixi/filter-displacement": "5.3.4", + "@pixi/filter-fxaa": "5.3.4", + "@pixi/filter-noise": "5.3.4", + "@pixi/graphics": "5.3.4", + "@pixi/interaction": "5.3.4", + "@pixi/loaders": "5.3.4", + "@pixi/math": "5.3.4", + "@pixi/mesh": "5.3.4", + "@pixi/mesh-extras": "5.3.4", + "@pixi/mixin-cache-as-bitmap": "5.3.4", + "@pixi/mixin-get-child-by-name": "5.3.4", + "@pixi/mixin-get-global-position": "5.3.4", + "@pixi/particles": "5.3.4", + "@pixi/polyfill": "5.3.4", + "@pixi/prepare": "5.3.4", + "@pixi/runner": "5.3.4", + "@pixi/settings": "5.3.4", + "@pixi/sprite": "5.3.4", + "@pixi/sprite-animated": "5.3.4", + "@pixi/sprite-tiling": "5.3.4", + "@pixi/spritesheet": "5.3.4", + "@pixi/text": "5.3.4", + "@pixi/text-bitmap": "5.3.4", + "@pixi/ticker": "5.3.4", + "@pixi/utils": "5.3.4" + } + }, "pkg-dir": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-5.0.0.tgz", @@ -5348,6 +5862,12 @@ "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==", "dev": true }, + "querystring": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", + "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=", + "dev": true + }, "read-pkg": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz", @@ -5596,6 +6116,16 @@ "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", "dev": true }, + "resource-loader": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/resource-loader/-/resource-loader-3.0.1.tgz", + "integrity": "sha512-fBuCRbEHdLCI1eglzQhUv9Rrdcmqkydr1r6uHE2cYHvRBrcLXeSmbE/qI/urFt8rPr/IGxir3BUwM5kUK8XoyA==", + "dev": true, + "requires": { + "mini-signals": "^1.2.0", + "parse-uri": "^1.0.0" + } + }, "restore-cursor": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz", @@ -6891,6 +7421,24 @@ "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=", "dev": true }, + "url": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/url/-/url-0.11.0.tgz", + "integrity": "sha1-ODjpfPxgUh63PFJajlW/3Z4uKPE=", + "dev": true, + "requires": { + "punycode": "1.3.2", + "querystring": "0.2.0" + }, + "dependencies": { + "punycode": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", + "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=", + "dev": true + } + } + }, "use": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", @@ -6903,6 +7451,12 @@ "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "dev": true }, + "utility-types": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/utility-types/-/utility-types-3.10.0.tgz", + "integrity": "sha512-O11mqxmi7wMKCo6HKFt5AhO4BwY3VV68YU07tgxfz8zJTIxr4BpsezN49Ffwy9j3ZpwwJp4fkRwjRzq3uWE6Rg==", + "dev": true + }, "uuid": { "version": "3.4.0", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", diff --git a/package.json b/package.json index 02fa5092..274641bf 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "build:watch": "gulp watch", "link": "gulp link", "clean": "gulp clean && gulp link --clean", - "update": "npm install --save-dev git+https://git.f3l.de/dungeonslayers/foundry-pc-types.git#f3l-fixes", + "update": "npm install --save-dev github:kmoschcau/foundry-vtt-types#foundry-0.7.9", "updateManifest": "gulp updateManifest", "lint": "eslint 'src/**/*.ts' --cache", "lint:fix": "eslint 'src/**/*.ts' --cache --fix", @@ -53,7 +53,7 @@ "eslint": "^7.18.0", "eslint-config-prettier": "^7.1.0", "eslint-plugin-prettier": "^3.3.1", - "foundry-pc-types": "git+https://git.f3l.de/dungeonslayers/foundry-pc-types.git#f3l-fixes", + "foundry-vtt-types": "github:kmoschcau/foundry-vtt-types#foundry-0.7.9", "fs-extra": "^9.0.1", "gulp": "^4.0.2", "gulp-git": "^2.10.1", diff --git a/src/module/actor/actor-data.ts b/src/module/actor/actor-data.ts index dba57d9f..c45a0cb2 100644 --- a/src/module/actor/actor-data.ts +++ b/src/module/actor/actor-data.ts @@ -1,6 +1,9 @@ import { ModifiableData, ResourceData, UsableResource } from "../common/common-data"; +import { DS4ItemData } from "../item/item-data"; -export type DS4ActorDataType = DS4ActorDataCharacter | DS4ActorDataCreature; +export type DS4ActorData = Actor.Data; + +type DS4ActorDataType = DS4ActorDataCharacter | DS4ActorDataCreature; interface DS4ActorDataBase { attributes: DS4ActorDataAttributes; diff --git a/src/module/actor/actor.ts b/src/module/actor/actor.ts index 270fee10..702a70fb 100644 --- a/src/module/actor/actor.ts +++ b/src/module/actor/actor.ts @@ -1,9 +1,9 @@ import { ModifiableData } from "../common/common-data"; import { DS4Item } from "../item/item"; -import { DS4Armor, DS4ItemDataType, DS4Shield, ItemType } from "../item/item-data"; -import { DS4ActorDataType } from "./actor-data"; +import { DS4Armor, DS4Shield, ItemType } from "../item/item-data"; +import { DS4ActorData } from "./actor-data"; -export class DS4Actor extends Actor { +export class DS4Actor extends Actor { /** @override */ prepareDerivedData(): void { const data = this.data; @@ -96,7 +96,7 @@ export class DS4Actor extends Actor * This only differs from the base implementation by also allowing negative values. * @override */ - async modifyTokenAttribute(attribute: string, value: number, isDelta = false, isBar = true): Promise { + async modifyTokenAttribute(attribute: string, value: number, isDelta = false, isBar = true): Promise { const current = getProperty(this.data.data, attribute); // Determine the updates to make to the actor data diff --git a/src/module/actor/sheets/actor-sheet.ts b/src/module/actor/sheets/actor-sheet.ts index 8565ca5c..e499b109 100644 --- a/src/module/actor/sheets/actor-sheet.ts +++ b/src/module/actor/sheets/actor-sheet.ts @@ -1,20 +1,39 @@ import { DS4Item } from "../../item/item"; -import { DS4ItemDataType, ItemType } from "../../item/item-data"; +import { DS4ItemData, ItemType } from "../../item/item-data"; import { DS4Actor } from "../actor"; -import { DS4ActorDataType } from "../actor-data"; /** * Extend the basic ActorSheet with some very simple modifications * @extends {ActorSheet} */ -export class DS4ActorSheet extends ActorSheet { +// TODO(types): provide proper types for all generic parameters +export class DS4ActorSheet extends ActorSheet { + // TODO(types): Improve mergeObject in upstream so that it isn't necessary to provide all parameters /** @override */ - static get defaultOptions(): FormApplicationOptions { - return mergeObject(super.defaultOptions, { + static get defaultOptions(): BaseEntitySheet.Options { + const superDefaultOptions = super.defaultOptions; + return mergeObject(superDefaultOptions, { classes: ["ds4", "sheet", "actor"], width: 745, height: 600, scrollY: [".sheet-body"], + template: superDefaultOptions.template, + viewPermission: superDefaultOptions.viewPermission, + closeOnSubmit: superDefaultOptions.closeOnSubmit, + submitOnChange: superDefaultOptions.submitOnChange, + submitOnClose: superDefaultOptions.submitOnClose, + editable: superDefaultOptions.editable, + baseApplication: superDefaultOptions.baseApplication, + top: superDefaultOptions.top, + left: superDefaultOptions.left, + popOut: superDefaultOptions.popOut, + minimizable: superDefaultOptions.minimizable, + resizable: superDefaultOptions.resizable, + id: superDefaultOptions.id, + dragDrop: superDefaultOptions.dragDrop, + filters: superDefaultOptions.filters, + title: superDefaultOptions.title, + tabs: superDefaultOptions.tabs, }); } @@ -32,7 +51,7 @@ export class DS4ActorSheet extends ActorSheet { + getData(): ActorSheet.Data { const data = { ...super.getData(), // Add the localization config to the data: @@ -82,13 +101,12 @@ export class DS4ActorSheet extends ActorSheet { + private _onItemCreate(event: JQuery.ClickEvent): Promise { event.preventDefault(); const header = event.currentTarget; // Get the type of item to create. - const type = header.dataset.type; // Grab any data associated with this control. - const data = duplicate(header.dataset); + const { type, ...data } = duplicate(header.dataset); // Initialize a default name. const name = `New ${type.capitalize()}`; // Prepare the item object. @@ -97,11 +115,9 @@ export class DS4ActorSheet extends ActorSheet, not an Item + const item = (duplicate(this.actor.getOwnedItem(id)) as unknown) as DS4ItemData; // TODO(types): Possible get better type definition for duplicate into upstream const property: string | undefined = $(ev.currentTarget).data("property"); // Early return: @@ -210,7 +226,7 @@ export class DS4ActorSheet extends ActorSheet[0]): Promise { - const item = await Item.fromDropData(data); + const item = ((await Item.fromDropData(data)) as unknown) as DS4Item; if (item && !this.actor.canOwnItemType(item.data.type as ItemType)) { ui.notifications.warn( game.i18n.format("DS4.WarningActorCannotOwnItem", { @@ -222,6 +238,6 @@ export class DS4ActorSheet extends ActorSheet; + +type DS4ItemDataType = | DS4Weapon | DS4Armor | DS4Shield diff --git a/src/module/item/item-sheet.ts b/src/module/item/item-sheet.ts index 6464defc..f974a76b 100644 --- a/src/module/item/item-sheet.ts +++ b/src/module/item/item-sheet.ts @@ -1,19 +1,37 @@ import { DS4Item } from "./item"; -import { DS4ItemDataType, isDS4ItemDataTypePhysical } from "./item-data"; +import { isDS4ItemDataTypePhysical } from "./item-data"; /** * Extend the basic ItemSheet with some very simple modifications * @extends {ItemSheet} */ -export class DS4ItemSheet extends ItemSheet { +// TODO(types): provide proper types for all generic parameters +export class DS4ItemSheet extends ItemSheet { /** @override */ - static get defaultOptions(): FormApplicationOptions { - return mergeObject(super.defaultOptions, { + static get defaultOptions(): BaseEntitySheet.Options { + const superDefaultOptions = super.defaultOptions; + return mergeObject(superDefaultOptions, { width: 530, height: 400, classes: ["ds4", "sheet", "item"], tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "description" }], scrollY: [".sheet-body"], + template: superDefaultOptions.template, + viewPermission: superDefaultOptions.viewPermission, + closeOnSubmit: superDefaultOptions.closeOnSubmit, + submitOnChange: superDefaultOptions.submitOnChange, + submitOnClose: superDefaultOptions.submitOnClose, + editable: superDefaultOptions.editable, + baseApplication: superDefaultOptions.baseApplication, + top: superDefaultOptions.top, + left: superDefaultOptions.left, + popOut: superDefaultOptions.popOut, + minimizable: superDefaultOptions.minimizable, + resizable: superDefaultOptions.resizable, + id: superDefaultOptions.id, + dragDrop: superDefaultOptions.dragDrop, + filters: superDefaultOptions.filters, + title: superDefaultOptions.title, }); } @@ -26,7 +44,7 @@ export class DS4ItemSheet extends ItemSheet { /* -------------------------------------------- */ /** @override */ - getData(): ItemSheetData { + getData(): ItemSheet.Data { const data = { ...super.getData(), config: CONFIG.DS4, @@ -41,11 +59,11 @@ export class DS4ItemSheet extends ItemSheet { /* -------------------------------------------- */ /** @override */ - setPosition(options: ApplicationPosition = {}): ApplicationPosition { + setPosition(options: Partial = {}): Application.Position { const position = super.setPosition(options); if ("find" in this.element) { const sheetBody = this.element.find(".sheet-body"); - const bodyHeight = position.height - 192; + const bodyHeight = (position.height as number) - 192; // TODO: remove type cast once https://github.com/kmoschcau/foundry-vtt-types/pull/214 is merged sheetBody.css("height", bodyHeight); } else { console.log("Failure setting position."); @@ -81,7 +99,7 @@ export class DS4ItemSheet extends ItemSheet { case "create": return this._createActiveEffect(); case "edit": - const effect = this.item.effects.get(li.data("effectId")); + const effect = this.item["effects"].get(li.data("effectId")); // TODO replace with item.effect once https://github.com/kmoschcau/foundry-vtt-types/pull/216 is merged return effect.sheet.render(true); case "delete": { return this.item.deleteEmbeddedEntity("ActiveEffect", li.data("effectId")); diff --git a/src/module/item/item.ts b/src/module/item/item.ts index e9a1aa3e..4944a12c 100644 --- a/src/module/item/item.ts +++ b/src/module/item/item.ts @@ -1,12 +1,10 @@ -import { DS4Actor } from "../actor/actor"; -import { DS4ActorDataType } from "../actor/actor-data"; -import { DS4ItemDataType, DS4Talent } from "./item-data"; +import { DS4ItemData, DS4Talent } from "./item-data"; /** * Extend the basic Item with some very simple modifications. * @extends {Item} */ -export class DS4Item extends Item { +export class DS4Item extends Item { /** * Augment the basic Item data model with additional dynamic data. */ diff --git a/src/module/rolls/check-factory.ts b/src/module/rolls/check-factory.ts index c972120c..4cadd373 100644 --- a/src/module/rolls/check-factory.ts +++ b/src/module/rolls/check-factory.ts @@ -130,41 +130,38 @@ async function askGmModifier( const renderedHtml = await renderTemplate(usedTemplate, templateData); const dialogPromise = new Promise((resolve) => { - new Dialog( - { - title: usedTitle, - close: () => { - // Don't do anything - }, - content: renderedHtml, - buttons: { - ok: { - label: game.i18n.localize("DS4.RollDialogOkButton"), - callback: (html: HTMLElement | JQuery) => { - if (!("jquery" in html)) { - throw new Error( - game.i18n.format("DS4.ErrorUnexpectedHtmlType", { - exType: "JQuery", - realType: "HTMLElement", - }), - ); - } else { - const innerForm = html[0].querySelector("form"); - resolve(innerForm); - } - }, - }, - cancel: { - label: game.i18n.localize("DS4.RollDialogCancelButton"), - callback: () => { - // Don't do anything - }, - }, - }, - default: "ok", + new Dialog({ + title: usedTitle, + close: () => { + // Don't do anything }, - {}, - ).render(true); + content: renderedHtml, + buttons: { + ok: { + label: game.i18n.localize("DS4.RollDialogOkButton"), + callback: (html: HTMLElement | JQuery) => { + if (!("jquery" in html)) { + throw new Error( + game.i18n.format("DS4.ErrorUnexpectedHtmlType", { + exType: "JQuery", + realType: "HTMLElement", + }), + ); + } else { + const innerForm = html[0].querySelector("form"); + resolve(innerForm); + } + }, + }, + cancel: { + label: game.i18n.localize("DS4.RollDialogCancelButton"), + callback: () => { + // Don't do anything + }, + }, + }, + default: "ok", + }).render(true); }); const dialogForm = await dialogPromise; return parseDialogFormData(dialogForm, targetValue); diff --git a/tsconfig.json b/tsconfig.json index f988dd5b..af1b6738 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,8 @@ "compilerOptions": { "target": "ES2017", "lib": ["DOM", "ES6", "ES2017"], - "types": ["foundry-pc-types"], - "esModuleInterop": true + "types": ["foundry-vtt-types"], + "esModuleInterop": true, + "skipLibCheck": true // TODO(types): remove once https://github.com/kmoschcau/foundry-vtt-types/issues/217 is resolved } } From a0c4d1c4d9bf6bda1a17a50a052d16d0d5ced6ee Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Tue, 26 Jan 2021 03:58:03 +0100 Subject: [PATCH 17/53] small adjustments to TODO comments --- src/module/actor/sheets/actor-sheet.ts | 2 +- src/module/item/item-sheet.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/module/actor/sheets/actor-sheet.ts b/src/module/actor/sheets/actor-sheet.ts index e499b109..c72d79b4 100644 --- a/src/module/actor/sheets/actor-sheet.ts +++ b/src/module/actor/sheets/actor-sheet.ts @@ -117,7 +117,7 @@ export class DS4ActorSheet extends ActorSheet { }; // Finally, create the item! - return this.actor.createOwnedItem(itemData as DS4ItemData); // TODO(types) Improve upstream typing of createOwnedItem. It is possible to leave parts out here. + return this.actor.createOwnedItem(itemData as DS4ItemData); // TODO(types): Improve upstream typing of createOwnedItem. It is possible to leave parts out here. } /** diff --git a/src/module/item/item-sheet.ts b/src/module/item/item-sheet.ts index f974a76b..c29c9234 100644 --- a/src/module/item/item-sheet.ts +++ b/src/module/item/item-sheet.ts @@ -63,7 +63,7 @@ export class DS4ItemSheet extends ItemSheet { const position = super.setPosition(options); if ("find" in this.element) { const sheetBody = this.element.find(".sheet-body"); - const bodyHeight = (position.height as number) - 192; // TODO: remove type cast once https://github.com/kmoschcau/foundry-vtt-types/pull/214 is merged + const bodyHeight = (position.height as number) - 192; // TODO(types): remove type cast once https://github.com/kmoschcau/foundry-vtt-types/pull/214 is merged sheetBody.css("height", bodyHeight); } else { console.log("Failure setting position."); @@ -99,7 +99,7 @@ export class DS4ItemSheet extends ItemSheet { case "create": return this._createActiveEffect(); case "edit": - const effect = this.item["effects"].get(li.data("effectId")); // TODO replace with item.effect once https://github.com/kmoschcau/foundry-vtt-types/pull/216 is merged + const effect = this.item["effects"].get(li.data("effectId")); // TODO(types): replace with item.effect once https://github.com/kmoschcau/foundry-vtt-types/pull/216 is merged return effect.sheet.render(true); case "delete": { return this.item.deleteEmbeddedEntity("ActiveEffect", li.data("effectId")); From f5117623658f4e38bd1f739c3747f8ebed8db801 Mon Sep 17 00:00:00 2001 From: Gesina Schwalbe Date: Tue, 26 Jan 2021 20:30:53 +0100 Subject: [PATCH 18/53] Apply 1 suggestion(s) to 1 file(s) --- src/templates/actor/character-sheet.hbs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/templates/actor/character-sheet.hbs b/src/templates/actor/character-sheet.hbs index 75be93ff..0d0382c3 100644 --- a/src/templates/actor/character-sheet.hbs +++ b/src/templates/actor/character-sheet.hbs @@ -84,6 +84,8 @@ {{localize 'DS4.HeadingBiography'}} + + {{!-- Sheet Body (remove indentation to avoid annoying Handlebars auto-indent) --}}
      {{!-- Items Tab --}} @@ -104,4 +106,6 @@ editable=editable}}
      + + From 0b70bbf9b90987e34df756fd2742e4586fcc144f Mon Sep 17 00:00:00 2001 From: Gesina Schwalbe Date: Tue, 26 Jan 2021 20:47:28 +0100 Subject: [PATCH 19/53] merged i18n and i18nKeys --- src/module/config.ts | 11 +++-------- src/module/ds4.ts | 8 ++++---- src/module/item/item-data.ts | 2 +- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/module/config.ts b/src/module/config.ts index 0f1bd1e0..d023fc05 100644 --- a/src/module/config.ts +++ b/src/module/config.ts @@ -9,16 +9,11 @@ export const DS4 = { =============================================================================================`, /** - * A dictionary of dictionaries each mapping keys to localized strings. - * To be filled with the localizations derived from i18nKeys. + * A dictionary of dictionaries each mapping keys to localized strings + * resp. their localization keys. + * The localization is assumed to take place on each reload. */ i18n: { - // to be filled with the localized mappings from i18nKeys - }, - /** - * A dictionary of dictionaries each mapping keys to localization keys. - */ - i18nKeys: { /** * Define the set of acttack types that can be performed with weapon items */ diff --git a/src/module/ds4.ts b/src/module/ds4.ts index a2f6ff2f..63a2dec4 100644 --- a/src/module/ds4.ts +++ b/src/module/ds4.ts @@ -29,8 +29,8 @@ Hooks.once("init", async function () { CONFIG.Item.entityClass = DS4Item as typeof Item; // Define localized type labels - CONFIG.Actor.typeLabels = DS4.i18nKeys.actorTypes; - CONFIG.Item.typeLabels = DS4.i18nKeys.itemTypes; + CONFIG.Actor.typeLabels = DS4.i18n.actorTypes; + CONFIG.Item.typeLabels = DS4.i18n.itemTypes; // Configure Dice CONFIG.Dice.types = [Die, DS4Check]; @@ -88,8 +88,8 @@ Hooks.once("setup", function () { const noSort = ["attributes", "traits", "combatValues", "creatureSizeCategories"]; // Localize and sort CONFIG objects - for (const o of Object.keys(CONFIG.DS4.i18nKeys)) { - const localized = Object.entries(CONFIG.DS4.i18nKeys[o]).map((e) => { + for (const o of Object.keys(CONFIG.DS4.i18n)) { + const localized = Object.entries(CONFIG.DS4.i18n[o]).map((e) => { return [e[0], game.i18n.localize(e[1] as string)]; }); if (!noSort.includes(o)) localized.sort((a, b) => a[1].localeCompare(b[1])); diff --git a/src/module/item/item-data.ts b/src/module/item/item-data.ts index 63951e46..b1cc26ef 100644 --- a/src/module/item/item-data.ts +++ b/src/module/item/item-data.ts @@ -1,7 +1,7 @@ import { ModifiableData } from "../common/common-data"; import { DS4 } from "../config"; -export type ItemType = keyof typeof DS4.i18nKeys.itemTypes; +export type ItemType = keyof typeof DS4.i18n.itemTypes; export type DS4ItemDataType = | DS4Weapon From 53f5514db39e0d54b0b871d918df7eff696ecb4e Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Tue, 26 Jan 2021 21:24:31 +0100 Subject: [PATCH 20/53] Update types --- package-lock.json | 5 +++-- package.json | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index c647856a..62f40bb9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3119,8 +3119,8 @@ } }, "foundry-vtt-types": { - "version": "github:kmoschcau/foundry-vtt-types#21f009f10de74856556ceadf71fb436089c663cc", - "from": "github:kmoschcau/foundry-vtt-types#foundry-0.7.9", + "version": "github:League-of-Foundry-Developers/foundry-vtt-types#7f7eccf1fa68ad869e98361199628764961d9c8c", + "from": "github:League-of-Foundry-Developers/foundry-vtt-types#foundry-0.7.9", "dev": true, "requires": { "@types/howler": "2.2.1", @@ -3130,6 +3130,7 @@ "@types/tinymce": "^4.5.24", "handlebars": "4.7.6", "pixi.js": "5.3.4", + "typescript": "^4.1.3", "utility-types": "^3.10.0" }, "dependencies": { diff --git a/package.json b/package.json index 274641bf..81c22eaa 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "build:watch": "gulp watch", "link": "gulp link", "clean": "gulp clean && gulp link --clean", - "update": "npm install --save-dev github:kmoschcau/foundry-vtt-types#foundry-0.7.9", + "update": "npm install --save-dev github:League-of-Foundry-Developers/foundry-vtt-types#foundry-0.7.9", "updateManifest": "gulp updateManifest", "lint": "eslint 'src/**/*.ts' --cache", "lint:fix": "eslint 'src/**/*.ts' --cache --fix", @@ -53,7 +53,7 @@ "eslint": "^7.18.0", "eslint-config-prettier": "^7.1.0", "eslint-plugin-prettier": "^3.3.1", - "foundry-vtt-types": "github:kmoschcau/foundry-vtt-types#foundry-0.7.9", + "foundry-vtt-types": "github:League-of-Foundry-Developers/foundry-vtt-types#foundry-0.7.9", "fs-extra": "^9.0.1", "gulp": "^4.0.2", "gulp-git": "^2.10.1", From ba268e424554b68727311280e87b7a85ede7df21 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Tue, 26 Jan 2021 21:25:43 +0100 Subject: [PATCH 21/53] remove workaround for position type --- src/module/item/item-sheet.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/module/item/item-sheet.ts b/src/module/item/item-sheet.ts index c29c9234..b5f50264 100644 --- a/src/module/item/item-sheet.ts +++ b/src/module/item/item-sheet.ts @@ -63,7 +63,7 @@ export class DS4ItemSheet extends ItemSheet { const position = super.setPosition(options); if ("find" in this.element) { const sheetBody = this.element.find(".sheet-body"); - const bodyHeight = (position.height as number) - 192; // TODO(types): remove type cast once https://github.com/kmoschcau/foundry-vtt-types/pull/214 is merged + const bodyHeight = position.height - 192; sheetBody.css("height", bodyHeight); } else { console.log("Failure setting position."); From 3209280b298c89e18005a11de7d22d3eeefe44c6 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Wed, 27 Jan 2021 01:38:47 +0100 Subject: [PATCH 22/53] Fix linter warning --- .eslintrc.js | 2 ++ src/module/ds4.ts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index 8d021e69..6f42ee63 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -12,6 +12,8 @@ module.exports = { "plugin:prettier/recommended", // Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array. ], + plugins: ["@typescript-eslint"], + rules: { // Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs // e.g. "@typescript-eslint/explicit-function-return-type": "off", diff --git a/src/module/ds4.ts b/src/module/ds4.ts index 0431d04a..7eea2bbf 100644 --- a/src/module/ds4.ts +++ b/src/module/ds4.ts @@ -113,7 +113,7 @@ Hooks.once("ready", function () { * (in this order). */ ["renderApplication", "renderActorSheet", "renderItemSheet"].forEach((hookName: string) => { - Hooks.on(hookName, (app: Dialog, html: JQueryStatic, data: any) => { + Hooks.on(hookName, (app: Dialog, html: JQueryStatic) => { $(html) .find("input") .on("focus", (ev: JQuery.FocusEvent) => { From d6b46d6183696746faaf059e832eecb72e522e98 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Fri, 29 Jan 2021 11:23:34 +0100 Subject: [PATCH 23/53] Remove skipLibCheck --- package-lock.json | 2 +- src/module/actor/sheets/actor-sheet.ts | 2 +- tsconfig.json | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 62f40bb9..59fe8050 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3119,7 +3119,7 @@ } }, "foundry-vtt-types": { - "version": "github:League-of-Foundry-Developers/foundry-vtt-types#7f7eccf1fa68ad869e98361199628764961d9c8c", + "version": "github:League-of-Foundry-Developers/foundry-vtt-types#c25d4823c2950ce472fbac240d56ff07e2d4cdaa", "from": "github:League-of-Foundry-Developers/foundry-vtt-types#foundry-0.7.9", "dev": true, "requires": { diff --git a/src/module/actor/sheets/actor-sheet.ts b/src/module/actor/sheets/actor-sheet.ts index c72d79b4..909b8098 100644 --- a/src/module/actor/sheets/actor-sheet.ts +++ b/src/module/actor/sheets/actor-sheet.ts @@ -218,7 +218,7 @@ export class DS4ActorSheet extends ActorSheet { const roll = new Roll(dataset.roll, this.actor.data.data); const label = dataset.label ? `Rolling ${dataset.label}` : ""; roll.roll().toMessage({ - speaker: ChatMessage.getSpeaker({ actor: this.actor }), + speaker: ChatMessage.getSpeaker({ actor: (this.actor as unknown) as string }), // TODO(types): Fix ChatMessage.getSpeaker in upstream flavor: label, }); } diff --git a/tsconfig.json b/tsconfig.json index af1b6738..5f44cffe 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,6 +4,7 @@ "lib": ["DOM", "ES6", "ES2017"], "types": ["foundry-vtt-types"], "esModuleInterop": true, - "skipLibCheck": true // TODO(types): remove once https://github.com/kmoschcau/foundry-vtt-types/issues/217 is resolved - } + "moduleResolution": "node" + }, + "include": ["src"] } From 3d5912a6314be1a59ad4272bb927d23156de0b2f Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Fri, 29 Jan 2021 16:17:31 +0100 Subject: [PATCH 24/53] Update foundry-vtt-types --- package-lock.json | 2 +- src/module/item/item-sheet.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 59fe8050..1ac37387 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3119,7 +3119,7 @@ } }, "foundry-vtt-types": { - "version": "github:League-of-Foundry-Developers/foundry-vtt-types#c25d4823c2950ce472fbac240d56ff07e2d4cdaa", + "version": "github:League-of-Foundry-Developers/foundry-vtt-types#e08a7166345d7905ac8324d6f418c05d98a49ebf", "from": "github:League-of-Foundry-Developers/foundry-vtt-types#foundry-0.7.9", "dev": true, "requires": { diff --git a/src/module/item/item-sheet.ts b/src/module/item/item-sheet.ts index b5f50264..3fe09a3d 100644 --- a/src/module/item/item-sheet.ts +++ b/src/module/item/item-sheet.ts @@ -99,7 +99,7 @@ export class DS4ItemSheet extends ItemSheet { case "create": return this._createActiveEffect(); case "edit": - const effect = this.item["effects"].get(li.data("effectId")); // TODO(types): replace with item.effect once https://github.com/kmoschcau/foundry-vtt-types/pull/216 is merged + const effect = this.item.effects.get(li.data("effectId")); return effect.sheet.render(true); case "delete": { return this.item.deleteEmbeddedEntity("ActiveEffect", li.data("effectId")); @@ -110,7 +110,7 @@ export class DS4ItemSheet extends ItemSheet { /** * Create a new ActiveEffect for the item using default data. */ - private async _createActiveEffect(): Promise { + private async _createActiveEffect(): Promise { const label = `New Effect`; const createData = { @@ -120,7 +120,7 @@ export class DS4ItemSheet extends ItemSheet { transfer: true, }; - const effect = await ActiveEffect.create(createData, this.item); + const effect = ActiveEffect.create(createData as ActiveEffect.Data, this.item); // TODO(types): ActiveEffect.create should be able to work with only partial createData. Fix this upstream return effect.create({}); } } From 628490c6f24b41aa1a58b8b0c3568dafb75422df Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Fri, 29 Jan 2021 16:44:08 +0100 Subject: [PATCH 25/53] Update TODOs --- src/module/actor/sheets/actor-sheet.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/module/actor/sheets/actor-sheet.ts b/src/module/actor/sheets/actor-sheet.ts index 909b8098..e4095016 100644 --- a/src/module/actor/sheets/actor-sheet.ts +++ b/src/module/actor/sheets/actor-sheet.ts @@ -117,7 +117,7 @@ export class DS4ActorSheet extends ActorSheet { }; // Finally, create the item! - return this.actor.createOwnedItem(itemData as DS4ItemData); // TODO(types): Improve upstream typing of createOwnedItem. It is possible to leave parts out here. + return this.actor.createOwnedItem(itemData as DS4ItemData); // TODO(types): Improve upstream typing of createOwnedItem. It is possible to leave parts out here. Should be fine after https://github.com/League-of-Foundry-Developers/foundry-vtt-types/pull/4/ is merged } /** @@ -132,7 +132,7 @@ export class DS4ActorSheet extends ActorSheet { console.log("Current target:", $(ev.currentTarget).get(0)["name"]); const el: HTMLFormElement = $(ev.currentTarget).get(0); const id = $(ev.currentTarget).parents(".item").data("itemId"); - const item = (duplicate(this.actor.getOwnedItem(id)) as unknown) as DS4ItemData; // TODO(types): Possible get better type definition for duplicate into upstream + const item = (duplicate(this.actor.getOwnedItem(id)) as unknown) as DS4ItemData; // TODO(types): Possibly get better type definition for duplicate into upstream const property: string | undefined = $(ev.currentTarget).data("property"); // Early return: From 6c3432cb269a66b65159e772ad9cc00d92fb21c7 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Sun, 31 Jan 2021 19:57:14 +0100 Subject: [PATCH 26/53] update type definitions --- package-lock.json | 2 +- src/module/actor/actor.ts | 2 +- src/module/actor/sheets/actor-sheet.ts | 6 +++--- src/module/ds4.ts | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1ac37387..1e3ef9af 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3119,7 +3119,7 @@ } }, "foundry-vtt-types": { - "version": "github:League-of-Foundry-Developers/foundry-vtt-types#e08a7166345d7905ac8324d6f418c05d98a49ebf", + "version": "github:League-of-Foundry-Developers/foundry-vtt-types#cc36aef8865034a37e56ac01b27c8a0746253fbb", "from": "github:League-of-Foundry-Developers/foundry-vtt-types#foundry-0.7.9", "dev": true, "requires": { diff --git a/src/module/actor/actor.ts b/src/module/actor/actor.ts index 702a70fb..6c68e460 100644 --- a/src/module/actor/actor.ts +++ b/src/module/actor/actor.ts @@ -3,7 +3,7 @@ import { DS4Item } from "../item/item"; import { DS4Armor, DS4Shield, ItemType } from "../item/item-data"; import { DS4ActorData } from "./actor-data"; -export class DS4Actor extends Actor { +export class DS4Actor extends Actor { /** @override */ prepareDerivedData(): void { const data = this.data; diff --git a/src/module/actor/sheets/actor-sheet.ts b/src/module/actor/sheets/actor-sheet.ts index e4095016..239df189 100644 --- a/src/module/actor/sheets/actor-sheet.ts +++ b/src/module/actor/sheets/actor-sheet.ts @@ -117,17 +117,17 @@ export class DS4ActorSheet extends ActorSheet { }; // Finally, create the item! - return this.actor.createOwnedItem(itemData as DS4ItemData); // TODO(types): Improve upstream typing of createOwnedItem. It is possible to leave parts out here. Should be fine after https://github.com/League-of-Foundry-Developers/foundry-vtt-types/pull/4/ is merged + return this.actor.createOwnedItem(itemData); } /** * Handle changes to properties of an Owned Item from within character sheet. * Can currently properly bind: see getValue(). * Assumes the item property is given as the value of the HTML element property 'data-property'. - * @param {JQuery.ChangeEvent} ev The originating change event + * @param {JQuery.ChangeEvent} ev The originating change event * @private */ - private _onItemChange(ev: JQuery.ChangeEvent): void { + private _onItemChange(ev: JQuery.ChangeEvent): void { ev.preventDefault(); console.log("Current target:", $(ev.currentTarget).get(0)["name"]); const el: HTMLFormElement = $(ev.currentTarget).get(0); diff --git a/src/module/ds4.ts b/src/module/ds4.ts index 7eea2bbf..f057db5d 100644 --- a/src/module/ds4.ts +++ b/src/module/ds4.ts @@ -33,7 +33,7 @@ Hooks.once("init", async function () { CONFIG.Item.typeLabels = DS4.i18n.itemTypes; // Configure Dice - CONFIG.Dice.types = [Die, DS4Check]; + CONFIG.Dice.types = [Die, DS4Check]; // TODO(types) fix upstream CONFIG.Dice.terms = { c: Coin, d: Die, From b0d4875c30426c3ea9615d4ab6a6e576274287d1 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Tue, 2 Feb 2021 17:35:12 +0100 Subject: [PATCH 27/53] Update types --- package-lock.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1e3ef9af..096634e5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3119,7 +3119,7 @@ } }, "foundry-vtt-types": { - "version": "github:League-of-Foundry-Developers/foundry-vtt-types#cc36aef8865034a37e56ac01b27c8a0746253fbb", + "version": "github:League-of-Foundry-Developers/foundry-vtt-types#d2ab516e66b01af00ce88d24b77fe00c19d882f6", "from": "github:League-of-Foundry-Developers/foundry-vtt-types#foundry-0.7.9", "dev": true, "requires": { @@ -3712,9 +3712,9 @@ "dev": true }, "uglify-js": { - "version": "3.12.5", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.12.5.tgz", - "integrity": "sha512-SgpgScL4T7Hj/w/GexjnBHi3Ien9WS1Rpfg5y91WXMj9SY997ZCQU76mH4TpLwwfmMvoOU8wiaRkIf6NaH3mtg==", + "version": "3.12.6", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.12.6.tgz", + "integrity": "sha512-aqWHe3DfQmZUDGWBbabZ2eQnJlQd1fKlMUu7gV+MiTuDzdgDw31bI3wA2jLLsV/hNcDP26IfyEgSVoft5+0SVw==", "dev": true, "optional": true }, From 763535bd8f5726ce32cbcaa96760dc75f3d0f7bb Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Wed, 3 Feb 2021 21:40:56 +0100 Subject: [PATCH 28/53] update types --- package-lock.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 096634e5..7894b22c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3119,7 +3119,7 @@ } }, "foundry-vtt-types": { - "version": "github:League-of-Foundry-Developers/foundry-vtt-types#d2ab516e66b01af00ce88d24b77fe00c19d882f6", + "version": "github:League-of-Foundry-Developers/foundry-vtt-types#e26dfcdeef409cd15a69b4e106c5c20060416746", "from": "github:League-of-Foundry-Developers/foundry-vtt-types#foundry-0.7.9", "dev": true, "requires": { From d8e085ce816896efba4dfa3149987979d284aa3f Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Thu, 4 Feb 2021 12:32:07 +0100 Subject: [PATCH 29/53] update types --- package-lock.json | 8 ++++---- src/module/ds4.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7894b22c..64f78792 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3119,7 +3119,7 @@ } }, "foundry-vtt-types": { - "version": "github:League-of-Foundry-Developers/foundry-vtt-types#e26dfcdeef409cd15a69b4e106c5c20060416746", + "version": "github:League-of-Foundry-Developers/foundry-vtt-types#6ce375cdf4941da6c8213b3e5c6c5dffea3677b9", "from": "github:League-of-Foundry-Developers/foundry-vtt-types#foundry-0.7.9", "dev": true, "requires": { @@ -3135,9 +3135,9 @@ }, "dependencies": { "@types/node": { - "version": "14.14.22", - "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.22.tgz", - "integrity": "sha512-g+f/qj/cNcqKkc3tFqlXOYjrmZA+jNBiDzbP3kH+B+otKFqAdPgVTGP1IeKRdMml/aE69as5S4FqtxAbl+LaMw==", + "version": "14.14.25", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.25.tgz", + "integrity": "sha512-EPpXLOVqDvisVxtlbvzfyqSsFeQxltFbluZNRndIb8tr9KiBnYNLzrc1N3pyKUCww2RNrfHDViqDWWE1LCJQtQ==", "dev": true } } diff --git a/src/module/ds4.ts b/src/module/ds4.ts index f057db5d..e0430975 100644 --- a/src/module/ds4.ts +++ b/src/module/ds4.ts @@ -13,7 +13,7 @@ import { migration } from "./migrations"; Hooks.once("init", async function () { console.log(`DS4 | Initializing the DS4 Game System\n${DS4.ASCII}`); - game["ds4"] = { + game["DS4"] = { DS4Actor, DS4Item, DS4, From 4e9b434839aa85296ac009991415c6156ec32aa1 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Thu, 4 Feb 2021 14:39:51 +0100 Subject: [PATCH 30/53] update types --- package-lock.json | 2 +- src/module/actor/sheets/actor-sheet.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 64f78792..ec268855 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3119,7 +3119,7 @@ } }, "foundry-vtt-types": { - "version": "github:League-of-Foundry-Developers/foundry-vtt-types#6ce375cdf4941da6c8213b3e5c6c5dffea3677b9", + "version": "github:League-of-Foundry-Developers/foundry-vtt-types#6a0610600e1058057ec54707762636eab313e2b4", "from": "github:League-of-Foundry-Developers/foundry-vtt-types#foundry-0.7.9", "dev": true, "requires": { diff --git a/src/module/actor/sheets/actor-sheet.ts b/src/module/actor/sheets/actor-sheet.ts index 239df189..ff29e4cf 100644 --- a/src/module/actor/sheets/actor-sheet.ts +++ b/src/module/actor/sheets/actor-sheet.ts @@ -132,7 +132,7 @@ export class DS4ActorSheet extends ActorSheet { console.log("Current target:", $(ev.currentTarget).get(0)["name"]); const el: HTMLFormElement = $(ev.currentTarget).get(0); const id = $(ev.currentTarget).parents(".item").data("itemId"); - const item = (duplicate(this.actor.getOwnedItem(id)) as unknown) as DS4ItemData; // TODO(types): Possibly get better type definition for duplicate into upstream + const item = duplicate(this.actor.getOwnedItem(id)); const property: string | undefined = $(ev.currentTarget).data("property"); // Early return: From bedab9ae83e80e5cfba7c6091153cd3232deb8e6 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Thu, 4 Feb 2021 17:28:55 +0100 Subject: [PATCH 31/53] update types --- package-lock.json | 2 +- src/module/item/item-sheet.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index ec268855..a91749c8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3119,7 +3119,7 @@ } }, "foundry-vtt-types": { - "version": "github:League-of-Foundry-Developers/foundry-vtt-types#6a0610600e1058057ec54707762636eab313e2b4", + "version": "github:League-of-Foundry-Developers/foundry-vtt-types#7e435fb1797edcde223ded6a5e7a75ce2140bf17", "from": "github:League-of-Foundry-Developers/foundry-vtt-types#foundry-0.7.9", "dev": true, "requires": { diff --git a/src/module/item/item-sheet.ts b/src/module/item/item-sheet.ts index 3fe09a3d..c4e5fc33 100644 --- a/src/module/item/item-sheet.ts +++ b/src/module/item/item-sheet.ts @@ -120,7 +120,7 @@ export class DS4ItemSheet extends ItemSheet { transfer: true, }; - const effect = ActiveEffect.create(createData as ActiveEffect.Data, this.item); // TODO(types): ActiveEffect.create should be able to work with only partial createData. Fix this upstream + const effect = ActiveEffect.create(createData, this.item); return effect.create({}); } } From 1d4c0ac459dcc223e722398e71a045cf19869e89 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Thu, 4 Feb 2021 18:00:05 +0100 Subject: [PATCH 32/53] update types --- package-lock.json | 2 +- src/module/actor/sheets/actor-sheet.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index a91749c8..b631343f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3119,7 +3119,7 @@ } }, "foundry-vtt-types": { - "version": "github:League-of-Foundry-Developers/foundry-vtt-types#7e435fb1797edcde223ded6a5e7a75ce2140bf17", + "version": "github:League-of-Foundry-Developers/foundry-vtt-types#71dbbcc8e94b8ffeb9e7295f1cb2af73f2d0c3d0", "from": "github:League-of-Foundry-Developers/foundry-vtt-types#foundry-0.7.9", "dev": true, "requires": { diff --git a/src/module/actor/sheets/actor-sheet.ts b/src/module/actor/sheets/actor-sheet.ts index ff29e4cf..61f01e0f 100644 --- a/src/module/actor/sheets/actor-sheet.ts +++ b/src/module/actor/sheets/actor-sheet.ts @@ -218,7 +218,7 @@ export class DS4ActorSheet extends ActorSheet { const roll = new Roll(dataset.roll, this.actor.data.data); const label = dataset.label ? `Rolling ${dataset.label}` : ""; roll.roll().toMessage({ - speaker: ChatMessage.getSpeaker({ actor: (this.actor as unknown) as string }), // TODO(types): Fix ChatMessage.getSpeaker in upstream + speaker: ChatMessage.getSpeaker({ actor: this.actor }), flavor: label, }); } From cd86857b43bd3d2b8fbd92c3d280165ff79b13aa Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Thu, 4 Feb 2021 23:03:49 +0100 Subject: [PATCH 33/53] Update types --- package-lock.json | 2 +- src/module/ds4.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index b631343f..c4b848c1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3119,7 +3119,7 @@ } }, "foundry-vtt-types": { - "version": "github:League-of-Foundry-Developers/foundry-vtt-types#71dbbcc8e94b8ffeb9e7295f1cb2af73f2d0c3d0", + "version": "github:League-of-Foundry-Developers/foundry-vtt-types#4890983e397a28026b0a38c4081fb284ff97020a", "from": "github:League-of-Foundry-Developers/foundry-vtt-types#foundry-0.7.9", "dev": true, "requires": { diff --git a/src/module/ds4.ts b/src/module/ds4.ts index e0430975..988f5b88 100644 --- a/src/module/ds4.ts +++ b/src/module/ds4.ts @@ -13,7 +13,7 @@ import { migration } from "./migrations"; Hooks.once("init", async function () { console.log(`DS4 | Initializing the DS4 Game System\n${DS4.ASCII}`); - game["DS4"] = { + game.DS4 = { DS4Actor, DS4Item, DS4, From 2641b1ee74e31423914cbc5cd751de6b66de26fa Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Fri, 5 Feb 2021 02:35:47 +0100 Subject: [PATCH 34/53] Update types --- package-lock.json | 2 +- src/module/actor/sheets/actor-sheet.ts | 3 +- src/module/ds4.ts | 9 ++-- src/module/item/item-sheet.ts | 3 +- src/module/rolls/check-factory.ts | 59 +++++++++++++------------- 5 files changed, 38 insertions(+), 38 deletions(-) diff --git a/package-lock.json b/package-lock.json index c4b848c1..3ace79b2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3119,7 +3119,7 @@ } }, "foundry-vtt-types": { - "version": "github:League-of-Foundry-Developers/foundry-vtt-types#4890983e397a28026b0a38c4081fb284ff97020a", + "version": "github:League-of-Foundry-Developers/foundry-vtt-types#dc5ff5a9c75cda3f4999603221275ed8d7d9212c", "from": "github:League-of-Foundry-Developers/foundry-vtt-types#foundry-0.7.9", "dev": true, "requires": { diff --git a/src/module/actor/sheets/actor-sheet.ts b/src/module/actor/sheets/actor-sheet.ts index 61f01e0f..470b8e31 100644 --- a/src/module/actor/sheets/actor-sheet.ts +++ b/src/module/actor/sheets/actor-sheet.ts @@ -1,3 +1,4 @@ +import { DS4 } from "../../config"; import { DS4Item } from "../../item/item"; import { DS4ItemData, ItemType } from "../../item/item-data"; import { DS4Actor } from "../actor"; @@ -55,7 +56,7 @@ export class DS4ActorSheet extends ActorSheet { const data = { ...super.getData(), // Add the localization config to the data: - config: CONFIG.DS4, + config: DS4, // Add the items explicitly sorted by type to the data: itemsByType: this.actor.itemTypes, }; diff --git a/src/module/ds4.ts b/src/module/ds4.ts index 988f5b88..b64491ae 100644 --- a/src/module/ds4.ts +++ b/src/module/ds4.ts @@ -35,8 +35,7 @@ Hooks.once("init", async function () { // Configure Dice CONFIG.Dice.types = [Die, DS4Check]; // TODO(types) fix upstream CONFIG.Dice.terms = { - c: Coin, - d: Die, + ...CONFIG.Dice.terms, s: DS4Check, }; @@ -88,12 +87,12 @@ Hooks.once("setup", function () { const noSort = ["attributes", "traits", "combatValues", "creatureSizeCategories"]; // Localize and sort CONFIG objects - for (const o of Object.keys(CONFIG.DS4.i18n)) { - const localized = Object.entries(CONFIG.DS4.i18n[o]).map((e) => { + for (const o of Object.keys(DS4.i18n)) { + const localized = Object.entries(DS4.i18n[o]).map((e) => { return [e[0], game.i18n.localize(e[1] as string)]; }); if (!noSort.includes(o)) localized.sort((a, b) => a[1].localeCompare(b[1])); - CONFIG.DS4.i18n[o] = localized.reduce((obj, e) => { + DS4.i18n[o] = localized.reduce((obj, e) => { obj[e[0]] = e[1]; return obj; }, {}); diff --git a/src/module/item/item-sheet.ts b/src/module/item/item-sheet.ts index c4e5fc33..970cefac 100644 --- a/src/module/item/item-sheet.ts +++ b/src/module/item/item-sheet.ts @@ -1,3 +1,4 @@ +import { DS4 } from "../config"; import { DS4Item } from "./item"; import { isDS4ItemDataTypePhysical } from "./item-data"; @@ -47,7 +48,7 @@ export class DS4ItemSheet extends ItemSheet { getData(): ItemSheet.Data { const data = { ...super.getData(), - config: CONFIG.DS4, + config: DS4, isOwned: this.item.isOwned, actor: this.item.actor, isPhysical: isDS4ItemDataTypePhysical(this.item.data.data), diff --git a/src/module/rolls/check-factory.ts b/src/module/rolls/check-factory.ts index af8e8fa1..5c1eb7ce 100644 --- a/src/module/rolls/check-factory.ts +++ b/src/module/rolls/check-factory.ts @@ -34,7 +34,7 @@ class CheckFactory { private checkOptions: DS4CheckFactoryOptions; async execute(): Promise { - const rollCls: typeof Roll = CONFIG.Dice.rolls[0]; + const rollCls = CONFIG.Dice.rolls[0]; const formula = [ "ds", @@ -131,38 +131,37 @@ async function askGmModifier( const renderedHtml = await renderTemplate(usedTemplate, templateData); const dialogPromise = new Promise((resolve) => { - new Dialog({ - title: usedTitle, - close: () => { - // Don't do anything - }, - content: renderedHtml, - buttons: { - ok: { - label: game.i18n.localize("DS4.RollDialogOkButton"), - callback: (html: HTMLElement | JQuery) => { - if (!("jquery" in html)) { - throw new Error( - game.i18n.format("DS4.ErrorUnexpectedHtmlType", { - exType: "JQuery", - realType: "HTMLElement", - }), - ); - } else { - const innerForm = html[0].querySelector("form"); - resolve(innerForm); - } - }, - }, - cancel: { - label: game.i18n.localize("DS4.RollDialogCancelButton"), - callback: () => { - // Don't do anything + new Dialog( + { + title: usedTitle, + content: renderedHtml, + buttons: { + ok: { + label: game.i18n.localize("DS4.RollDialogOkButton"), + callback: (html) => { + if (!("jquery" in html)) { + throw new Error( + game.i18n.format("DS4.ErrorUnexpectedHtmlType", { + exType: "JQuery", + realType: "HTMLElement", + }), + ); + } else { + const innerForm = html[0].querySelector("form"); + resolve(innerForm); + } + }, + icon: "", // TODO(types): Remove once https://github.com/League-of-Foundry-Developers/foundry-vtt-types/issues/266 is fixed + }, + cancel: { + label: game.i18n.localize("DS4.RollDialogCancelButton"), + icon: "", // TODO(types): Remove once https://github.com/League-of-Foundry-Developers/foundry-vtt-types/issues/266 is fixed }, }, + default: "ok", }, - default: "ok", - }).render(true); + {}, // TODO(types): Remove once https://github.com/League-of-Foundry-Developers/foundry-vtt-types/issues/267 is resolved + ).render(true); }); const dialogForm = await dialogPromise; return parseDialogFormData(dialogForm); From b8d11fa5cd6a1c90c56f92421f79c0177cd26407 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Fri, 5 Feb 2021 02:52:55 +0100 Subject: [PATCH 35/53] remove some redundant casts --- src/module/ds4.ts | 4 ++-- src/module/rolls/check-factory.ts | 2 +- src/module/rolls/check.ts | 2 +- src/module/rolls/roll-data.ts | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/module/ds4.ts b/src/module/ds4.ts index b64491ae..ffd62bab 100644 --- a/src/module/ds4.ts +++ b/src/module/ds4.ts @@ -25,8 +25,8 @@ Hooks.once("init", async function () { CONFIG.DS4 = DS4; // Define custom Entity classes - CONFIG.Actor.entityClass = DS4Actor as typeof Actor; - CONFIG.Item.entityClass = DS4Item as typeof Item; + CONFIG.Actor.entityClass = DS4Actor; + CONFIG.Item.entityClass = DS4Item; // Define localized type labels CONFIG.Actor.typeLabels = DS4.i18n.actorTypes; diff --git a/src/module/rolls/check-factory.ts b/src/module/rolls/check-factory.ts index 5c1eb7ce..b2da3534 100644 --- a/src/module/rolls/check-factory.ts +++ b/src/module/rolls/check-factory.ts @@ -10,7 +10,7 @@ class DefaultCheckOptions implements DS4CheckFactoryOptions { readonly rollMode: DS4RollMode = "roll"; mergeWith(other: Partial): DS4CheckFactoryOptions { - return { ...this, ...other } as DS4CheckFactoryOptions; + return { ...this, ...other }; } } diff --git a/src/module/rolls/check.ts b/src/module/rolls/check.ts index 38773fb3..0fd84be2 100644 --- a/src/module/rolls/check.ts +++ b/src/module/rolls/check.ts @@ -110,7 +110,7 @@ export class DS4Check extends DiceTerm { let checked = 0; while (checked < intermediateResults.length) { - const r = (intermediateResults as Array)[checked]; + const r = intermediateResults[checked]; checked++; if (!r.active) continue; diff --git a/src/module/rolls/roll-data.ts b/src/module/rolls/roll-data.ts index 78329e44..f4440156 100644 --- a/src/module/rolls/roll-data.ts +++ b/src/module/rolls/roll-data.ts @@ -12,7 +12,7 @@ export class DefaultRollOptions implements RollOptions { public slayingDiceRepetition = false; mergeWith(other: Partial): RollOptions { - return { ...this, ...other } as RollOptions; + return { ...this, ...other }; } } From b657633c7f9666d26f89d6ff7f477b63d3fb4547 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Fri, 5 Feb 2021 02:56:13 +0100 Subject: [PATCH 36/53] remove unwanted change --- src/module/ds4.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/module/ds4.ts b/src/module/ds4.ts index ffd62bab..657a4603 100644 --- a/src/module/ds4.ts +++ b/src/module/ds4.ts @@ -13,7 +13,7 @@ import { migration } from "./migrations"; Hooks.once("init", async function () { console.log(`DS4 | Initializing the DS4 Game System\n${DS4.ASCII}`); - game.DS4 = { + game.ds4 = { DS4Actor, DS4Item, DS4, From 5598255d6ef73b7bc691a56c63a7bd3da519fc91 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Fri, 5 Feb 2021 03:42:42 +0100 Subject: [PATCH 37/53] Improve typing of DS4Item and DS4Actor --- src/module/actor/actor-data.ts | 56 ++++++++++-------- src/module/actor/actor.ts | 13 +++-- src/module/actor/sheets/actor-sheet.ts | 2 +- src/module/item/item-data.ts | 80 ++++++++++++++++---------- src/module/item/item.ts | 6 +- 5 files changed, 94 insertions(+), 63 deletions(-) diff --git a/src/module/actor/actor-data.ts b/src/module/actor/actor-data.ts index c45a0cb2..9f12ef3e 100644 --- a/src/module/actor/actor-data.ts +++ b/src/module/actor/actor-data.ts @@ -1,23 +1,31 @@ import { ModifiableData, ResourceData, UsableResource } from "../common/common-data"; +import { DS4 } from "../config"; import { DS4ItemData } from "../item/item-data"; -export type DS4ActorData = Actor.Data; +export type DS4ActorData = DS4CharacterData | DS4CreatureData; -type DS4ActorDataType = DS4ActorDataCharacter | DS4ActorDataCreature; +type ActorType = keyof typeof DS4.i18n.actorTypes; -interface DS4ActorDataBase { - attributes: DS4ActorDataAttributes; - traits: DS4ActorDataTraits; - combatValues: DS4ActorDataCombatValues; +interface DS4ActorDataHelper extends Actor.Data { + type: U; } -interface DS4ActorDataAttributes { +type DS4CharacterData = DS4ActorDataHelper; +type DS4CreatureData = DS4ActorDataHelper; + +interface DS4ActorDataDataBase { + attributes: DS4ActorDataDataAttributes; + traits: DS4ActorDataDataTraits; + combatValues: DS4ActorDataDataCombatValues; +} + +interface DS4ActorDataDataAttributes { body: ModifiableData; mobility: ModifiableData; mind: ModifiableData; } -interface DS4ActorDataTraits { +interface DS4ActorDataDataTraits { strength: ModifiableData; constitution: ModifiableData; agility: ModifiableData; @@ -26,7 +34,7 @@ interface DS4ActorDataTraits { aura: ModifiableData; } -interface DS4ActorDataCombatValues { +interface DS4ActorDataDataCombatValues { hitPoints: ResourceData; defense: ModifiableData; initiative: ModifiableData; @@ -37,34 +45,32 @@ interface DS4ActorDataCombatValues { targetedSpellcasting: ModifiableData; } -interface DS4ActorDataCharacter extends DS4ActorDataBase { - baseInfo: DS4ActorDataCharacterBaseInfo; - progression: DS4ActorDataCharacterProgression; - language: DS4ActorDataCharacterLanguage; - profile: DS4ActorDataCharacterProfile; - currency: DS4ActorDataCharacterCurrency; +interface DS4CharacterDataData extends DS4ActorDataDataBase { + baseInfo: DS4CharacterDataDataBaseInfo; + progression: DS4CharacterDataDataProgression; + language: DS4CharacterDataDataLanguage; + profile: DS4CharacterDataDataProfile; + currency: DS4CharacterDataDataCurrency; } - -interface DS4ActorDataCharacterBaseInfo { +interface DS4CharacterDataDataBaseInfo { race: string; class: string; heroClass: string; culture: string; } - -interface DS4ActorDataCharacterProgression { +interface DS4CharacterDataDataProgression { level: number; experiencePoints: number; talentPoints: UsableResource; progressPoints: UsableResource; } -interface DS4ActorDataCharacterLanguage { +interface DS4CharacterDataDataLanguage { languages: string; alphabets: string; } -interface DS4ActorDataCharacterProfile { +interface DS4CharacterDataDataProfile { biography: string; gender: string; birthday: string; @@ -77,21 +83,21 @@ interface DS4ActorDataCharacterProfile { specialCharacteristics: string; } -interface DS4ActorDataCharacterCurrency { +interface DS4CharacterDataDataCurrency { gold: number; silver: number; copper: number; } -interface DS4ActorDataCreature extends DS4ActorDataBase { - baseInfo: DS4ActorDataCreatureBaseInfo; +interface DS4CreatureDataData extends DS4ActorDataDataBase { + baseInfo: DS4CreatureDataDataBaseInfo; } type CreatureType = "animal" | "construct" | "humanoid" | "magicalEntity" | "plantBeing" | "undead"; type SizeCategory = "tiny" | "small" | "normal" | "large" | "huge" | "colossal"; -interface DS4ActorDataCreatureBaseInfo { +interface DS4CreatureDataDataBaseInfo { loot: string; foeFactor: number; creatureType: CreatureType; diff --git a/src/module/actor/actor.ts b/src/module/actor/actor.ts index 6c68e460..47623d47 100644 --- a/src/module/actor/actor.ts +++ b/src/module/actor/actor.ts @@ -1,6 +1,6 @@ import { ModifiableData } from "../common/common-data"; import { DS4Item } from "../item/item"; -import { DS4Armor, DS4Shield, ItemType } from "../item/item-data"; +import { ItemType } from "../item/item-data"; import { DS4ActorData } from "./actor-data"; export class DS4Actor extends Actor { @@ -84,10 +84,13 @@ export class DS4Actor extends Actor { */ private _calculateArmorValueOfEquippedItems(): number { return this.items - .filter((item) => ["armor", "shield"].includes(item.type)) - .map((item) => item.data.data as DS4Armor | DS4Shield) - .filter((itemData) => itemData.equipped) - .map((itemData) => itemData.armorValue) + .map((item) => { + if (item.data.type === "armor" || item.data.type === "shield") { + return item.data.data.equipped ? item.data.data.armorValue : 0; + } else { + return 0; + } + }) .reduce((a, b) => a + b, 0); } diff --git a/src/module/actor/sheets/actor-sheet.ts b/src/module/actor/sheets/actor-sheet.ts index 470b8e31..c9adc8fc 100644 --- a/src/module/actor/sheets/actor-sheet.ts +++ b/src/module/actor/sheets/actor-sheet.ts @@ -128,7 +128,7 @@ export class DS4ActorSheet extends ActorSheet { * @param {JQuery.ChangeEvent} ev The originating change event * @private */ - private _onItemChange(ev: JQuery.ChangeEvent): void { + private _onItemChange(ev: JQuery.ChangeEvent): void { ev.preventDefault(); console.log("Current target:", $(ev.currentTarget).get(0)["name"]); const el: HTMLFormElement = $(ev.currentTarget).get(0); diff --git a/src/module/item/item-data.ts b/src/module/item/item-data.ts index 53736b79..33a9b67a 100644 --- a/src/module/item/item-data.ts +++ b/src/module/item/item-data.ts @@ -3,35 +3,53 @@ import { DS4 } from "../config"; export type ItemType = keyof typeof DS4.i18n.itemTypes; -export type DS4ItemData = Item.Data; +export type DS4ItemData = + | DS4WeaponData + | DS4ArmorData + | DS4ShieldData + | DS4SpellData + | DS4TrinketData + | DS4EquipmentData + | DS4TalentData + | DS4RacialAbilityData + | DS4LanguageData + | DS4AlphabetData + | DS4SpecialCreatureAbilityData; -type DS4ItemDataType = - | DS4Weapon - | DS4Armor - | DS4Shield - | DS4Spell - | DS4Trinket - | DS4Equipment - | DS4Talent - | DS4RacialAbility - | DS4Language - | DS4Alphabet - | DS4SpecialCreatureAbility; +interface DS4ItemDataHelper extends Item.Data { + type: U; +} + +type DS4WeaponData = DS4ItemDataHelper; +type DS4ArmorData = DS4ItemDataHelper; +type DS4ShieldData = DS4ItemDataHelper; +type DS4SpellData = DS4ItemDataHelper; +type DS4TrinketData = DS4ItemDataHelper; +type DS4EquipmentData = DS4ItemDataHelper; +type DS4TalentData = DS4ItemDataHelper; +type DS4RacialAbilityData = DS4ItemDataHelper; +type DS4LanguageData = DS4ItemDataHelper; +type DS4AlphabetData = DS4ItemDataHelper; +type DS4SpecialCreatureAbilityData = DS4ItemDataHelper; // types -interface DS4Weapon extends DS4ItemBase, DS4ItemPhysical, DS4ItemEquipable { +interface DS4WeaponDataData extends DS4ItemDataDataBase, DS4ItemDataDataPhysical, DS4ItemDataDataEquipable { attackType: "melee" | "ranged" | "meleeRanged"; weaponBonus: number; opponentDefense: number; } -export interface DS4Armor extends DS4ItemBase, DS4ItemPhysical, DS4ItemEquipable, DS4ItemProtective { +interface DS4ArmorDataData + extends DS4ItemDataDataBase, + DS4ItemDataDataPhysical, + DS4ItemDataDataEquipable, + DS4ItemDataDataProtective { armorMaterialType: "cloth" | "leather" | "chain" | "plate"; armorType: "body" | "helmet" | "vambrace" | "greaves" | "vambraceGreaves"; } -export interface DS4Talent extends DS4ItemBase { +interface DS4TalentDataData extends DS4ItemDataDataBase { rank: DS4TalentRank; } @@ -39,7 +57,7 @@ interface DS4TalentRank extends ModifiableData { max: number; } -interface DS4Spell extends DS4ItemBase, DS4ItemEquipable { +interface DS4SpellDataData extends DS4ItemDataDataBase, DS4ItemDataDataEquipable { spellType: "spellcasting" | "targetedSpellcasting"; bonus: string; spellCategory: @@ -59,37 +77,41 @@ interface DS4Spell extends DS4ItemBase, DS4ItemEquipable { scrollPrice: number; } -export interface DS4Shield extends DS4ItemBase, DS4ItemPhysical, DS4ItemEquipable, DS4ItemProtective {} -interface DS4Trinket extends DS4ItemBase, DS4ItemPhysical, DS4ItemEquipable {} -interface DS4Equipment extends DS4ItemBase, DS4ItemPhysical {} -type DS4RacialAbility = DS4ItemBase; -type DS4Language = DS4ItemBase; -type DS4Alphabet = DS4ItemBase; -interface DS4SpecialCreatureAbility extends DS4ItemBase { +interface DS4ShieldDataData + extends DS4ItemDataDataBase, + DS4ItemDataDataPhysical, + DS4ItemDataDataEquipable, + DS4ItemDataDataProtective {} +interface DS4TrinketDataData extends DS4ItemDataDataBase, DS4ItemDataDataPhysical, DS4ItemDataDataEquipable {} +interface DS4EquipmentDataData extends DS4ItemDataDataBase, DS4ItemDataDataPhysical {} +type DS4RacialAbilityDataData = DS4ItemDataDataBase; +type DS4LanguageDataData = DS4ItemDataDataBase; +type DS4AlphabetDataData = DS4ItemDataDataBase; +interface DS4SpecialCreatureAbilityDataData extends DS4ItemDataDataBase { experiencePoints: number; } // templates -interface DS4ItemBase { +interface DS4ItemDataDataBase { description: string; } -interface DS4ItemPhysical { +interface DS4ItemDataDataPhysical { quantity: number; price: number; availability: "hamlet" | "village" | "city" | "elves" | "dwarves" | "nowhere" | "unset"; storageLocation: string; } -export function isDS4ItemDataTypePhysical(input: DS4ItemDataType): boolean { +export function isDS4ItemDataTypePhysical(input: DS4ItemData["data"]): boolean { return "quantity" in input && "price" in input && "availability" in input && "storageLocation" in input; } -interface DS4ItemEquipable { +interface DS4ItemDataDataEquipable { equipped: boolean; } -interface DS4ItemProtective { +interface DS4ItemDataDataProtective { armorValue: number; } diff --git a/src/module/item/item.ts b/src/module/item/item.ts index 4944a12c..0226b5bb 100644 --- a/src/module/item/item.ts +++ b/src/module/item/item.ts @@ -1,4 +1,4 @@ -import { DS4ItemData, DS4Talent } from "./item-data"; +import { DS4ItemData } from "./item-data"; /** * Extend the basic Item with some very simple modifications. @@ -19,8 +19,8 @@ export class DS4Item extends Item { } prepareDerivedData(): void { - if (this.type === "talent") { - const data = this.data.data as DS4Talent; + if (this.data.type === "talent") { + const data = this.data.data; data.rank.total = data.rank.base + data.rank.mod; } } From 52c729c3fa184eb363ce1671333ce14ad0d98b48 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Fri, 5 Feb 2021 03:47:54 +0100 Subject: [PATCH 38/53] SImplify Dice configuration --- src/module/ds4.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/module/ds4.ts b/src/module/ds4.ts index 657a4603..be4543cd 100644 --- a/src/module/ds4.ts +++ b/src/module/ds4.ts @@ -33,11 +33,8 @@ Hooks.once("init", async function () { CONFIG.Item.typeLabels = DS4.i18n.itemTypes; // Configure Dice - CONFIG.Dice.types = [Die, DS4Check]; // TODO(types) fix upstream - CONFIG.Dice.terms = { - ...CONFIG.Dice.terms, - s: DS4Check, - }; + CONFIG.Dice.types.push(DS4Check); // TODO(types) fix upstream + CONFIG.Dice.terms.s = DS4Check; // Register system settings registerSystemSettings(); From 05bd1335ba2abcdec98a141c66a04c9548afd6be Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Fri, 5 Feb 2021 03:50:08 +0100 Subject: [PATCH 39/53] remove redundant cast --- src/module/actor/sheets/actor-sheet.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/module/actor/sheets/actor-sheet.ts b/src/module/actor/sheets/actor-sheet.ts index c9adc8fc..33287aa5 100644 --- a/src/module/actor/sheets/actor-sheet.ts +++ b/src/module/actor/sheets/actor-sheet.ts @@ -228,7 +228,7 @@ export class DS4ActorSheet extends ActorSheet { /** @override */ async _onDropItem(event: DragEvent, data: Parameters[0]): Promise { const item = ((await Item.fromDropData(data)) as unknown) as DS4Item; - if (item && !this.actor.canOwnItemType(item.data.type as ItemType)) { + if (item && !this.actor.canOwnItemType(item.data.type)) { ui.notifications.warn( game.i18n.format("DS4.WarningActorCannotOwnItem", { actorName: this.actor.name, From 5cb75a40017d50daab38d951d8b686c6a76aea03 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Fri, 5 Feb 2021 20:37:52 +0100 Subject: [PATCH 40/53] Update types --- package-lock.json | 2 +- src/module/ds4.ts | 2 +- src/module/rolls/check-factory.ts | 51 ++++++++++++++----------------- 3 files changed, 25 insertions(+), 30 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3ace79b2..81f1be4f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3119,7 +3119,7 @@ } }, "foundry-vtt-types": { - "version": "github:League-of-Foundry-Developers/foundry-vtt-types#dc5ff5a9c75cda3f4999603221275ed8d7d9212c", + "version": "github:League-of-Foundry-Developers/foundry-vtt-types#865f9522eb8b81e15f34f06793e2cbf09e48d601", "from": "github:League-of-Foundry-Developers/foundry-vtt-types#foundry-0.7.9", "dev": true, "requires": { diff --git a/src/module/ds4.ts b/src/module/ds4.ts index be4543cd..84414037 100644 --- a/src/module/ds4.ts +++ b/src/module/ds4.ts @@ -33,7 +33,7 @@ Hooks.once("init", async function () { CONFIG.Item.typeLabels = DS4.i18n.itemTypes; // Configure Dice - CONFIG.Dice.types.push(DS4Check); // TODO(types) fix upstream + CONFIG.Dice.types.push(DS4Check); CONFIG.Dice.terms.s = DS4Check; // Register system settings diff --git a/src/module/rolls/check-factory.ts b/src/module/rolls/check-factory.ts index b2da3534..95ee765b 100644 --- a/src/module/rolls/check-factory.ts +++ b/src/module/rolls/check-factory.ts @@ -131,37 +131,32 @@ async function askGmModifier( const renderedHtml = await renderTemplate(usedTemplate, templateData); const dialogPromise = new Promise((resolve) => { - new Dialog( - { - title: usedTitle, - content: renderedHtml, - buttons: { - ok: { - label: game.i18n.localize("DS4.RollDialogOkButton"), - callback: (html) => { - if (!("jquery" in html)) { - throw new Error( - game.i18n.format("DS4.ErrorUnexpectedHtmlType", { - exType: "JQuery", - realType: "HTMLElement", - }), - ); - } else { - const innerForm = html[0].querySelector("form"); - resolve(innerForm); - } - }, - icon: "", // TODO(types): Remove once https://github.com/League-of-Foundry-Developers/foundry-vtt-types/issues/266 is fixed - }, - cancel: { - label: game.i18n.localize("DS4.RollDialogCancelButton"), - icon: "", // TODO(types): Remove once https://github.com/League-of-Foundry-Developers/foundry-vtt-types/issues/266 is fixed + new Dialog({ + title: usedTitle, + content: renderedHtml, + buttons: { + ok: { + label: game.i18n.localize("DS4.RollDialogOkButton"), + callback: (html) => { + if (!("jquery" in html)) { + throw new Error( + game.i18n.format("DS4.ErrorUnexpectedHtmlType", { + exType: "JQuery", + realType: "HTMLElement", + }), + ); + } else { + const innerForm = html[0].querySelector("form"); + resolve(innerForm); + } }, }, - default: "ok", + cancel: { + label: game.i18n.localize("DS4.RollDialogCancelButton"), + }, }, - {}, // TODO(types): Remove once https://github.com/League-of-Foundry-Developers/foundry-vtt-types/issues/267 is resolved - ).render(true); + default: "ok", + }).render(true); }); const dialogForm = await dialogPromise; return parseDialogFormData(dialogForm); From 823c33142cd82036aa9e26486072576ae923ff50 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Sat, 6 Feb 2021 06:10:23 +0100 Subject: [PATCH 41/53] update types --- package-lock.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 81f1be4f..57e08d74 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3119,7 +3119,7 @@ } }, "foundry-vtt-types": { - "version": "github:League-of-Foundry-Developers/foundry-vtt-types#865f9522eb8b81e15f34f06793e2cbf09e48d601", + "version": "github:League-of-Foundry-Developers/foundry-vtt-types#840c6dd1198b60aa16bde28fc7173621612f033c", "from": "github:League-of-Foundry-Developers/foundry-vtt-types#foundry-0.7.9", "dev": true, "requires": { From f20d9b3143b594bf077ccf66e589fa2bc81da890 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Sat, 6 Feb 2021 21:46:04 +0100 Subject: [PATCH 42/53] Update types --- package-lock.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 57e08d74..e58e7904 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3119,7 +3119,7 @@ } }, "foundry-vtt-types": { - "version": "github:League-of-Foundry-Developers/foundry-vtt-types#840c6dd1198b60aa16bde28fc7173621612f033c", + "version": "github:League-of-Foundry-Developers/foundry-vtt-types#e17295657bcdf61775f3eaf86900be594e5cec57", "from": "github:League-of-Foundry-Developers/foundry-vtt-types#foundry-0.7.9", "dev": true, "requires": { From d7c617facb73da723bdd9deac56911a93e453d8c Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Sat, 6 Feb 2021 22:09:07 +0100 Subject: [PATCH 43/53] Switch to ES2020 --- tsconfig.json | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index 5f44cffe..f0f1205b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,10 +1,12 @@ { "compilerOptions": { - "target": "ES2017", - "lib": ["DOM", "ES6", "ES2017"], + "target": "ES2020", + "lib": ["DOM", "ES2020"], "types": ["foundry-vtt-types"], "esModuleInterop": true, - "moduleResolution": "node" + "moduleResolution": "node", + "forceConsistentCasingInFileNames": true, + "strict": false }, "include": ["src"] } From 98568de676b70aa230154ccfc3e413c902fea5f7 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Sun, 7 Feb 2021 11:15:37 +0100 Subject: [PATCH 44/53] Update types --- package-lock.json | 6 +++--- src/module/actor/sheets/actor-sheet.ts | 15 +++++++-------- src/module/item/item-sheet.ts | 5 ++--- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/package-lock.json b/package-lock.json index e58e7904..ad8c8a40 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3712,9 +3712,9 @@ "dev": true }, "uglify-js": { - "version": "3.12.6", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.12.6.tgz", - "integrity": "sha512-aqWHe3DfQmZUDGWBbabZ2eQnJlQd1fKlMUu7gV+MiTuDzdgDw31bI3wA2jLLsV/hNcDP26IfyEgSVoft5+0SVw==", + "version": "3.12.7", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.12.7.tgz", + "integrity": "sha512-SIZhkoh+U/wjW+BHGhVwE9nt8tWJspncloBcFapkpGRwNPqcH8pzX36BXe3TPBjzHWPMUZotpCigak/udWNr1Q==", "dev": true, "optional": true }, diff --git a/src/module/actor/sheets/actor-sheet.ts b/src/module/actor/sheets/actor-sheet.ts index 33287aa5..24983524 100644 --- a/src/module/actor/sheets/actor-sheet.ts +++ b/src/module/actor/sheets/actor-sheet.ts @@ -1,15 +1,14 @@ import { DS4 } from "../../config"; import { DS4Item } from "../../item/item"; -import { DS4ItemData, ItemType } from "../../item/item-data"; +import { DS4ItemData } from "../../item/item-data"; import { DS4Actor } from "../actor"; /** * Extend the basic ActorSheet with some very simple modifications - * @extends {ActorSheet} */ -// TODO(types): provide proper types for all generic parameters +// TODO(types): Remove first generic parameter once https://github.com/League-of-Foundry-Developers/foundry-vtt-types/pull/273 is merged export class DS4ActorSheet extends ActorSheet { - // TODO(types): Improve mergeObject in upstream so that it isn't necessary to provide all parameters + // TODO(types): Improve mergeObject in upstream so that it isn't necessary to provide all parameters (see https://github.com/League-of-Foundry-Developers/foundry-vtt-types/issues/272) /** @override */ static get defaultOptions(): BaseEntitySheet.Options { const superDefaultOptions = super.defaultOptions; @@ -99,7 +98,7 @@ export class DS4ActorSheet extends ActorSheet { /** * Handle creating a new Owned Item for the actor using initial data defined in the HTML dataset - * @param {JQuery.ClickEvent} event The originating click event + * @param event The originating click event * @private */ private _onItemCreate(event: JQuery.ClickEvent): Promise { @@ -125,7 +124,7 @@ export class DS4ActorSheet extends ActorSheet { * Handle changes to properties of an Owned Item from within character sheet. * Can currently properly bind: see getValue(). * Assumes the item property is given as the value of the HTML element property 'data-property'. - * @param {JQuery.ChangeEvent} ev The originating change event + * @param ev The originating change event * @private */ private _onItemChange(ev: JQuery.ChangeEvent): void { @@ -207,7 +206,7 @@ export class DS4ActorSheet extends ActorSheet { /** * Handle clickable rolls. - * @param {JQuery.ClickEvent} event The originating click event + * @param event The originating click event * @private */ private _onRoll(event: JQuery.ClickEvent): void { @@ -239,6 +238,6 @@ export class DS4ActorSheet extends ActorSheet { ); return false; } - return super["_onDropItem"](event, data); // TODO(types): Add _onDropItem to upstream + return super["_onDropItem"](event, data); // TODO(types): Add _onDropItem to upstream (fixed by https://github.com/League-of-Foundry-Developers/foundry-vtt-types/pull/273) } } diff --git a/src/module/item/item-sheet.ts b/src/module/item/item-sheet.ts index 970cefac..56223979 100644 --- a/src/module/item/item-sheet.ts +++ b/src/module/item/item-sheet.ts @@ -4,9 +4,8 @@ import { isDS4ItemDataTypePhysical } from "./item-data"; /** * Extend the basic ItemSheet with some very simple modifications - * @extends {ItemSheet} */ -// TODO(types): provide proper types for all generic parameters +// TODO(types): Remove first generic parameter once https://github.com/League-of-Foundry-Developers/foundry-vtt-types/pull/273 is merged export class DS4ItemSheet extends ItemSheet { /** @override */ static get defaultOptions(): BaseEntitySheet.Options { @@ -85,7 +84,7 @@ export class DS4ItemSheet extends ItemSheet { /** * Handle management of ActiveEffects. - * @param {Event} event The originating click event + * @param event The originating click event */ private async _onManageActiveEffect(event: JQuery.ClickEvent): Promise { event.preventDefault(); From d5db788c31f834da2a6cf1e9202c2dff3e04b26c Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Sun, 7 Feb 2021 11:51:36 +0100 Subject: [PATCH 45/53] Do some cleanup --- src/module/actor/actor.ts | 5 +- src/module/actor/sheets/actor-sheet.ts | 27 +++----- src/module/actor/sheets/character-sheet.ts | 3 + src/module/actor/sheets/creature-sheet.ts | 3 + src/module/common/utils.ts | 37 +++++++++++ src/module/config.ts | 2 +- src/module/ds4.ts | 6 +- src/module/item/item-sheet.ts | 14 ++--- src/module/item/item.ts | 10 +-- src/module/rolls/check-factory.ts | 6 +- src/module/rolls/roll-executor.ts | 22 +++---- src/module/rolls/roll-utils.ts | 63 ++++--------------- src/templates/actor/creature-sheet.hbs | 2 +- ...> special-creature-abilities-overview.hbs} | 0 14 files changed, 91 insertions(+), 109 deletions(-) create mode 100644 src/module/common/utils.ts rename src/templates/actor/partials/{special-creature-abilites-overview.hbs => special-creature-abilities-overview.hbs} (100%) diff --git a/src/module/actor/actor.ts b/src/module/actor/actor.ts index 47623d47..5fcf00a7 100644 --- a/src/module/actor/actor.ts +++ b/src/module/actor/actor.ts @@ -3,6 +3,9 @@ import { DS4Item } from "../item/item"; import { ItemType } from "../item/item-data"; import { DS4ActorData } from "./actor-data"; +/** + * The Actor class for DS4 + */ export class DS4Actor extends Actor { /** @override */ prepareDerivedData(): void { @@ -45,7 +48,7 @@ export class DS4Actor extends Actor { /** * Checks whether or not the given item type can be owned by the actor. - * @param itemType the item type to check + * @param itemType - The item type to check */ canOwnItemType(itemType: ItemType): boolean { return this.ownableItemTypes.includes(itemType); diff --git a/src/module/actor/sheets/actor-sheet.ts b/src/module/actor/sheets/actor-sheet.ts index 24983524..06977077 100644 --- a/src/module/actor/sheets/actor-sheet.ts +++ b/src/module/actor/sheets/actor-sheet.ts @@ -4,7 +4,7 @@ import { DS4ItemData } from "../../item/item-data"; import { DS4Actor } from "../actor"; /** - * Extend the basic ActorSheet with some very simple modifications + * The base Sheet class for all DS4 Actors */ // TODO(types): Remove first generic parameter once https://github.com/League-of-Foundry-Developers/foundry-vtt-types/pull/273 is merged export class DS4ActorSheet extends ActorSheet { @@ -43,13 +43,11 @@ export class DS4ActorSheet extends ActorSheet { return `${path}/${this.actor.data.type}-sheet.hbs`; } - /* -------------------------------------------- */ - /** * This method returns the data for the template of the actor sheet. * It explicitly adds the items of the object sorted by type in the * object itemsByType. - * @returns the data fed to the template of the actor sheet + * @returns The data fed to the template of the actor sheet */ getData(): ActorSheet.Data { const data = { @@ -62,8 +60,6 @@ export class DS4ActorSheet extends ActorSheet { return data; } - /* -------------------------------------------- */ - /** @override */ activateListeners(html: JQuery): void { super.activateListeners(html); @@ -94,14 +90,11 @@ export class DS4ActorSheet extends ActorSheet { html.find(".rollable").click(this._onRoll.bind(this)); } - /* -------------------------------------------- */ - /** * Handle creating a new Owned Item for the actor using initial data defined in the HTML dataset - * @param event The originating click event - * @private + * @param event - The originating click event */ - private _onItemCreate(event: JQuery.ClickEvent): Promise { + protected _onItemCreate(event: JQuery.ClickEvent): Promise { event.preventDefault(); const header = event.currentTarget; // Get the type of item to create. @@ -124,10 +117,9 @@ export class DS4ActorSheet extends ActorSheet { * Handle changes to properties of an Owned Item from within character sheet. * Can currently properly bind: see getValue(). * Assumes the item property is given as the value of the HTML element property 'data-property'. - * @param ev The originating change event - * @private + * @param ev - The originating change event */ - private _onItemChange(ev: JQuery.ChangeEvent): void { + protected _onItemChange(ev: JQuery.ChangeEvent): void { ev.preventDefault(); console.log("Current target:", $(ev.currentTarget).get(0)["name"]); const el: HTMLFormElement = $(ev.currentTarget).get(0); @@ -155,7 +147,7 @@ export class DS4ActorSheet extends ActorSheet { * - Checkbox: boolean * - Text input: string * - Number: number - * @param el the input element to collect the value of + * @param el - The input element to collect the value of */ private getValue(el: HTMLFormElement): boolean | string | number { // One needs to differentiate between e.g. checkboxes (value="on") and select boxes etc. @@ -206,10 +198,9 @@ export class DS4ActorSheet extends ActorSheet { /** * Handle clickable rolls. - * @param event The originating click event - * @private + * @param event - The originating click event */ - private _onRoll(event: JQuery.ClickEvent): void { + protected _onRoll(event: JQuery.ClickEvent): void { event.preventDefault(); const element = event.currentTarget; const dataset = element.dataset; diff --git a/src/module/actor/sheets/character-sheet.ts b/src/module/actor/sheets/character-sheet.ts index a7d5e337..2e077ce6 100644 --- a/src/module/actor/sheets/character-sheet.ts +++ b/src/module/actor/sheets/character-sheet.ts @@ -1,5 +1,8 @@ import { DS4ActorSheet } from "./actor-sheet"; +/** + * The Sheet class for DS4 Character Actors + */ export class DS4CharacterActorSheet extends DS4ActorSheet { /** @override */ static get defaultOptions(): BaseEntitySheet.Options { diff --git a/src/module/actor/sheets/creature-sheet.ts b/src/module/actor/sheets/creature-sheet.ts index 45ce614d..91af61d2 100644 --- a/src/module/actor/sheets/creature-sheet.ts +++ b/src/module/actor/sheets/creature-sheet.ts @@ -1,5 +1,8 @@ import { DS4ActorSheet } from "./actor-sheet"; +/** + * The Sheet class for DS4 Creature Actors + */ export class DS4CreatureActorSheet extends DS4ActorSheet { /** @override */ static get defaultOptions(): BaseEntitySheet.Options { diff --git a/src/module/common/utils.ts b/src/module/common/utils.ts new file mode 100644 index 00000000..df5fe8f3 --- /dev/null +++ b/src/module/common/utils.ts @@ -0,0 +1,37 @@ +/** + * Partition an array into two, following a predicate. + * @param input - The Array to split. + * @param predicate - The predicate by which to split. + * @returns A tuple of two arrays, the first one containing all elements from `input` that match the predicate, the second one containing those that do not. + */ +export function partition(input: Array, predicate: (v: T) => boolean): [T[], T[]] { + return input.reduce( + (p: [Array, Array], cur: T) => { + if (predicate(cur)) { + p[0].push(cur); + } else { + p[1].push(cur); + } + return p; + }, + [[], []], + ); +} + +/** + * Zips two Arrays to an array of pairs of elements with corresponding indices. Excessive elements are dropped. + * @param a1 - First array to zip. + * @param a2 - Second array to zip. + * + * @typeParam T - Type of elements contained in `a1`. + * @typeParam U - Type of elements contained in `a2`. + * + * @returns The array of pairs that had the same index in their source array. + */ +export function zip(a1: Array, a2: Array): Array<[T, U]> { + if (a1.length <= a2.length) { + return a1.map((e1, i) => [e1, a2[i]]); + } else { + return a2.map((e2, i) => [a1[i], e2]); + } +} diff --git a/src/module/config.ts b/src/module/config.ts index d023fc05..9233799e 100644 --- a/src/module/config.ts +++ b/src/module/config.ts @@ -76,7 +76,7 @@ export const DS4 = { }, /** - * Define the set of armor materials, used to determine if a characer may wear the armor without additional penalties + * Define the set of armor materials, used to determine if a character may wear the armor without additional penalties */ armorMaterialTypes: { cloth: "DS4.ArmorMaterialTypeCloth", diff --git a/src/module/ds4.ts b/src/module/ds4.ts index 84414037..7591960b 100644 --- a/src/module/ds4.ts +++ b/src/module/ds4.ts @@ -65,17 +65,13 @@ async function registerHandlebarsPartials() { "systems/ds4/templates/actor/partials/combat-values.hbs", "systems/ds4/templates/actor/partials/profile.hbs", "systems/ds4/templates/actor/partials/character-progression.hbs", - "systems/ds4/templates/actor/partials/special-creature-abilites-overview.hbs", + "systems/ds4/templates/actor/partials/special-creature-abilities-overview.hbs", "systems/ds4/templates/actor/partials/character-inventory.hbs", "systems/ds4/templates/actor/partials/creature-inventory.hbs", ]; return loadTemplates(templatePaths); } -/* -------------------------------------------- */ -/* Foundry VTT Setup */ -/* -------------------------------------------- */ - /** * This function runs after game data has been requested and loaded from the servers, so entities exist */ diff --git a/src/module/item/item-sheet.ts b/src/module/item/item-sheet.ts index 56223979..1d2b227c 100644 --- a/src/module/item/item-sheet.ts +++ b/src/module/item/item-sheet.ts @@ -3,7 +3,7 @@ import { DS4Item } from "./item"; import { isDS4ItemDataTypePhysical } from "./item-data"; /** - * Extend the basic ItemSheet with some very simple modifications + * The Sheet class for DS4 Items */ // TODO(types): Remove first generic parameter once https://github.com/League-of-Foundry-Developers/foundry-vtt-types/pull/273 is merged export class DS4ItemSheet extends ItemSheet { @@ -41,8 +41,6 @@ export class DS4ItemSheet extends ItemSheet { return `${path}/${this.item.data.type}-sheet.hbs`; } - /* -------------------------------------------- */ - /** @override */ getData(): ItemSheet.Data { const data = { @@ -56,8 +54,6 @@ export class DS4ItemSheet extends ItemSheet { return data; } - /* -------------------------------------------- */ - /** @override */ setPosition(options: Partial = {}): Application.Position { const position = super.setPosition(options); @@ -71,8 +67,6 @@ export class DS4ItemSheet extends ItemSheet { return position; } - /* -------------------------------------------- */ - /** @override */ activateListeners(html: JQuery): void { super.activateListeners(html); @@ -84,9 +78,9 @@ export class DS4ItemSheet extends ItemSheet { /** * Handle management of ActiveEffects. - * @param event The originating click event + * @param event - he originating click event */ - private async _onManageActiveEffect(event: JQuery.ClickEvent): Promise { + protected async _onManageActiveEffect(event: JQuery.ClickEvent): Promise { event.preventDefault(); if (this.item.isOwned) { @@ -110,7 +104,7 @@ export class DS4ItemSheet extends ItemSheet { /** * Create a new ActiveEffect for the item using default data. */ - private async _createActiveEffect(): Promise { + protected async _createActiveEffect(): Promise { const label = `New Effect`; const createData = { diff --git a/src/module/item/item.ts b/src/module/item/item.ts index 0226b5bb..34ce460f 100644 --- a/src/module/item/item.ts +++ b/src/module/item/item.ts @@ -1,21 +1,15 @@ import { DS4ItemData } from "./item-data"; /** - * Extend the basic Item with some very simple modifications. - * @extends {Item} + * The Item class for DS4 */ export class DS4Item extends Item { /** - * Augment the basic Item data model with additional dynamic data. + * @override */ prepareData(): void { super.prepareData(); this.prepareDerivedData(); - - // Get the Item's data - // const itemData = this.data; - // const actorData = this.actor ? this.actor.data : {}; - // const data = itemData.data; } prepareDerivedData(): void { diff --git a/src/module/rolls/check-factory.ts b/src/module/rolls/check-factory.ts index 95ee765b..d2919812 100644 --- a/src/module/rolls/check-factory.ts +++ b/src/module/rolls/check-factory.ts @@ -75,8 +75,8 @@ class CheckFactory { /** * Asks the user for all unknown/necessary information and passes them on to perform a roll. - * @param targetValue The Check Target Number ("CTN") - * @param options Options changing the behaviour of the roll and message. + * @param targetValue - The Check Target Number ("CTN") + * @param options - Options changing the behavior of the roll and message. */ export async function createCheckRoll( targetValue: number, @@ -164,7 +164,7 @@ async function askGmModifier( /** * Extracts Dialog data from the returned DOM element. - * @param formData The filed dialog + * @param formData - The filed dialog */ function parseDialogFormData(formData: HTMLFormElement): Partial { return { diff --git a/src/module/rolls/roll-executor.ts b/src/module/rolls/roll-executor.ts index c7e187b1..8801170d 100644 --- a/src/module/rolls/roll-executor.ts +++ b/src/module/rolls/roll-executor.ts @@ -4,9 +4,9 @@ import { calculateRollResult, isDiceSwapNecessary, isSlayingDiceRepetition, sepa /** * Performs a roll against a check target number, e.g. for usage in battle, but not for herbs. - * @param {number} checkTargetValue the final CTN, including all static modifiers. - * @param {Partial} rollOptions optional, final option override that affect the checks outcome, e.g. different values for crits or whether slaying dice are used. - * @param {Array} dice optional, pass already thrown dice that are used instead of rolling new ones. + * @param checkTargetValue - the final CTN, including all static modifiers. + * @param rollOptions - optional, final option override that affect the checks outcome, e.g. different values for crits or whether slaying dice are used. + * @param dice - optional, pass already thrown dice that are used instead of rolling new ones. */ export function ds4roll( checkTargetValue: number, @@ -27,11 +27,11 @@ export function ds4roll( * This is not intended for direct usage. Use * {@link ds4roll | the function that is not bound to an amount of Dice} instead. * - * @param {number} checkTargetValue - The target value to check against. - * @param {RollOptions} rollOptions - Options that affect the checks outcome, e.g. different values for crits or whether slaying dice are used. - * @param {Array} dice optional, pass already thrown dice that are used instead of rolling new ones. + * @param checkTargetValue - The target value to check against. + * @param rollOptions - Options that affect the checks outcome, e.g. different values for crits or whether slaying dice are used. + * @param dice - optional, pass already thrown dice that are used instead of rolling new ones. * - * @returns {RollResult} An object containing detailed information on the roll result. + * @returns An object containing detailed information on the roll result. */ export function rollCheckSingleDie( checkTargetValue: number, @@ -66,11 +66,11 @@ export function rollCheckSingleDie( * This is not intended for direct usage. Use * {@link ds4roll | the function that is not bound to an amount of Dice} instead. * - * @param {number} targetValue- - The target value to check against. - * @param {RollOptions} rollOptions - Options that affect the checks outcome, e.g. different values for crits or whether slaying dice are used. - * @param {Array} dice - Optional array of dice values to consider instead of rolling new ones. + * @param targetValue - The target value to check against. + * @param rollOptions - Options that affect the checks outcome, e.g. different values for crits or whether slaying dice are used. + * @param dice - Optional array of dice values to consider instead of rolling new ones. * - * @returns {RollResult} An object containing detailed information on the roll result. + * @returns An object containing detailed information on the roll result. */ export function rollCheckMultipleDice( targetValue: number, diff --git a/src/module/rolls/roll-utils.ts b/src/module/rolls/roll-utils.ts index a880a66d..a3b39b0b 100644 --- a/src/module/rolls/roll-utils.ts +++ b/src/module/rolls/roll-utils.ts @@ -1,3 +1,4 @@ +import { partition, zip } from "../common/utils"; import { RollOptions } from "./roll-data"; /** @@ -8,9 +9,9 @@ import { RollOptions } from "./roll-data"; * @private_remarks * This uses an internal implementation of a `partition` method. Don't let typescript fool you, it will tell you that a partition method is available for Arrays, but that one's imported globally from foundry's declarations and not available during the test stage! * - * @param {Array} dice - The dice values. - * @param {RollOptions} usedOptions - Options that affect the check's behaviour. - * @returns {[Array, Array]} A tuple containing two arrays of dice values, the first one containing all critical hits, the second one containing all others. Both arrays are sorted descendingby value. + * @param dice - The dice values. + * @param usedOptions - Options that affect the check's behavior. + * @returns A tuple containing two arrays of dice values, the first one containing all critical hits, the second one containing all others. Both arrays are sorted descending by value. */ export function separateCriticalHits(dice: Array, usedOptions: RollOptions): CritsAndNonCrits { const [critSuccesses, otherRolls] = partition(dice, (v: number) => { @@ -25,40 +26,19 @@ export function separateCriticalHits(dice: Array, usedOptions: RollOptio */ type CritsAndNonCrits = [Array, Array]; -/** - * Partition an array into two, following a predicate. - * @param {Array} input The Array to split. - * @param {(T) => boolean} predicate The predicate by which to split. - * @returns A tuple of two arrays, the first one containing all elements from `input` that matched the predicate, the second one containing those that don't. - */ -// TODO: Move to generic utils method? -function partition(input: Array, predicate: (v: T) => boolean) { - return input.reduce( - (p: [Array, Array], cur: T) => { - if (predicate(cur)) { - p[0].push(cur); - } else { - p[1].push(cur); - } - return p; - }, - [[], []], - ); -} - /** * Calculates if a critical success should be moved to the last position in order to maximize the check's result. * * @example * With regular dice rolling rules and a check target number of 31, the two dice 1 and 19 can get to a check result of 30. * This method would be called as follows: - * ``` + * ```ts * isDiceSwapNecessary([[1], [19]], 11) * ``` * - * @param {[Array, Array]} critsAndNonCrits the dice values thrown. It is assumed that both critical successes and other rolls are sorted descending. - * @param {number} remainingTargetValue the target value for the last dice, that is the only one that can be less than 20. - * @returns {boolean} Bool indicating whether a critical success has to be used as the last dice. + * @param critsAndNonCrits - The dice values thrown. It is assumed that both critical successes and other rolls are sorted descending. + * @param remainingTargetValue - The target value for the last dice, that is the only one that can be less than 20. + * @returns Bool indicating whether a critical success has to be used as the last dice. */ export function isDiceSwapNecessary( [critSuccesses, otherRolls]: CritsAndNonCrits, @@ -81,7 +61,7 @@ export function isDiceSwapNecessary( * * @internal * - * @param {RollOptions} opts the roll options to check against + * @param opts - The roll options to check against */ export function isSlayingDiceRepetition(opts: RollOptions): boolean { return opts.useSlayingDice && opts.slayingDiceRepetition; @@ -92,9 +72,9 @@ export function isSlayingDiceRepetition(opts: RollOptions): boolean { * * @internal * - * @param assignedRollResults The dice values in the order of usage. - * @param remainderTargetValue Target value for the last dice (the only one differing from `20`). - * @param rollOptions Config object containing options that change the way dice results are handled. + * @param assignedRollResults - The dice values in the order of usage. + * @param remainderTargetValue - Target value for the last dice (the only one differing from `20`). + * @param rollOptions - Config object containing options that change the way dice results are handled. * * @returns {number} The total check value. */ @@ -118,22 +98,3 @@ export function calculateRollResult( .map(([v]) => v) .reduce((a, b) => a + b); } - -// TODO: Move to generic utils method? -/** - * Zips two Arrays to an array of pairs of elements with corresponding indices. Excessive elements are dropped. - * @param {Array} a1 First array to zip. - * @param {Array} a2 Second array to zip. - * - * @typeParam T - Type of elements contained in `a1`. - * @typeParam U - Type of elements contained in `a2`. - * - * @returns {Array<[T,U]>} The array of pairs that had the same index in their source array. - */ -function zip(a1: Array, a2: Array): Array<[T, U]> { - if (a1.length <= a2.length) { - return a1.map((e1, i) => [e1, a2[i]]); - } else { - return a2.map((e2, i) => [a1[i], e2]); - } -} diff --git a/src/templates/actor/creature-sheet.hbs b/src/templates/actor/creature-sheet.hbs index 424dbcc2..c34a142d 100644 --- a/src/templates/actor/creature-sheet.hbs +++ b/src/templates/actor/creature-sheet.hbs @@ -64,7 +64,7 @@ {{> systems/ds4/templates/actor/partials/creature-inventory.hbs}} {{!-- Special Creature Abilities Tab --}} - {{> systems/ds4/templates/actor/partials/special-creature-abilites-overview.hbs}} + {{> systems/ds4/templates/actor/partials/special-creature-abilities-overview.hbs}} {{!-- Spells Tab --}} {{> systems/ds4/templates/actor/partials/spells-overview.hbs}} diff --git a/src/templates/actor/partials/special-creature-abilites-overview.hbs b/src/templates/actor/partials/special-creature-abilities-overview.hbs similarity index 100% rename from src/templates/actor/partials/special-creature-abilites-overview.hbs rename to src/templates/actor/partials/special-creature-abilities-overview.hbs From f64e459cd29fb4c99a91069ad348f0189cbb5017 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Sun, 7 Feb 2021 12:16:48 +0100 Subject: [PATCH 46/53] Update types --- package-lock.json | 2 +- src/module/actor/sheets/actor-sheet.ts | 13 ++++++++----- src/module/item/item-sheet.ts | 5 ++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index ad8c8a40..dcac6663 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3119,7 +3119,7 @@ } }, "foundry-vtt-types": { - "version": "github:League-of-Foundry-Developers/foundry-vtt-types#e17295657bcdf61775f3eaf86900be594e5cec57", + "version": "github:League-of-Foundry-Developers/foundry-vtt-types#32d849fd2afa4e88319c0105c989cec62bb888c2", "from": "github:League-of-Foundry-Developers/foundry-vtt-types#foundry-0.7.9", "dev": true, "requires": { diff --git a/src/module/actor/sheets/actor-sheet.ts b/src/module/actor/sheets/actor-sheet.ts index 06977077..e0308546 100644 --- a/src/module/actor/sheets/actor-sheet.ts +++ b/src/module/actor/sheets/actor-sheet.ts @@ -2,12 +2,12 @@ import { DS4 } from "../../config"; import { DS4Item } from "../../item/item"; import { DS4ItemData } from "../../item/item-data"; import { DS4Actor } from "../actor"; +import { DS4ActorData } from "../actor-data"; /** * The base Sheet class for all DS4 Actors */ -// TODO(types): Remove first generic parameter once https://github.com/League-of-Foundry-Developers/foundry-vtt-types/pull/273 is merged -export class DS4ActorSheet extends ActorSheet { +export class DS4ActorSheet extends ActorSheet { // TODO(types): Improve mergeObject in upstream so that it isn't necessary to provide all parameters (see https://github.com/League-of-Foundry-Developers/foundry-vtt-types/issues/272) /** @override */ static get defaultOptions(): BaseEntitySheet.Options { @@ -49,7 +49,7 @@ export class DS4ActorSheet extends ActorSheet { * object itemsByType. * @returns The data fed to the template of the actor sheet */ - getData(): ActorSheet.Data { + getData(): ActorSheet.Data | Promise> { const data = { ...super.getData(), // Add the localization config to the data: @@ -216,7 +216,10 @@ export class DS4ActorSheet extends ActorSheet { } /** @override */ - async _onDropItem(event: DragEvent, data: Parameters[0]): Promise { + protected async _onDropItem( + event: DragEvent, + data: { type: "Item" } & (DeepPartial> | { pack: string } | { id: string }), + ): Promise> { const item = ((await Item.fromDropData(data)) as unknown) as DS4Item; if (item && !this.actor.canOwnItemType(item.data.type)) { ui.notifications.warn( @@ -229,6 +232,6 @@ export class DS4ActorSheet extends ActorSheet { ); return false; } - return super["_onDropItem"](event, data); // TODO(types): Add _onDropItem to upstream (fixed by https://github.com/League-of-Foundry-Developers/foundry-vtt-types/pull/273) + return super._onDropItem(event, data); } } diff --git a/src/module/item/item-sheet.ts b/src/module/item/item-sheet.ts index 1d2b227c..5afc372d 100644 --- a/src/module/item/item-sheet.ts +++ b/src/module/item/item-sheet.ts @@ -5,8 +5,7 @@ import { isDS4ItemDataTypePhysical } from "./item-data"; /** * The Sheet class for DS4 Items */ -// TODO(types): Remove first generic parameter once https://github.com/League-of-Foundry-Developers/foundry-vtt-types/pull/273 is merged -export class DS4ItemSheet extends ItemSheet { +export class DS4ItemSheet extends ItemSheet { /** @override */ static get defaultOptions(): BaseEntitySheet.Options { const superDefaultOptions = super.defaultOptions; @@ -42,7 +41,7 @@ export class DS4ItemSheet extends ItemSheet { } /** @override */ - getData(): ItemSheet.Data { + getData(): ItemSheet.Data | Promise> { const data = { ...super.getData(), config: DS4, From 8e8aa4caee2d4a9558f0185e812f957ae551fdf5 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Sun, 7 Feb 2021 12:23:20 +0100 Subject: [PATCH 47/53] Add icons to check roll dialog buttons --- src/module/rolls/check-factory.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/module/rolls/check-factory.ts b/src/module/rolls/check-factory.ts index d2919812..21291e57 100644 --- a/src/module/rolls/check-factory.ts +++ b/src/module/rolls/check-factory.ts @@ -136,6 +136,7 @@ async function askGmModifier( content: renderedHtml, buttons: { ok: { + icon: '', label: game.i18n.localize("DS4.RollDialogOkButton"), callback: (html) => { if (!("jquery" in html)) { @@ -152,6 +153,7 @@ async function askGmModifier( }, }, cancel: { + icon: '', label: game.i18n.localize("DS4.RollDialogCancelButton"), }, }, From dac37eeaa1cdb71b2c2c8c18e10b0255ab9c0246 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Sun, 7 Feb 2021 12:29:15 +0100 Subject: [PATCH 48/53] Remove unused import --- src/module/actor/sheets/actor-sheet.ts | 1 - src/module/ds4.ts | 8 -------- 2 files changed, 9 deletions(-) diff --git a/src/module/actor/sheets/actor-sheet.ts b/src/module/actor/sheets/actor-sheet.ts index e0308546..8d373def 100644 --- a/src/module/actor/sheets/actor-sheet.ts +++ b/src/module/actor/sheets/actor-sheet.ts @@ -2,7 +2,6 @@ import { DS4 } from "../../config"; import { DS4Item } from "../../item/item"; import { DS4ItemData } from "../../item/item-data"; import { DS4Actor } from "../actor"; -import { DS4ActorData } from "../actor-data"; /** * The base Sheet class for all DS4 Actors diff --git a/src/module/ds4.ts b/src/module/ds4.ts index 7591960b..2f825cfc 100644 --- a/src/module/ds4.ts +++ b/src/module/ds4.ts @@ -1,4 +1,3 @@ -// Import Modules import { DS4Actor } from "./actor/actor"; import { DS4Item } from "./item/item"; import { DS4ItemSheet } from "./item/item-sheet"; @@ -21,25 +20,19 @@ Hooks.once("init", async function () { migration, }; - // Record configuration CONFIG.DS4 = DS4; - // Define custom Entity classes CONFIG.Actor.entityClass = DS4Actor; CONFIG.Item.entityClass = DS4Item; - // Define localized type labels CONFIG.Actor.typeLabels = DS4.i18n.actorTypes; CONFIG.Item.typeLabels = DS4.i18n.itemTypes; - // Configure Dice CONFIG.Dice.types.push(DS4Check); CONFIG.Dice.terms.s = DS4Check; - // Register system settings registerSystemSettings(); - // Register sheet application classes Actors.unregisterSheet("core", ActorSheet); Actors.registerSheet("ds4", DS4CharacterActorSheet, { types: ["character"], makeDefault: true }); Actors.registerSheet("ds4", DS4CreatureActorSheet, { types: ["creature"], makeDefault: true }); @@ -76,7 +69,6 @@ async function registerHandlebarsPartials() { * This function runs after game data has been requested and loaded from the servers, so entities exist */ Hooks.once("setup", function () { - // Exclude some from sorting where the default order matters const noSort = ["attributes", "traits", "combatValues", "creatureSizeCategories"]; // Localize and sort CONFIG objects From bc0c72632907fdd405d16b75b7da9d0642f4f120 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Sun, 7 Feb 2021 12:38:45 +0100 Subject: [PATCH 49/53] Update dependencies --- package-lock.json | 246 +++++++++++++++++++++++++++++----------------- package.json | 20 ++-- 2 files changed, 166 insertions(+), 100 deletions(-) diff --git a/package-lock.json b/package-lock.json index dcac6663..2894318b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "test", + "name": "dungeonslayers4", "version": "0.2.1", "lockfileVersion": 1, "requires": true, @@ -503,9 +503,9 @@ "dev": true }, "@types/jasmine": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/@types/jasmine/-/jasmine-3.6.2.tgz", - "integrity": "sha512-AzfesNFLvOs6Q1mHzIsVJXSeUnqVh4ZHG8ngygKJfbkcSLwzrBVm/LKa+mR8KrOfnWtUL47112gde1MC0IXqpQ==", + "version": "3.6.3", + "resolved": "https://registry.npmjs.org/@types/jasmine/-/jasmine-3.6.3.tgz", + "integrity": "sha512-5QKAG8WfC9XrOgYLXPrxv1G2IIUE6zDyzTWamhNWJO0LqPRUbZ0q0zGHDhDJ7MpFloUuyME/jpBIdPjq3/P3jA==", "dev": true }, "@types/jquery": { @@ -518,9 +518,9 @@ } }, "@types/json-schema": { - "version": "7.0.6", - "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.6.tgz", - "integrity": "sha512-3c+yGKvVP5Y9TYBEibGNR+kLtijnj7mYrXRg+WpFb2X9xm04g/DXYkfg4hmzJQosc9snFNUPkbYIhu+KAm6jJw==", + "version": "7.0.7", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.7.tgz", + "integrity": "sha512-cxWFQVseBm6O9Gbw1IWb8r6OS4OhSt3hPZLkFApLjM8TEXROBuQGLAH2i2gZpcXdLBIrpXuTDhH7Vbm1iXmNGA==", "dev": true }, "@types/node": { @@ -557,13 +557,13 @@ } }, "@typescript-eslint/eslint-plugin": { - "version": "4.14.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.14.0.tgz", - "integrity": "sha512-IJ5e2W7uFNfg4qh9eHkHRUCbgZ8VKtGwD07kannJvM5t/GU8P8+24NX8gi3Hf5jST5oWPY8kyV1s/WtfiZ4+Ww==", + "version": "4.14.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.14.2.tgz", + "integrity": "sha512-uMGfG7GFYK/nYutK/iqYJv6K/Xuog/vrRRZX9aEP4Zv1jsYXuvFUMDFLhUnc8WFv3D2R5QhNQL3VYKmvLS5zsQ==", "dev": true, "requires": { - "@typescript-eslint/experimental-utils": "4.14.0", - "@typescript-eslint/scope-manager": "4.14.0", + "@typescript-eslint/experimental-utils": "4.14.2", + "@typescript-eslint/scope-manager": "4.14.2", "debug": "^4.1.1", "functional-red-black-tree": "^1.0.1", "lodash": "^4.17.15", @@ -614,28 +614,28 @@ } }, "@typescript-eslint/experimental-utils": { - "version": "4.14.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.14.0.tgz", - "integrity": "sha512-6i6eAoiPlXMKRbXzvoQD5Yn9L7k9ezzGRvzC/x1V3650rUk3c3AOjQyGYyF9BDxQQDK2ElmKOZRD0CbtdkMzQQ==", + "version": "4.14.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.14.2.tgz", + "integrity": "sha512-mV9pmET4C2y2WlyHmD+Iun8SAEqkLahHGBkGqDVslHkmoj3VnxnGP4ANlwuxxfq1BsKdl/MPieDbohCEQgKrwA==", "dev": true, "requires": { "@types/json-schema": "^7.0.3", - "@typescript-eslint/scope-manager": "4.14.0", - "@typescript-eslint/types": "4.14.0", - "@typescript-eslint/typescript-estree": "4.14.0", + "@typescript-eslint/scope-manager": "4.14.2", + "@typescript-eslint/types": "4.14.2", + "@typescript-eslint/typescript-estree": "4.14.2", "eslint-scope": "^5.0.0", "eslint-utils": "^2.0.0" } }, "@typescript-eslint/parser": { - "version": "4.14.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.14.0.tgz", - "integrity": "sha512-sUDeuCjBU+ZF3Lzw0hphTyScmDDJ5QVkyE21pRoBo8iDl7WBtVFS+WDN3blY1CH3SBt7EmYCw6wfmJjF0l/uYg==", + "version": "4.14.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.14.2.tgz", + "integrity": "sha512-ipqSP6EuUsMu3E10EZIApOJgWSpcNXeKZaFeNKQyzqxnQl8eQCbV+TSNsl+s2GViX2d18m1rq3CWgnpOxDPgHg==", "dev": true, "requires": { - "@typescript-eslint/scope-manager": "4.14.0", - "@typescript-eslint/types": "4.14.0", - "@typescript-eslint/typescript-estree": "4.14.0", + "@typescript-eslint/scope-manager": "4.14.2", + "@typescript-eslint/types": "4.14.2", + "@typescript-eslint/typescript-estree": "4.14.2", "debug": "^4.1.1" }, "dependencies": { @@ -657,29 +657,29 @@ } }, "@typescript-eslint/scope-manager": { - "version": "4.14.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.14.0.tgz", - "integrity": "sha512-/J+LlRMdbPh4RdL4hfP1eCwHN5bAhFAGOTsvE6SxsrM/47XQiPSgF5MDgLyp/i9kbZV9Lx80DW0OpPkzL+uf8Q==", + "version": "4.14.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.14.2.tgz", + "integrity": "sha512-cuV9wMrzKm6yIuV48aTPfIeqErt5xceTheAgk70N1V4/2Ecj+fhl34iro/vIssJlb7XtzcaD07hWk7Jk0nKghg==", "dev": true, "requires": { - "@typescript-eslint/types": "4.14.0", - "@typescript-eslint/visitor-keys": "4.14.0" + "@typescript-eslint/types": "4.14.2", + "@typescript-eslint/visitor-keys": "4.14.2" } }, "@typescript-eslint/types": { - "version": "4.14.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.14.0.tgz", - "integrity": "sha512-VsQE4VvpldHrTFuVPY1ZnHn/Txw6cZGjL48e+iBxTi2ksa9DmebKjAeFmTVAYoSkTk7gjA7UqJ7pIsyifTsI4A==", + "version": "4.14.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.14.2.tgz", + "integrity": "sha512-LltxawRW6wXy4Gck6ZKlBD05tCHQUj4KLn4iR69IyRiDHX3d3NCAhO+ix5OR2Q+q9bjCrHE/HKt+riZkd1At8Q==", "dev": true }, "@typescript-eslint/typescript-estree": { - "version": "4.14.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.14.0.tgz", - "integrity": "sha512-wRjZ5qLao+bvS2F7pX4qi2oLcOONIB+ru8RGBieDptq/SudYwshveORwCVU4/yMAd4GK7Fsf8Uq1tjV838erag==", + "version": "4.14.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.14.2.tgz", + "integrity": "sha512-ESiFl8afXxt1dNj8ENEZT12p+jl9PqRur+Y19m0Z/SPikGL6rqq4e7Me60SU9a2M28uz48/8yct97VQYaGl0Vg==", "dev": true, "requires": { - "@typescript-eslint/types": "4.14.0", - "@typescript-eslint/visitor-keys": "4.14.0", + "@typescript-eslint/types": "4.14.2", + "@typescript-eslint/visitor-keys": "4.14.2", "debug": "^4.1.1", "globby": "^11.0.1", "is-glob": "^4.0.1", @@ -730,12 +730,12 @@ } }, "@typescript-eslint/visitor-keys": { - "version": "4.14.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.14.0.tgz", - "integrity": "sha512-MeHHzUyRI50DuiPgV9+LxcM52FCJFYjJiWHtXlbyC27b80mfOwKeiKI+MHOTEpcpfmoPFm/vvQS88bYIx6PZTA==", + "version": "4.14.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.14.2.tgz", + "integrity": "sha512-KBB+xLBxnBdTENs/rUgeUKO0UkPBRs2vD09oMRRIkj5BEN8PX1ToXV532desXfpQnZsYTyLLviS7JrPhdL154w==", "dev": true, "requires": { - "@typescript-eslint/types": "4.14.0", + "@typescript-eslint/types": "4.14.2", "eslint-visitor-keys": "^2.0.0" } }, @@ -2365,9 +2365,9 @@ "dev": true }, "eslint": { - "version": "7.18.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.18.0.tgz", - "integrity": "sha512-fbgTiE8BfUJZuBeq2Yi7J3RB3WGUQ9PNuNbmgi6jt9Iv8qrkxfy19Ds3OpL1Pm7zg3BtTVhvcUZbIRQ0wmSjAQ==", + "version": "7.19.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.19.0.tgz", + "integrity": "sha512-CGlMgJY56JZ9ZSYhJuhow61lMPPjUzWmChFya71Z/jilVos7mR/jPgaEfVGgMBY5DshbKdG8Ezb8FDCHcoMEMg==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", @@ -2501,9 +2501,9 @@ } }, "eslint-config-prettier": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-7.1.0.tgz", - "integrity": "sha512-9sm5/PxaFG7qNJvJzTROMM1Bk1ozXVTKI0buKOyb0Bsr1hrwi0H/TzxF/COtf1uxikIK8SwhX7K6zg78jAzbeA==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-7.2.0.tgz", + "integrity": "sha512-rV4Qu0C3nfJKPOAhFujFxB7RMP+URFyQqqOZW9DMRD7ZDTFyjaIlETU3xzHELt++4ugC0+Jm084HQYkkJe+Ivg==", "dev": true }, "eslint-plugin-prettier": { @@ -2574,9 +2574,9 @@ "dev": true }, "esquery": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.3.1.tgz", - "integrity": "sha512-olpvt9QG0vniUBZspVRN6lwB7hOZoTRtT+jzR+tS4ffYx2mzbw+z0XCOk44aaLYKApNX5nMm+E+P6o25ip/DHQ==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz", + "integrity": "sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==", "dev": true, "requires": { "estraverse": "^5.1.0" @@ -2934,9 +2934,9 @@ "dev": true }, "fastq": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.10.0.tgz", - "integrity": "sha512-NL2Qc5L3iQEsyYzweq7qfgy5OtXCmGzGvhElGEd/SoFWEMOEczNh5s5ocaF01HDetxz+p8ecjNPA6cZxxIHmzA==", + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.10.1.tgz", + "integrity": "sha512-AWuv6Ery3pM+dY7LYS8YIaCiQvUaos9OB1RyNgaOWnaX+Tik7Onvcsf8x8c+YtDeT0maYLniBip2hox5KtEXXA==", "dev": true, "requires": { "reusify": "^1.0.4" @@ -3071,9 +3071,9 @@ } }, "flatted": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.1.0.tgz", - "integrity": "sha512-tW+UkmtNg/jv9CSofAKvgVcO7c2URjhTdW1ZTkcAritblu8tajiYy7YisnIflEwtKssCtOxpnBRoCB7iap0/TA==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.1.1.tgz", + "integrity": "sha512-zAoAQiudy+r5SvnSw3KJy5os/oRJYHzrzja/tBDqrZtNhUw8bt6y8OBzMWcjWr+8liV8Eb6yOhw8WZ7VFZ5ZzA==", "dev": true }, "flush-write-stream": { @@ -3158,15 +3158,15 @@ "dev": true }, "fs-extra": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.0.1.tgz", - "integrity": "sha512-h2iAoN838FqAFJY2/qVpzFXy+EBxfVE220PalAqQLDVsFOHLJrZvut5puAbCdNv6WJk+B8ihI+k0c7JK5erwqQ==", + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz", + "integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==", "dev": true, "requires": { "at-least-node": "^1.0.0", "graceful-fs": "^4.2.0", "jsonfile": "^6.0.1", - "universalify": "^1.0.0" + "universalify": "^2.0.0" } }, "fs-mkdirp-stream": { @@ -4244,9 +4244,9 @@ "dev": true }, "jasmine": { - "version": "3.6.3", - "resolved": "https://registry.npmjs.org/jasmine/-/jasmine-3.6.3.tgz", - "integrity": "sha512-Th91zHsbsALWjDUIiU5d/W5zaYQsZFMPTdeNmi8GivZPmAaUAK8MblSG3yQI4VMGC/abF2us7ex60NH1AAIMTA==", + "version": "3.6.4", + "resolved": "https://registry.npmjs.org/jasmine/-/jasmine-3.6.4.tgz", + "integrity": "sha512-hIeOou6y0BgCOKYgXYveQvlY+PTHgDPajFf+vLCYbMTQ+VjAP9+EQv0nuC9+gyCAAWISRFauB1XUb9kFuOKtcQ==", "dev": true, "requires": { "glob": "^7.1.6", @@ -4350,14 +4350,6 @@ "requires": { "graceful-fs": "^4.1.6", "universalify": "^2.0.0" - }, - "dependencies": { - "universalify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", - "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", - "dev": true - } } }, "jsprim": { @@ -4486,9 +4478,9 @@ "dev": true }, "lint-staged": { - "version": "10.5.3", - "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-10.5.3.tgz", - "integrity": "sha512-TanwFfuqUBLufxCc3RUtFEkFraSPNR3WzWcGF39R3f2J7S9+iF9W0KTVLfSy09lYGmZS5NDCxjNvhGMSJyFCWg==", + "version": "10.5.4", + "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-10.5.4.tgz", + "integrity": "sha512-EechC3DdFic/TdOPgj/RB3FicqE6932LTHCUm0Y2fsD9KGlLB+RwJl2q1IYBIvEsKzDOgn0D4gll+YxG5RsrKg==", "dev": true, "requires": { "chalk": "^4.1.0", @@ -4569,9 +4561,9 @@ } }, "listr2": { - "version": "3.2.3", - "resolved": "https://registry.npmjs.org/listr2/-/listr2-3.2.3.tgz", - "integrity": "sha512-vUb80S2dSUi8YxXahO8/I/s29GqnOL8ozgHVLjfWQXa03BNEeS1TpBLjh2ruaqq5ufx46BRGvfymdBSuoXET5w==", + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/listr2/-/listr2-3.3.1.tgz", + "integrity": "sha512-8Zoxe7s/8nNr4bJ8bdAduHD8uJce+exmMmUWTXlq0WuUdffnH3muisHPHPFtW2vvOfohIsq7FGCaguUxN/h3Iw==", "dev": true, "requires": { "chalk": "^4.1.0", @@ -4581,14 +4573,88 @@ "log-update": "^4.0.0", "p-map": "^4.0.0", "rxjs": "^6.6.3", - "through": "^2.3.8" + "through": "^2.3.8", + "wrap-ansi": "^7.0.0" }, "dependencies": { + "ansi-regex": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", + "dev": true + }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, "indent-string": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", "dev": true + }, + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true + }, + "string-width": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz", + "integrity": "sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg==", + "dev": true, + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.0" + } + }, + "strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.0" + } + }, + "wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "requires": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + } } } }, @@ -6204,9 +6270,9 @@ "dev": true }, "sass": { - "version": "1.32.4", - "resolved": "https://registry.npmjs.org/sass/-/sass-1.32.4.tgz", - "integrity": "sha512-N0BT0PI/t3+gD8jKa83zJJUb7ssfQnRRfqN+GIErokW6U4guBpfYl8qYB+OFLEho+QvnV5ZH1R9qhUC/Z2Ch9w==", + "version": "1.32.6", + "resolved": "https://registry.npmjs.org/sass/-/sass-1.32.6.tgz", + "integrity": "sha512-1bcDHDcSqeFtMr0JXI3xc/CXX6c4p0wHHivJdru8W7waM7a1WjKMm4m/Z5sY7CbVw4Whi2Chpcw6DFfSWwGLzQ==", "dev": true, "requires": { "chokidar": ">=2.0.0 <4.0.0" @@ -6959,9 +7025,9 @@ }, "dependencies": { "ajv": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-7.0.3.tgz", - "integrity": "sha512-R50QRlXSxqXcQP5SvKUrw8VZeypvo12i2IX0EeR5PiZ7bEKeHWgzgo264LDadUsCU42lTJVhFikTqJwNeH34gQ==", + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-7.0.4.tgz", + "integrity": "sha512-xzzzaqgEQfmuhbhAoqjJ8T/1okb6gAzXn/eQRNpAN1AEUoHJTNF9xCDRTtf/s3SKldtZfa+RJeTs+BQq+eZ/sw==", "dev": true, "requires": { "fast-deep-equal": "^3.1.1", @@ -7198,9 +7264,9 @@ "dev": true }, "tsutils": { - "version": "3.19.1", - "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.19.1.tgz", - "integrity": "sha512-GEdoBf5XI324lu7ycad7s6laADfnAqCw6wLGI+knxvw9vsIYBaJfYdmeCEG3FMMUiSm3OGgNb+m6utsWf5h9Vw==", + "version": "3.20.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.20.0.tgz", + "integrity": "sha512-RYbuQuvkhuqVeXweWT3tJLKOEJ/UUw9GjNEZGWdrLLlM+611o1gwLHBpxoFJKKl25fLprp2eVthtKs5JOrNeXg==", "dev": true, "requires": { "tslib": "^1.8.1" @@ -7356,9 +7422,9 @@ } }, "universalify": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-1.0.0.tgz", - "integrity": "sha512-rb6X1W158d7pRQBg5gkR8uPaSfiids68LTJQYOtEUhoJUWBdaQHsuT/EUduxXYxcrt4r5PJ4fuHW1MHT6p0qug==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", + "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", "dev": true }, "unset-value": { diff --git a/package.json b/package.json index 81c22eaa..11d8f691 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "private": true, - "name": "test", + "name": "dungeonslayers4", "description": "An implementation of the Dungeonslayers 4 game system for Foundry Virtual Tabletop.", "version": "0.2.1", "license": "MIT", @@ -45,28 +45,28 @@ }, "devDependencies": { "@types/fs-extra": "^9.0.6", - "@types/jasmine": "^3.6.2", - "@typescript-eslint/eslint-plugin": "^4.14.0", - "@typescript-eslint/parser": "^4.14.0", + "@types/jasmine": "^3.6.3", + "@typescript-eslint/eslint-plugin": "^4.14.2", + "@typescript-eslint/parser": "^4.14.2", "archiver": "^5.2.0", "chalk": "^4.1.0", - "eslint": "^7.18.0", - "eslint-config-prettier": "^7.1.0", + "eslint": "^7.19.0", + "eslint-config-prettier": "^7.2.0", "eslint-plugin-prettier": "^3.3.1", "foundry-vtt-types": "github:League-of-Foundry-Developers/foundry-vtt-types#foundry-0.7.9", - "fs-extra": "^9.0.1", + "fs-extra": "^9.1.0", "gulp": "^4.0.2", "gulp-git": "^2.10.1", "gulp-less": "^4.0.1", "gulp-sass": "^4.1.0", "gulp-typescript": "^6.0.0-alpha.1", "husky": "^4.3.8", - "jasmine": "^3.6.3", + "jasmine": "^3.6.4", "jasmine-xml-reporter": "^1.2.1", "json-stringify-pretty-compact": "^2.0.0", - "lint-staged": "^10.5.3", + "lint-staged": "^10.5.4", "prettier": "^2.2.1", - "sass": "^1.32.4", + "sass": "^1.32.6", "ts-node": "^9.1.1", "typescript": "^4.1.3", "yargs": "^16.2.0" From 09b411730665ed57dc0abceefc7717113d4a86ed Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Sun, 7 Feb 2021 13:51:20 +0100 Subject: [PATCH 50/53] Activate strict mode --- src/module/actor/sheets/actor-sheet.ts | 2 +- src/module/ds4.ts | 41 +++++++++++-------- src/module/item/item-sheet.ts | 4 +- src/module/migrations.ts | 10 ++--- src/module/migrations/001.ts | 4 +- src/module/rolls/check-factory.ts | 56 ++++++++++++++------------ src/module/rolls/check.ts | 12 +++--- src/module/rolls/roll-executor.ts | 10 ++--- tsconfig.json | 2 +- 9 files changed, 78 insertions(+), 63 deletions(-) diff --git a/src/module/actor/sheets/actor-sheet.ts b/src/module/actor/sheets/actor-sheet.ts index 8d373def..177fff4c 100644 --- a/src/module/actor/sheets/actor-sheet.ts +++ b/src/module/actor/sheets/actor-sheet.ts @@ -221,7 +221,7 @@ export class DS4ActorSheet extends ActorSheet { ): Promise> { const item = ((await Item.fromDropData(data)) as unknown) as DS4Item; if (item && !this.actor.canOwnItemType(item.data.type)) { - ui.notifications.warn( + ui.notifications?.warn( game.i18n.format("DS4.WarningActorCannotOwnItem", { actorName: this.actor.name, actorType: this.actor.data.type, diff --git a/src/module/ds4.ts b/src/module/ds4.ts index 2f825cfc..0a500414 100644 --- a/src/module/ds4.ts +++ b/src/module/ds4.ts @@ -9,7 +9,7 @@ import { createCheckRoll } from "./rolls/check-factory"; import { registerSystemSettings } from "./settings"; import { migration } from "./migrations"; -Hooks.once("init", async function () { +Hooks.once("init", async () => { console.log(`DS4 | Initializing the DS4 Game System\n${DS4.ASCII}`); game.ds4 = { @@ -68,23 +68,11 @@ async function registerHandlebarsPartials() { /** * This function runs after game data has been requested and loaded from the servers, so entities exist */ -Hooks.once("setup", function () { - const noSort = ["attributes", "traits", "combatValues", "creatureSizeCategories"]; - - // Localize and sort CONFIG objects - for (const o of Object.keys(DS4.i18n)) { - const localized = Object.entries(DS4.i18n[o]).map((e) => { - return [e[0], game.i18n.localize(e[1] as string)]; - }); - if (!noSort.includes(o)) localized.sort((a, b) => a[1].localeCompare(b[1])); - DS4.i18n[o] = localized.reduce((obj, e) => { - obj[e[0]] = e[1]; - return obj; - }, {}); - } +Hooks.once("setup", () => { + localizeAndSortConfigObjects(); }); -Hooks.once("ready", function () { +Hooks.once("ready", () => { migration.migrate(); }); @@ -105,3 +93,24 @@ Hooks.once("ready", function () { }); }); }); + +/** + * Localizes all objects in {@link DS4.i18n} and sorts them unless they are explicitly excluded. + */ +function localizeAndSortConfigObjects() { + const noSort = ["attributes", "traits", "combatValues", "creatureSizeCategories"]; + + const localizeObject = (obj: T, sort = true): T => { + const localized = Object.entries(obj).map(([key, value]) => { + return [key, game.i18n.localize(value)]; + }); + if (sort) localized.sort((a, b) => a[1].localeCompare(b[1])); + return Object.fromEntries(localized); + }; + + DS4.i18n = Object.fromEntries( + Object.entries(DS4.i18n).map(([key, value]) => { + return [key, localizeObject(value, !noSort.includes(key))]; + }), + ) as typeof DS4.i18n; +} diff --git a/src/module/item/item-sheet.ts b/src/module/item/item-sheet.ts index 5afc372d..f32b6029 100644 --- a/src/module/item/item-sheet.ts +++ b/src/module/item/item-sheet.ts @@ -83,7 +83,7 @@ export class DS4ItemSheet extends ItemSheet { event.preventDefault(); if (this.item.isOwned) { - return ui.notifications.warn(game.i18n.localize("DS4.WarningManageActiveEffectOnOwnedItem")); + return ui.notifications?.warn(game.i18n.localize("DS4.WarningManageActiveEffectOnOwnedItem")); } const a = event.currentTarget; const li = $(a).parents(".effect"); @@ -93,7 +93,7 @@ export class DS4ItemSheet extends ItemSheet { return this._createActiveEffect(); case "edit": const effect = this.item.effects.get(li.data("effectId")); - return effect.sheet.render(true); + return effect?.sheet.render(true); case "delete": { return this.item.deleteEmbeddedEntity("ActiveEffect", li.data("effectId")); } diff --git a/src/module/migrations.ts b/src/module/migrations.ts index ec48294a..345ad263 100644 --- a/src/module/migrations.ts +++ b/src/module/migrations.ts @@ -1,7 +1,7 @@ import { migrate as migrate001 } from "./migrations/001"; async function migrate(): Promise { - if (!game.user.isGM) { + if (!game.user?.isGM) { return; } @@ -18,14 +18,14 @@ async function migrate(): Promise { } async function migrateFromTo(oldMigrationVersion: number, targetMigrationVersion: number): Promise { - if (!game.user.isGM) { + if (!game.user?.isGM) { return; } const migrationsToExecute = migrations.slice(oldMigrationVersion, targetMigrationVersion); if (migrationsToExecute.length > 0) { - ui.notifications.info( + ui.notifications?.info( game.i18n.format("DS4.InfoSystemUpdateStart", { currentVersion: oldMigrationVersion, targetVersion: targetMigrationVersion, @@ -40,7 +40,7 @@ async function migrateFromTo(oldMigrationVersion: number, targetMigrationVersion await migration(); game.settings.set("ds4", "systemMigrationVersion", currentMigrationVersion); } catch (err) { - ui.notifications.error( + ui.notifications?.error( game.i18n.format("DS4.ErrorDuringMigration", { currentVersion: oldMigrationVersion, targetVersion: targetMigrationVersion, @@ -54,7 +54,7 @@ async function migrateFromTo(oldMigrationVersion: number, targetMigrationVersion } } - ui.notifications.info( + ui.notifications?.info( game.i18n.format("DS4.InfoSystemUpdateCompleted", { currentVersion: oldMigrationVersion, targetVersion: targetMigrationVersion, diff --git a/src/module/migrations/001.ts b/src/module/migrations/001.ts index efc3637e..943aecc9 100644 --- a/src/module/migrations/001.ts +++ b/src/module/migrations/001.ts @@ -1,5 +1,5 @@ export async function migrate(): Promise { - for (const a of game.actors.entities) { + for (const a of game.actors?.entities ?? []) { const updateData = getActorUpdateData(); console.log(`Migrating actor ${a.name}`); await a.update(updateData, { enforceTypes: false }); @@ -18,7 +18,7 @@ function getActorUpdateData(): Record { "rangedAttack", "spellcasting", "targetedSpellcasting", - ].reduce((acc, curr) => { + ].reduce((acc: Partial>, curr) => { acc[curr] = { "-=base": null }; return acc; }, {}), diff --git a/src/module/rolls/check-factory.ts b/src/module/rolls/check-factory.ts index 21291e57..b0f007ea 100644 --- a/src/module/rolls/check-factory.ts +++ b/src/module/rolls/check-factory.ts @@ -131,34 +131,40 @@ async function askGmModifier( const renderedHtml = await renderTemplate(usedTemplate, templateData); const dialogPromise = new Promise((resolve) => { - new Dialog({ - title: usedTitle, - content: renderedHtml, - buttons: { - ok: { - icon: '', - label: game.i18n.localize("DS4.RollDialogOkButton"), - callback: (html) => { - if (!("jquery" in html)) { - throw new Error( - game.i18n.format("DS4.ErrorUnexpectedHtmlType", { - exType: "JQuery", - realType: "HTMLElement", - }), - ); - } else { - const innerForm = html[0].querySelector("form"); - resolve(innerForm); - } + new Dialog( + { + title: usedTitle, + content: renderedHtml, + buttons: { + ok: { + icon: '', + label: game.i18n.localize("DS4.RollDialogOkButton"), + callback: (html) => { + if (!("jquery" in html)) { + throw new Error( + game.i18n.format("DS4.ErrorUnexpectedHtmlType", { + exType: "JQuery", + realType: "HTMLElement", + }), + ); + } else { + const innerForm = html[0].querySelector("form"); + if (!innerForm) { + throw new Error(); // TODO: localize + } + resolve(innerForm); + } + }, + }, + cancel: { + icon: '', + label: game.i18n.localize("DS4.RollDialogCancelButton"), }, }, - cancel: { - icon: '', - label: game.i18n.localize("DS4.RollDialogCancelButton"), - }, + default: "ok", }, - default: "ok", - }).render(true); + { jQuery: true }, + ).render(true); }); const dialogForm = await dialogPromise; return parseDialogFormData(dialogForm); diff --git a/src/module/rolls/check.ts b/src/module/rolls/check.ts index 0fd84be2..12216ae6 100644 --- a/src/module/rolls/check.ts +++ b/src/module/rolls/check.ts @@ -56,8 +56,8 @@ export class DS4Check extends DiceTerm { } } - success = null; - failure = null; + success: boolean | null = null; + failure: boolean | null = null; targetValue = DS4Check.DEFAULT_TARGET_VALUE; minCritFailure = DS4Check.DEFAULT_MIN_CRIT_FAILURE; maxCritSuccess = DS4Check.DEFAULT_MAX_CRIT_SUCCESS; @@ -94,15 +94,15 @@ export class DS4Check extends DiceTerm { } /** Term Modifiers */ - noop(): this { - return this; + noop(): void { + return; } // DS4 only allows recursive explosions - explode(modifier: string): this { + explode(modifier: string): void { const rgx = /[xX]/; const match = modifier.match(rgx); - if (!match) return this; + if (!match) return; this.results = (this.results as Array) .map((r) => { diff --git a/src/module/rolls/roll-executor.ts b/src/module/rolls/roll-executor.ts index 8801170d..ea84bac8 100644 --- a/src/module/rolls/roll-executor.ts +++ b/src/module/rolls/roll-executor.ts @@ -11,7 +11,7 @@ import { calculateRollResult, isDiceSwapNecessary, isSlayingDiceRepetition, sepa export function ds4roll( checkTargetValue: number, rollOptions: Partial = {}, - dice: Array = null, + dice: Array = [], ): RollResult { if (checkTargetValue <= 20) { return rollCheckSingleDie(checkTargetValue, rollOptions, dice); @@ -36,11 +36,11 @@ export function ds4roll( export function rollCheckSingleDie( checkTargetValue: number, rollOptions: Partial, - dice: Array = null, + dice: Array = [], ): RollResult { const usedOptions = new DefaultRollOptions().mergeWith(rollOptions); - if (dice?.length != 1) { + if (dice.length != 1) { dice = [new DS4RollProvider().getNextRoll()]; } const usedDice = dice; @@ -75,13 +75,13 @@ export function rollCheckSingleDie( export function rollCheckMultipleDice( targetValue: number, rollOptions: Partial, - dice: Array = null, + dice: Array = [], ): RollResult { const usedOptions = new DefaultRollOptions().mergeWith(rollOptions); const remainderTargetValue = targetValue % 20; const numberOfDice = Math.ceil(targetValue / 20); - if (!dice || dice.length != numberOfDice) { + if (dice.length != numberOfDice) { dice = new DS4RollProvider().getNextRolls(numberOfDice); } const usedDice = dice; diff --git a/tsconfig.json b/tsconfig.json index f0f1205b..de75b335 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,7 +6,7 @@ "esModuleInterop": true, "moduleResolution": "node", "forceConsistentCasingInFileNames": true, - "strict": false + "strict": true }, "include": ["src"] } From ff3c09f00983e4633bd6b472a415089ef8d90b85 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Sun, 7 Feb 2021 14:00:26 +0100 Subject: [PATCH 51/53] Add missing localization --- src/lang/de.json | 3 ++- src/lang/en.json | 3 ++- src/module/rolls/check-factory.ts | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/lang/de.json b/src/lang/de.json index c1ea7a27..391571ea 100644 --- a/src/lang/de.json +++ b/src/lang/de.json @@ -198,7 +198,8 @@ "DS4.RollDialogDefaultTitle": "Proben-Optionen", "DS4.RollDialogOkButton": "OK", "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.RollDialogTargetLabel": "Probenwert", "DS4.RollDialogModifierLabel": "SL-Modifikator", "DS4.RollDialogCoupLabel": "Immersieg bis", diff --git a/src/lang/en.json b/src/lang/en.json index 6cd7c33a..e1d15a54 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -198,7 +198,8 @@ "DS4.RollDialogDefaultTitle": "Roll Options", "DS4.RollDialogOkButton": "Ok", "DS4.RollDialogCancelButton": "Cancel", - "DS4.ErrorUnexpectedHtmlType": "Type Error: Expected {exType}, got {realType}", + "DS4.ErrorUnexpectedHtmlType": "Type Error: Expected '{exType}' but got '{realType}'.", + "DS4.ErrorCouldNotFindForm": "Could not find html element '{htmlElement}'.", "DS4.RollDialogTargetLabel": "Check Target Number", "DS4.RollDialogModifierLabel": "Game Master Modifier", "DS4.RollDialogCoupLabel": "Coup to", diff --git a/src/module/rolls/check-factory.ts b/src/module/rolls/check-factory.ts index b0f007ea..43d8efaa 100644 --- a/src/module/rolls/check-factory.ts +++ b/src/module/rolls/check-factory.ts @@ -150,7 +150,9 @@ async function askGmModifier( } else { const innerForm = html[0].querySelector("form"); if (!innerForm) { - throw new Error(); // TODO: localize + throw new Error( + game.i18n.format("DS4.ErrorCouldNotFindHtmlElement", { htmlElement: "form" }), + ); } resolve(innerForm); } From 746d4d7a44773436beeb69681f3b3a4e0ba82398 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Mon, 8 Feb 2021 02:07:25 +0100 Subject: [PATCH 52/53] Update types --- package-lock.json | 2 +- src/module/actor/sheets/actor-sheet.ts | 8 ++++---- src/module/item/item-sheet.ts | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2894318b..8b3eee5b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3119,7 +3119,7 @@ } }, "foundry-vtt-types": { - "version": "github:League-of-Foundry-Developers/foundry-vtt-types#32d849fd2afa4e88319c0105c989cec62bb888c2", + "version": "github:League-of-Foundry-Developers/foundry-vtt-types#f1c321dcfe460595123765ababe5b8772d5df966", "from": "github:League-of-Foundry-Developers/foundry-vtt-types#foundry-0.7.9", "dev": true, "requires": { diff --git a/src/module/actor/sheets/actor-sheet.ts b/src/module/actor/sheets/actor-sheet.ts index 177fff4c..66c381be 100644 --- a/src/module/actor/sheets/actor-sheet.ts +++ b/src/module/actor/sheets/actor-sheet.ts @@ -6,7 +6,7 @@ import { DS4Actor } from "../actor"; /** * The base Sheet class for all DS4 Actors */ -export class DS4ActorSheet extends ActorSheet { +export class DS4ActorSheet extends ActorSheet> { // TODO(types): Improve mergeObject in upstream so that it isn't necessary to provide all parameters (see https://github.com/League-of-Foundry-Developers/foundry-vtt-types/issues/272) /** @override */ static get defaultOptions(): BaseEntitySheet.Options { @@ -48,9 +48,9 @@ export class DS4ActorSheet extends ActorSheet { * object itemsByType. * @returns The data fed to the template of the actor sheet */ - getData(): ActorSheet.Data | Promise> { + async getData(): Promise> { const data = { - ...super.getData(), + ...(await super.getData()), // Add the localization config to the data: config: DS4, // Add the items explicitly sorted by type to the data: @@ -73,7 +73,7 @@ export class DS4ActorSheet extends ActorSheet { html.find(".item-edit").on("click", (ev) => { const li = $(ev.currentTarget).parents(".item"); const item = this.actor.getOwnedItem(li.data("itemId")); - item.sheet.render(true); + item.sheet?.render(true); }); // Delete Inventory Item diff --git a/src/module/item/item-sheet.ts b/src/module/item/item-sheet.ts index f32b6029..2c7153ad 100644 --- a/src/module/item/item-sheet.ts +++ b/src/module/item/item-sheet.ts @@ -5,7 +5,7 @@ import { isDS4ItemDataTypePhysical } from "./item-data"; /** * The Sheet class for DS4 Items */ -export class DS4ItemSheet extends ItemSheet { +export class DS4ItemSheet extends ItemSheet> { /** @override */ static get defaultOptions(): BaseEntitySheet.Options { const superDefaultOptions = super.defaultOptions; @@ -41,9 +41,9 @@ export class DS4ItemSheet extends ItemSheet { } /** @override */ - getData(): ItemSheet.Data | Promise> { + async getData(): Promise> { const data = { - ...super.getData(), + ...(await super.getData()), config: DS4, isOwned: this.item.isOwned, actor: this.item.actor, From fc3f3eb1f35ad96c6e21b20d5ef42ea282fc288f Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Mon, 8 Feb 2021 02:15:43 +0100 Subject: [PATCH 53/53] Simplify DS4Check.MODIFIERS --- src/module/rolls/check.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/module/rolls/check.ts b/src/module/rolls/check.ts index 12216ae6..0ff4ef0b 100644 --- a/src/module/rolls/check.ts +++ b/src/module/rolls/check.ts @@ -93,11 +93,6 @@ export class DS4Check extends DiceTerm { } } - /** Term Modifiers */ - noop(): void { - return; - } - // DS4 only allows recursive explosions explode(modifier: string): void { const rgx = /[xX]/; @@ -135,7 +130,7 @@ export class DS4Check extends DiceTerm { static DENOMINATION = "s"; static MODIFIERS = { x: "explode", - c: "noop", // Modifier is consumed in constructor for target value - v: "noop", // Modifier is consumed in constructor for target value + c: (): void => undefined, // Modifier is consumed in constructor for crit + v: (): void => undefined, // Modifier is consumed in constructor for target value }; }