Update types

This commit is contained in:
Johannes Loher 2021-02-05 02:35:47 +01:00
parent cd86857b43
commit 2641b1ee74
5 changed files with 38 additions and 38 deletions

2
package-lock.json generated
View file

@ -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": {

View file

@ -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<unknown, DS4Actor> {
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,
};

View file

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

View file

@ -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<unknown, DS4Item> {
getData(): ItemSheet.Data<DS4Item> {
const data = {
...super.getData(),
config: CONFIG.DS4,
config: DS4,
isOwned: this.item.isOwned,
actor: this.item.actor,
isPhysical: isDS4ItemDataTypePhysical(this.item.data.data),

View file

@ -34,7 +34,7 @@ class CheckFactory {
private checkOptions: DS4CheckFactoryOptions;
async execute(): Promise<ChatMessage | unknown> {
const rollCls: typeof Roll = CONFIG.Dice.rolls[0];
const rollCls = CONFIG.Dice.rolls[0];
const formula = [
"ds",
@ -131,16 +131,14 @@ async function askGmModifier(
const renderedHtml = await renderTemplate(usedTemplate, templateData);
const dialogPromise = new Promise<HTMLFormElement>((resolve) => {
new Dialog({
new Dialog(
{
title: usedTitle,
close: () => {
// Don't do anything
},
content: renderedHtml,
buttons: {
ok: {
label: game.i18n.localize("DS4.RollDialogOkButton"),
callback: (html: HTMLElement | JQuery) => {
callback: (html) => {
if (!("jquery" in html)) {
throw new Error(
game.i18n.format("DS4.ErrorUnexpectedHtmlType", {
@ -153,16 +151,17 @@ async function askGmModifier(
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"),
callback: () => {
// Don't do anything
},
icon: "", // TODO(types): Remove once https://github.com/League-of-Foundry-Developers/foundry-vtt-types/issues/266 is fixed
},
},
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);