Files
mgt2-compendium-amiral-denisov/scripts/npc.js

42 lines
1.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { NpcDialog } from './NpcDialog.js';
import { syncNpcRollTables } from './npcRollTableSync.js';
const MODULE_ID = 'mgt2-compendium-amiral-denisov';
function openNpcDialog(initialTab, options = {}) {
new NpcDialog({ initialTab, ...options }).render(true);
}
Hooks.once('init', () => {
console.log(`${MODULE_ID} | Outils PNJ initialisés`);
loadTemplates([
`modules/${MODULE_ID}/templates/npc-dialog.hbs`,
`modules/${MODULE_ID}/templates/npc-result.hbs`,
]);
});
Hooks.once('ready', async () => {
await syncNpcRollTables();
console.log(`${MODULE_ID} | Outils PNJ prêts tapez /pnj, /rencontre ou /mission dans le chat`);
});
Hooks.on('chatMessage', (_chatLog, message, _chatData) => {
const trimmed = message.trim().toLowerCase();
if (trimmed === '/pnj' || trimmed.startsWith('/pnj ')) {
openNpcDialog('npc');
return false;
}
if (trimmed === '/rencontre' || trimmed.startsWith('/rencontre ')) {
openNpcDialog('encounter');
return false;
}
if (trimmed === '/mission' || trimmed.startsWith('/mission ')) {
openNpcDialog('mission');
return false;
}
});