taulukko-common-scripts-dnd5ed 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/index.d.ts +1 -5
- package/dist/index.d.ts +1 -2
- package/dist/sockets/implementations/common-socket-chatmessage.d.ts +1 -1
- package/dist/sockets/implementations/common-socket-dummy.d.ts +1 -1
- package/dist/sockets/implementations/common-socket-socketlib.d.ts +1 -1
- package/dist/submodules/dialog-utils/dialog-utils.d.ts +4 -4
- package/dist/submodules/hero-points/hero-points.d.ts +1 -1
- package/dist/submodules/hide-unindentify/hide-unidentify.d.ts +1 -1
- package/dist/submodules/index.d.ts +1 -0
- package/dist/submodules/playertools/players-tool.d.ts +1 -1
- package/dist/submodules/region-utils/region-utils.d.ts +1 -1
- package/dist/{common → submodules}/sub-module-base.d.ts +1 -1
- package/dist/taulukko-common-scripts-dnd5ed.iife.js +1 -1
- package/package.json +1 -1
- /package/dist/{common → submodules}/npc/button.d.ts +0 -0
- /package/dist/{common → submodules}/npc/index.d.ts +0 -0
- /package/dist/{common → submodules}/npc/npc-dialog.d.ts +0 -0
- /package/dist/{common → submodules}/npc/npc-portrait-dialog.d.ts +0 -0
- /package/dist/{common → submodules}/npc/npc.d.ts +0 -0
package/dist/common/index.d.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
1
|
export { CacheReturnControl } from './cache-returns-control';
|
|
2
|
-
export {
|
|
3
|
-
export { NPC } from './npc/npc';
|
|
4
|
-
export { NPCDialog } from './npc/npc-dialog';
|
|
5
|
-
export { NPCPortraitDialog } from './npc/npc-portrait-dialog';
|
|
6
|
-
export { SubModuleBase } from './sub-module-base';
|
|
2
|
+
export { SubModuleBase } from '../submodules/sub-module-base';
|
|
7
3
|
export { ModuleBase } from './module-base';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export { DialogUtils, HeroPoints, HideUnidentify, PlayersTools, RegionUtils } from './submodules';
|
|
1
|
+
export { DialogUtils, HeroPoints, HideUnidentify, PlayersTools, RegionUtils, Button, NPC, NPCDialog, NPCPortraitDialog } from './submodules';
|
|
2
2
|
export { SocketLib, ChatSocket, DummySocket } from './sockets';
|
|
3
3
|
export type { Socket } from './sockets';
|
|
4
|
-
export { Button, NPC, NPCDialog, NPCPortraitDialog } from './common/npc';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Socket } from '../common-socket';
|
|
2
|
-
import { SubModuleBase } from '../../
|
|
2
|
+
import { SubModuleBase } from '../../submodules/sub-module-base';
|
|
3
3
|
export declare class ChatSocket extends SubModuleBase implements Socket {
|
|
4
4
|
#private;
|
|
5
5
|
protected initHooks(): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SubModuleBase } from '../../
|
|
1
|
+
import { SubModuleBase } from '../../submodules/sub-module-base';
|
|
2
2
|
import { Socket } from '../common-socket';
|
|
3
3
|
export declare class DummySocket extends SubModuleBase implements Socket {
|
|
4
4
|
protected initHooks(): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Socket } from '../common-socket';
|
|
2
|
-
import { SubModuleBase } from '../../
|
|
2
|
+
import { SubModuleBase } from '../../submodules/sub-module-base';
|
|
3
3
|
export declare class SocketLib extends SubModuleBase implements Socket {
|
|
4
4
|
private _socketOriginal;
|
|
5
5
|
private _requirementModules;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Button } from '
|
|
2
|
-
import { SubModuleBase } from '
|
|
3
|
-
import { NPC } from '
|
|
4
|
-
import { NPCDialog } from '
|
|
1
|
+
import { Button } from '../npc/button';
|
|
2
|
+
import { SubModuleBase } from '../sub-module-base';
|
|
3
|
+
import { NPC } from '../npc/npc';
|
|
4
|
+
import { NPCDialog } from '../npc/npc-dialog';
|
|
5
5
|
export declare class DialogUtils extends SubModuleBase {
|
|
6
6
|
#private;
|
|
7
7
|
readonly npctype: typeof NPC;
|
|
@@ -3,3 +3,4 @@ export { HeroPoints } from './hero-points/hero-points';
|
|
|
3
3
|
export { HideUnidentify } from './hide-unindentify/hide-unidentify';
|
|
4
4
|
export { PlayersTools } from './playertools/players-tool';
|
|
5
5
|
export { RegionUtils } from './region-utils/region-utils';
|
|
6
|
+
export { Button, NPC, NPCDialog, NPCPortraitDialog } from './npc';
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
`)}),u+=`
|
|
13
13
|
</SELECT>
|
|
14
14
|
</DIV>
|
|
15
|
-
`,i.debug("NPC.createDialog:10",e),i.debug("NPC.createDialog:15:activeNPC.groups:",n.activeNPC.groups),r||(i.debug("NPC.createDialog:20"),r=[c.createButton("send","Enviar",!0,"action",async()=>{i.debug("NPC.createDialog, before creating send:",n.activeNPC.groups),i.debug("NPC.createDialog [10]: Escolhido a opcao enviar");const m=(document.querySelector(`.${l}-actions-buttons SELECT`)||null)?.value;if(m==null){i.error("NPC.createDialog: Erro ao obter a opcao selecionada");return}if(i.debug("NPC.createDialog [20]: depois de selecionar o resultado",m),m===`${l}-random`){const h=n.activeNPC.screens.at(-1);n.activeNPC.screens.push({name:m,callback:n.activeNPC.send,type:h.type}),i.debug("NPC.createDialog, before random send:",n.activeNPC.groups),n.activeNPC.send(!1),i.debug("NPC.createDialog, after random send:",n.activeNPC.groups);return}e.forEach(h=>{h.action==m&&(i.debug("NPC.Enviado a opcao :"+m),n.activeNPC.screens.push({name:m,callback:h.callback,type:h.type}),h.callback(),i.debug("NPC.createDialog, after 3 creating send:",n.activeNPC.groups))})}),c.createButton("back","Voltar",!0,"action",async()=>{i.debug("NPC.screens ao voltar - antes: ",n.activeNPC.screens);const d=n.activeNPC.screens.at(-2),m=n.activeNPC.screens.pop();i.debug("lastScreen:",m),i.debug("screens ao voltar - depois: ",n.activeNPC.screens),m.type=="screen-context"&&n.activeNPC.decrementGroup(),d.callback()}),c.createButton("cancel","Cancelar",!0,"action",async()=>{i.debug("NPC.Cancelado a tela do ",l)})],i.debug("NPC.createDialog:25. Create submits",r),i.debug("NPC.createDialog:30 - depois de criar submits"));const g=(d,m,h,p)=>{};i.debug("NPC.createDialog:40 - antes de criar dialogo"),c.createDialog(t,n.activeNPC.DEFAULT_STYLE,u,r,[g],200,void 0,400),i.debug("NPC.createDialog:50 - depois de criar dialogo")}async getListLinesFromGroup(t){const o=a.injectController.resolve("NPCDialog"),e=a.injectController.resolve("Log"),r=Array.from(t).map(Number).sort((c,i)=>c-i);if(r.length===0&&t.size===0)return new Array;if(r.length===0&&r.push(Number.parseInt(t.get(0),10)),r.length==1)return r;let n=await o.activeNPC.getCombinations(r);return e.debug("groups:",r),e.debug("keys:",n),n}async getCombinations(t,o=";"){const e=a.injectController.resolve("NPCDialog"),r=a.injectController.resolve("Log"),n=new Array;if(t.length==0||t.length==1)return[...t];r.debug("numbers:",t);const c=(i,l)=>{r.debug("generate start:",i,",path",l);let u=t.join(";");if(r.debug("combinationKey:",u),r.debug("groupToLines:",e.activeNPC.groupToLines,"-",typeof u),e.activeNPC.groupToLines.has(u))return r.debug("find, return the combination"),n.push(u),n;r.debug("combinationKey not found:",u);for(let g=i;g<t.length;g++){const d=[...l,t[g]];r.debug("novaCombinacao:",d),u=d.join(";"),n.push(u),c(g+1,d)}};return c(0,[]),n}async speak(t){const o=a.injectController.resolve("NPCDialog"),e=a.injectController.resolve("Log"),r=o.activeNPC.lines[t];e.debug("speak:talk:",r),e.debug("disparando o evento pra todo mundo:"),console.log("[NPC Portrait] Enviando para todos..."),await ChatMessage.create({content:"NPC Portrait Event",whisper:Array.from(game.users?.values()||[]).map(u=>u.id),flags:{"forgotten-realms":{type:"npcDialogOnTalk",payload:{imageUrl:this.imageUrl,npcName:this.name,dialogText:r}}}}),e.debug(" evento disparado pra todo mundo:");const n=t.toString().padStart(3,"0"),c=o.activeNPC.name,i=`modules/forgotten-realms/sounds/npcs/${c}/${n}/${c}${n}.${o.activeNPC.formatSound}`,l=await this.playSoundWithNoEffect(i);e.debug("Retorno do play:",l)}async playSoundWithNoEffect(t){a.injectController.resolve("NPCDialog");const o=a.injectController.resolve("Log");try{const e=await fetch(t,{method:"HEAD"});return e.ok?(foundry.audio.AudioHelper.play({src:t,autoplay:!0},!0),!0):(console.warn(`Arquivo não encontrado: ${t} (${e.status})`),!1)}catch(e){return o.error("Erro ao reproduzir o som:",t,e),!1}}async send(t=!0){const o=a.injectController.resolve("NPCDialog"),e=a.injectController.resolve("Log");o.activeNPC.groups.size===0&&o.activeNPC.groups.add($);const r=await o.activeNPC.getListLinesFromGroup(o.activeNPC.groups);e.debug("NPC.send, before send,list:",r);const n=new Array;for(const u of r){const g=u.toString();if(e.debug("group:",g),!o.activeNPC.groupToLines.has(g)){e.warn(`NPC.send, afterSend:Grupo ${g} não encontrado em groupToLines!`);continue}const d=g.split(";").length+1,m=o.activeNPC.groupToLines.get(g);e.debug("NPC.send, 50,linesForThisGroupConcat:",m,"-size:",d);const h=m.split(";");e.debug("NPC.send, 60,linesForThisGroup:",h),h.forEach(p=>{for(let Q=0;Q<d;Q++)n.push(p)})}e.debug("NPC.send, afterSend,lines:",n);let c=Math.abs(Math.round(Math.random()*n.length));c=c>=n.length?n.length-1:c,e.debug("NPC.send, afterSend,randomIndex:",c);const i=Number.parseInt(n[c],10);e.debug("NPC.send, afterSend,lineIndex:",i),o.activeNPC.speak(i),e.debug("NPC.send, afterSend,activeScreen:",o.activeNPC.screens);const l=o.activeNPC.screens.at(-2);o.activeNPC.screens.pop(),l.callback(),o.activeNPC.groups.delete($),t&&o.activeNPC.decrementGroup(),e.debug("NPC.send, afterSend:",o.activeNPC.groups)}}class E extends Application{imageUrl;npcName;dialogText;constructor(t={}){super(),this.imageUrl=t.imageUrl||"YOUR_IMAGE_URL_HERE",this.npcName=t.npcName||"NPC",this.dialogText=t.dialogText||"Olá, aventureiro..."}static get defaultOptions(){return foundry.utils.mergeObject(Application.defaultOptions,{id:"npc-portrait-dialog",classes:["npc-portrait-app"],title:"",width:600,height:400,resizable:!1,minimizable:!1,popOut:!0})}get template(){return"modules/
|
|
15
|
+
`,i.debug("NPC.createDialog:10",e),i.debug("NPC.createDialog:15:activeNPC.groups:",n.activeNPC.groups),r||(i.debug("NPC.createDialog:20"),r=[c.createButton("send","Enviar",!0,"action",async()=>{i.debug("NPC.createDialog, before creating send:",n.activeNPC.groups),i.debug("NPC.createDialog [10]: Escolhido a opcao enviar");const m=(document.querySelector(`.${l}-actions-buttons SELECT`)||null)?.value;if(m==null){i.error("NPC.createDialog: Erro ao obter a opcao selecionada");return}if(i.debug("NPC.createDialog [20]: depois de selecionar o resultado",m),m===`${l}-random`){const h=n.activeNPC.screens.at(-1);n.activeNPC.screens.push({name:m,callback:n.activeNPC.send,type:h.type}),i.debug("NPC.createDialog, before random send:",n.activeNPC.groups),n.activeNPC.send(!1),i.debug("NPC.createDialog, after random send:",n.activeNPC.groups);return}e.forEach(h=>{h.action==m&&(i.debug("NPC.Enviado a opcao :"+m),n.activeNPC.screens.push({name:m,callback:h.callback,type:h.type}),h.callback(),i.debug("NPC.createDialog, after 3 creating send:",n.activeNPC.groups))})}),c.createButton("back","Voltar",!0,"action",async()=>{i.debug("NPC.screens ao voltar - antes: ",n.activeNPC.screens);const d=n.activeNPC.screens.at(-2),m=n.activeNPC.screens.pop();i.debug("lastScreen:",m),i.debug("screens ao voltar - depois: ",n.activeNPC.screens),m.type=="screen-context"&&n.activeNPC.decrementGroup(),d.callback()}),c.createButton("cancel","Cancelar",!0,"action",async()=>{i.debug("NPC.Cancelado a tela do ",l)})],i.debug("NPC.createDialog:25. Create submits",r),i.debug("NPC.createDialog:30 - depois de criar submits"));const g=(d,m,h,p)=>{};i.debug("NPC.createDialog:40 - antes de criar dialogo"),c.createDialog(t,n.activeNPC.DEFAULT_STYLE,u,r,[g],200,void 0,400),i.debug("NPC.createDialog:50 - depois de criar dialogo")}async getListLinesFromGroup(t){const o=a.injectController.resolve("NPCDialog"),e=a.injectController.resolve("Log"),r=Array.from(t).map(Number).sort((c,i)=>c-i);if(r.length===0&&t.size===0)return new Array;if(r.length===0&&r.push(Number.parseInt(t.get(0),10)),r.length==1)return r;let n=await o.activeNPC.getCombinations(r);return e.debug("groups:",r),e.debug("keys:",n),n}async getCombinations(t,o=";"){const e=a.injectController.resolve("NPCDialog"),r=a.injectController.resolve("Log"),n=new Array;if(t.length==0||t.length==1)return[...t];r.debug("numbers:",t);const c=(i,l)=>{r.debug("generate start:",i,",path",l);let u=t.join(";");if(r.debug("combinationKey:",u),r.debug("groupToLines:",e.activeNPC.groupToLines,"-",typeof u),e.activeNPC.groupToLines.has(u))return r.debug("find, return the combination"),n.push(u),n;r.debug("combinationKey not found:",u);for(let g=i;g<t.length;g++){const d=[...l,t[g]];r.debug("novaCombinacao:",d),u=d.join(";"),n.push(u),c(g+1,d)}};return c(0,[]),n}async speak(t){const o=a.injectController.resolve("NPCDialog"),e=a.injectController.resolve("Log"),r=o.activeNPC.lines[t];e.debug("speak:talk:",r),e.debug("disparando o evento pra todo mundo:"),console.log("[NPC Portrait] Enviando para todos..."),await ChatMessage.create({content:"NPC Portrait Event",whisper:Array.from(game.users?.values()||[]).map(u=>u.id),flags:{"forgotten-realms":{type:"npcDialogOnTalk",payload:{imageUrl:this.imageUrl,npcName:this.name,dialogText:r}}}}),e.debug(" evento disparado pra todo mundo:");const n=t.toString().padStart(3,"0"),c=o.activeNPC.name,i=`modules/forgotten-realms/sounds/npcs/${c}/${n}/${c}${n}.${o.activeNPC.formatSound}`,l=await this.playSoundWithNoEffect(i);e.debug("Retorno do play:",l)}async playSoundWithNoEffect(t){a.injectController.resolve("NPCDialog");const o=a.injectController.resolve("Log");try{const e=await fetch(t,{method:"HEAD"});return e.ok?(foundry.audio.AudioHelper.play({src:t,autoplay:!0},!0),!0):(console.warn(`Arquivo não encontrado: ${t} (${e.status})`),!1)}catch(e){return o.error("Erro ao reproduzir o som:",t,e),!1}}async send(t=!0){const o=a.injectController.resolve("NPCDialog"),e=a.injectController.resolve("Log");o.activeNPC.groups.size===0&&o.activeNPC.groups.add($);const r=await o.activeNPC.getListLinesFromGroup(o.activeNPC.groups);e.debug("NPC.send, before send,list:",r);const n=new Array;for(const u of r){const g=u.toString();if(e.debug("group:",g),!o.activeNPC.groupToLines.has(g)){e.warn(`NPC.send, afterSend:Grupo ${g} não encontrado em groupToLines!`);continue}const d=g.split(";").length+1,m=o.activeNPC.groupToLines.get(g);e.debug("NPC.send, 50,linesForThisGroupConcat:",m,"-size:",d);const h=m.split(";");e.debug("NPC.send, 60,linesForThisGroup:",h),h.forEach(p=>{for(let Q=0;Q<d;Q++)n.push(p)})}e.debug("NPC.send, afterSend,lines:",n);let c=Math.abs(Math.round(Math.random()*n.length));c=c>=n.length?n.length-1:c,e.debug("NPC.send, afterSend,randomIndex:",c);const i=Number.parseInt(n[c],10);e.debug("NPC.send, afterSend,lineIndex:",i),o.activeNPC.speak(i),e.debug("NPC.send, afterSend,activeScreen:",o.activeNPC.screens);const l=o.activeNPC.screens.at(-2);o.activeNPC.screens.pop(),l.callback(),o.activeNPC.groups.delete($),t&&o.activeNPC.decrementGroup(),e.debug("NPC.send, afterSend:",o.activeNPC.groups)}}class E extends Application{imageUrl;npcName;dialogText;constructor(t={}){super(),this.imageUrl=t.imageUrl||"YOUR_IMAGE_URL_HERE",this.npcName=t.npcName||"NPC",this.dialogText=t.dialogText||"Olá, aventureiro..."}static get defaultOptions(){return foundry.utils.mergeObject(Application.defaultOptions,{id:"npc-portrait-dialog",classes:["npc-portrait-app"],title:"",width:600,height:400,resizable:!1,minimizable:!1,popOut:!0})}get template(){return"modules/common-scripts-dnd5ed/scripts/templates/npc-talk.hbs"}async getData(){return{imageUrl:this.imageUrl,npcName:this.npcName,dialogText:this.dialogText}}activateListeners(t){super.activateListeners(t),t.on("click",".close-button",()=>{this.close()})}static renderTalk(t){new E({imageUrl:t.imageUrl,npcName:t.npcName,dialogText:t.dialogText}).render(!0)}async showToAllPlayers(){if(this.render(!0),game.user?.isGM){const t={type:"showNPCPortrait",data:{imageUrl:this.imageUrl,npcName:this.npcName,dialogText:this.dialogText}};game.socket.emit("module.seu-modulo",t)}}}console.log("npcDialog.ts loaded 10");class ge extends f{npcSelected;activeNPC;npcs=new Map;buttonloaded=!1;#e=!1;initHooks(){Hooks.on("createChatMessage",async t=>{const o=a.injectController.resolve("Log"),e=a.injectController.resolve("NPCDialog"),r=300*1e3;if(await e.whaitFor(()=>a.injectController.has("DialogUtils"),r),!a.injectController.has("DialogUtils")){o.error("Givup chat message ",t," because timeout wiaiting for DialogUtils");return}try{if(o.debug("createChatMessage recebido..."),t.flags?.["common-assets"]?.type==="npcDialogOnTalk"){const n=t.flags["common-assets"].payload;o.debug("[NPC Portrait] Evento recebido dos jogadores:",n),E.renderTalk(n)}}catch(n){o.error("[NPC Portrait] Erro ao processar evento:",n)}}),Hooks.on("getSceneControlButtons",async t=>{const o=a.injectController.resolve("Log"),e=a.injectController.resolve("NPCDialog"),r=300*1e3;if(await e.whaitFor(()=>a.injectController.has("DialogUtils"),r),!a.injectController.has("DialogUtils")){o.error("Givup getSceneControlButtons ",t," because timeout wiaiting for DialogUtils");return}o.debug("On getSceneControlButtons 05...",t,e),await e.addNPCButtons(t),e.#e=!0,o.debug("On getSceneControlButtons...:20")})}async waitReady(){if(await this.whaitFor(()=>this.#e,3e5),!this.#e)throw new Error("Timeout waiting for hooks");Hooks.callAll("onReadyNPCDialog",{})}async addNPCButtons(t){const o=a.injectController.resolve("Log"),e=a.injectController.resolve("NPCDialog");if(!game.user.isGM){o.debug("NPC Buttons off");return}o.debug("Criando botão dos NPCs especiais",t),t.tokens.tools.npcButton={name:"npcButton",title:"NPCs Especiais",icon:"fa-solid fa-web-awesome",button:!0,toggle:!1,onClick:()=>{o.debug("Botão de NPCs especiais pressionado"),console.log("npcDialog",e),e.showNPCChooseDialog(),o.debug("Após abrir janela de NPCs especiais")}},o.debug("Botão de NPC criado")}async showNPCChooseDialog(){const t=a.injectController.resolve("Log"),o=a.injectController.resolve("NPCDialog"),e=a.injectController.resolve("DialogUtils");t.debug("Botão NPCsespecial pressionado, mostrando diálogo...");const r="Escolha um NPC Especial",n=`
|
|
16
16
|
.select-npc { padding: 20px; background: #222; color: #eee; }
|
|
17
17
|
.select-npc button { margin: 5px; padding: 5px 10px; }
|
|
18
18
|
`,c=`
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|