Ajout des commandes de creation de rencontre/NJ
This commit is contained in:
41
scripts/npc.js
Normal file
41
scripts/npc.js
Normal file
@@ -0,0 +1,41 @@
|
||||
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;
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user