2021-09-19 12:23:52 +02:00
|
|
|
// SPDX-FileCopyrightText: 2021 Johannes Loher
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
2022-11-04 21:47:18 +01:00
|
|
|
import { getGame } from "../utils/utils";
|
2021-09-19 12:23:52 +02:00
|
|
|
|
|
|
|
declare global {
|
|
|
|
interface FlagConfig {
|
|
|
|
ChatMessage: {
|
|
|
|
ds4?: {
|
|
|
|
flavorData?: Record<string, string | number | null>;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export class DS4ChatMessage extends ChatMessage {
|
2022-05-29 17:47:27 +02:00
|
|
|
override prepareData(): void {
|
2021-09-19 12:23:52 +02:00
|
|
|
super.prepareData();
|
|
|
|
if (this.data.flavor) {
|
|
|
|
const game = getGame();
|
|
|
|
const flavorData = Object.fromEntries(
|
|
|
|
Object.entries(this.data.flags.ds4?.flavorData ?? {}).map(([key, value]) => [
|
|
|
|
key,
|
|
|
|
typeof value === "string" ? game.i18n.localize(value) : value,
|
|
|
|
]),
|
|
|
|
);
|
|
|
|
this.data.flavor = game.i18n.format(this.data.flavor, flavorData);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|