Do a bit of cleanup

This commit is contained in:
Johannes Loher 2021-07-01 02:56:09 +02:00
parent 2161a8e92a
commit f26d75b56f
7 changed files with 34 additions and 34 deletions

View file

@ -15,8 +15,6 @@ export interface HasTotal<T> {
total: T; total: T;
} }
export interface ModifiableDataTotal<T> extends ModifiableData<T>, HasTotal<T> {}
export interface ModifiableDataBaseTotal<T> extends ModifiableDataBase<T>, HasTotal<T> {} export interface ModifiableDataBaseTotal<T> extends ModifiableDataBase<T>, HasTotal<T> {}
export interface ResourceData<T> extends ModifiableData<T> { export interface ResourceData<T> extends ModifiableData<T> {

View file

@ -2,8 +2,6 @@
// //
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
import { DS4 } from "./config";
declare global { declare global {
namespace ClientSettings { namespace ClientSettings {
interface Values { interface Values {
@ -18,8 +16,6 @@ declare global {
x: (this: PoolTerm, modifier: string) => void; x: (this: PoolTerm, modifier: string) => void;
} }
} }
interface CONFIG {
DS4: typeof DS4;
}
} }
export {};

View file

@ -63,3 +63,20 @@ async function init() {
await registerHandlebarsPartials(); await registerHandlebarsPartials();
registerHandlebarsHelpers(); registerHandlebarsHelpers();
} }
declare global {
interface Game {
ds4: {
DS4Actor: typeof DS4Actor;
DS4Item: typeof DS4Item;
DS4: typeof DS4;
createCheckRoll: typeof createCheckRoll;
migration: typeof migration;
macros: typeof macros;
};
}
interface CONFIG {
DS4: typeof DS4;
}
}

View file

@ -95,10 +95,8 @@ export class DS4ItemSheet extends ItemSheet<ItemSheet.Options, DS4ItemSheetData>
* Create a new ActiveEffect for the item using default data. * Create a new ActiveEffect for the item using default data.
*/ */
protected async _createActiveEffect(): Promise<ActiveEffect | undefined> { protected async _createActiveEffect(): Promise<ActiveEffect | undefined> {
const label = `New Effect`;
const createData = { const createData = {
label: label, label: "New Effect",
changes: [], changes: [],
duration: {}, duration: {},
transfer: true, transfer: true,

View file

@ -8,24 +8,17 @@ const loggingSeparator = "|";
type LogLevel = "debug" | "info" | "warning" | "error"; type LogLevel = "debug" | "info" | "warning" | "error";
type LoggingFunction = (...data: unknown[]) => void; type LoggingFunction = (...data: unknown[]) => void;
class Logger { const getLoggingFunction = (type: LogLevel = "info"): LoggingFunction => {
readonly debug: LoggingFunction; const log = { debug: console.debug, info: console.info, warning: console.warn, error: console.error }[type];
readonly info: LoggingFunction; return (...data: unknown[]) => log(loggingContext, loggingSeparator, ...data);
readonly warn: LoggingFunction; };
readonly error: LoggingFunction;
constructor() { const logger = Object.freeze({
this.debug = this.getLoggingFunction("debug"); debug: getLoggingFunction("debug"),
this.info = this.getLoggingFunction("info"); info: getLoggingFunction("info"),
this.warn = this.getLoggingFunction("warning"); warn: getLoggingFunction("warning"),
this.error = this.getLoggingFunction("error"); error: getLoggingFunction("error"),
} getLoggingFunction,
});
getLoggingFunction(type: LogLevel = "info") {
const log = { debug: console.debug, info: console.info, warning: console.warn, error: console.error }[type];
return (...data: unknown[]) => log(loggingContext, loggingSeparator, ...data);
}
}
const logger = new Logger();
export default logger; export default logger;

View file

@ -18,11 +18,11 @@ export function getActiveActor(): DS4Actor | undefined {
const speakerToken = speaker.token ? getCanvas().tokens.get(speaker.token) : undefined; const speakerToken = speaker.token ? getCanvas().tokens.get(speaker.token) : undefined;
if (speakerToken) { if (speakerToken) {
return speakerToken.actor as DS4Actor; return speakerToken.actor ?? undefined;
} }
const speakerActor = speaker.actor ? game.actors?.get(speaker.actor) : undefined; const speakerActor = speaker.actor ? game.actors?.get(speaker.actor) : undefined;
if (speakerActor) { if (speakerActor) {
return speakerActor as DS4Actor; return speakerActor;
} }
} }

View file

@ -49,12 +49,10 @@ class CheckFactory {
// @ts-ignore // @ts-ignore
const speaker = ChatMessage.getSpeaker(); const speaker = ChatMessage.getSpeaker();
const a = roll.toMessage( return roll.toMessage(
{ speaker, flavor: this.options.flavor }, { speaker, flavor: this.options.flavor },
{ rollMode: this.options.rollMode, create: true }, { rollMode: this.options.rollMode, create: true },
); );
return a;
} }
createCheckTargetNumberModifier(): string { createCheckTargetNumberModifier(): string {