taulukko-common-scripts-dnd5ed 1.0.1
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/LICENSE +21 -0
- package/README.md +8 -0
- package/dist/common-scripts.iife.js +55 -0
- package/package.json +25 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Edson Vicente Carli Junior
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
(function(){"use strict";const L=document;class Q{_isReady=!1;constructor(){this.callHooks()}init(){L.COMMON_MODULE.debug("Dummy Socket initializing..."),this._isReady=!0,Hooks.callAll("onReadyCommonSocket",{})}callHooks(){Hooks.once("onReadyCommonModule",async()=>{this.init()})}async executeForAll(t,...o){L.COMMON_MODULE.debug("Socket dummy executeForAll for event:",t,",parameters: ",o,"...parameters",...o)}async executeAsGM(t,...o){if(!game.user||!game.users)throw new Error("Game isnt complete prepareted yet, player and gm isnt filled the information. Wait for game ready event ");L.COMMON_MODULE.debug("Socket dummy executeAsGM for event:",t,",parameters: ",o,"...parameters",...o)}async executeToGM(t,...o){L.COMMON_MODULE.debug("Socket dummy executeAsGM for event:",t,",parameters: ",o,"...parameters",...o)}async executeIn(t,o,...e){}isReadyToSendToGM(){return!1}async register(t,o){}isReady(){return this._isReady}}const Z=new Q;class ee{getSocket(){return Z}}const m=new ee().getSocket();let d=document;function te(){Hooks.once("onReadyCommonSocket",async()=>{d.COMMON_MODULE.debug("onReadyCommonSocket 20"),m.register("helloEveryOne",r),m.register("helloToGM",t),m.register("helloFromGM",o),d.COMMON_MODULE.debug("Socketlib 20"),m.register("add",e),m.register("someusersadd",s),d.COMMON_MODULE.debug("Socketlib finish the register events");function r(i){d.COMMON_MODULE.debug(`User ${i} says hello for everyone!`)}function t(i){d.COMMON_MODULE.debug(`User ${i} says hello to GM!`)}function o(i){d.COMMON_MODULE.debug("GM say hello to you!",i)}function e(i,a){return d.COMMON_MODULE.debug("The addition is performed on a GM client."),i+a}let n=0;function s(i,a){return d.COMMON_MODULE.debug("The addition is performed on a client of manys - addWithErrors."),i+a+n++}try{if(m.isReadyToSendToGM())if(d.COMMON_MODULE.debug("Gm esta pronto pra receber mensagens"),m.executeForAll("helloEveryOne","teste1"),d.COMMON_MODULE.debug("Depois de usar executeForAll"),game.user.isGM){let g=await m.executeAsGM("add",5,6);d.COMMON_MODULE.debug(`The player calculated: ${g}`),await m.executeAsGM("helloFromGM","Hello from ","GM"),d.COMMON_MODULE.debug("depois de helloFromGM 1")}else{m.executeForAll("helloEveryOne","teste2"),d.COMMON_MODULE.debug("Depois de heldebugM");try{await m.executeAsGM("helloEveryOne","teste5")}catch(g){d.COMMON_MODULE.debug("depois de helloToGM 1",g)}}else d.COMMON_MODULE.debug("A minha implementacao notou que o gm nao foi carregado ainda 1");m.executeForAll("helloEveryOne","teste3"),d.COMMON_MODULE.debug("depois de helloEveryOne 2"),m.executeToGM("helloEveryOne","esse-apenas-gm-deveria-receber");let i=game.users.map(g=>g.id);i=i.filter(g=>(d.COMMON_MODULE.debug("id recebido e meu user id",g,game.user.id),g!=game.user.id));let a=Math.round(1e3*Math.random())+1e3,l=Math.round(i.length*Math.random());l=l==i.length?l-1:l;const O=i.at(l);d.COMMON_MODULE.debug(`Sending to player random: ${O} , I am userid: ${game.user.id} and number random is ${a}`);let h=await m.executeIn("add",[O],a,1);d.COMMON_MODULE.debug(`The player random calculated: ${h}`),m.executeIn("helloEveryOne",[O],"teste4:"+game.user.id),d.COMMON_MODULE.debug(`Depois do teste4 seletivo: ${h}`)}catch(i){d.COMMON_MODULE.debug("Common socket error",i)}})}const f={MODULE_NAME:"common-assets",MODULE_VERSION:"common-assets-version"};let c=document;class A{name="common-assets";version="1.0.0";startVersion="";DIALOG_UTILS;REGION_UTILS;NPC_DIALOG;_prefix="CA:";_debugMode=!1;_printData=this._debugMode;formatCompactDate(t=new Date){const o=t.getFullYear().toString().padStart(4,"0"),e=(t.getMonth()+1).toString().padStart(2,"0"),n=t.getDate().toString().padStart(2,"0"),s=t.getHours().toString().padStart(2,"0"),i=t.getMinutes().toString().padStart(2,"0"),a=t.getSeconds().toString().padStart(2,"0"),l=t.getMilliseconds().toString().padStart(3,"0");return`${o}${e}${n}${s}${i}${a}${l}`}get prefix(){return c.COMMON_MODULE._printData?c.COMMON_MODULE.formatCompactDate(new Date)+" "+c.COMMON_MODULE._prefix:c.COMMON_MODULE._prefix}async startModule(){await this.addInitCommonAssetsChanges(),Hooks.callAll("onInitCommonModule",{})}async addReadyCommonAssetsChanges(){this.debug("Criando botão de ajuda de rolagem");const t=c.getElementById("roll-privacy");if(!t){this.error("Menu privacy não encontrado");return}const o=c.createElement("button");o.textContent="?",o.className="ui-control icon fa-solid fa-help common-assets-help",o.addEventListener("click",e=>{e.preventDefault();const n=game.journal.getName("Como Rolar Dados");if(this.log("Mensagem exibida ao clicar no botão ?"),!n){this.error("Journal não instalado!");return}n.sheet.render(!0)}),t.appendChild(o),this.debug("Botão de ajuda de rolagem criado")}async registerSetting(t,o=String){await game.settings.register(f.MODULE_NAME,t,{type:o})}async registerNewSettings(){this.debug("registerNewSettings:10,module_name:",this.name,",key=",f.MODULE_VERSION),this.debug("registerNewSettings:20,register in settings key:",f.MODULE_VERSION),this.registerSetting(f.MODULE_VERSION),this.debug("registerNewSettings:30, registered"),this.debug("registerNewSettings:40,module_name:",this.name)}async setSettings(t,o){await game.settings.set(f.MODULE_NAME,t,o)}async getSettings(t){return await game.settings.get(f.MODULE_NAME,t)}async addInitCommonAssetsChanges(){this.debug("addInitCommonAssetsChanges:10.1"),await this.registerNewSettings(),this.debug("addInitCommonAssetsChanges:20")}async updateVersions(t,o){t!==o&&(this.warnAboutUpdate(t,o),t=o,await this.setSettings(f.MODULE_VERSION,t))}async warnAboutUpdate(t,o){this.log(`Atualizando da versão : ${t} para a versão ${o}`)}async whaitFor(t,o=6e4,e=100){let n=0;return new Promise((i,a)=>{const l=setInterval(()=>{if(c.COMMON_MODULE.debug("Total time:",n," for function ",t),t()){clearInterval(l),i();return}n>o&&(c.COMMON_MODULE.debug("Timeout for test:",t),clearInterval(l),a(new Error("timeout while wait For in common module"))),n+=e},e)})}debugMode(t=void 0){return t===void 0||(c.COMMON_MODULE._debugMode=t),c.COMMON_MODULE._debugMode}logPrefix(t){c.COMMON_MODULE._prefix=t||"CA:"}genericLog(t,o,...e){const n=c.COMMON_MODULE.prefix;if(t(n,...e),!!c.COMMON_MODULE.debugMode())try{throw new Error("Thread trace "+o+" :"+n)}catch(s){console.error("log "+o+":",s)}}log(...t){c.COMMON_MODULE.genericLog(console.log,"log",...t)}info(...t){c.COMMON_MODULE.genericLog(console.log,"info",...t)}error(...t){c.COMMON_MODULE.genericLog(console.log,"error",...t)}warn(...t){c.COMMON_MODULE.genericLog(console.log,"warn",...t)}debug(...t){c.COMMON_MODULE.genericLog(console.log,"debug",...t)}}c=document,c.COMMON_MODULE=new A;function oe(){Hooks.once("init",async()=>{const r=document;r.COMMON_MODULE=new A,r.COMMON_MODULE.log("Módulo Common Assets inicalizando..."),await r.COMMON_MODULE.startModule()}),Hooks.once("ready",async()=>{if(!c.COMMON_MODULE.version){c.COMMON_MODULE.error("Módulo Common Assets não está instalado ou não foi iniciado corretamente.");return}game.user.isGM&&(c.COMMON_MODULE.log("GM detected, adding isGM class to body"),document.body.classList.add("isGM")),c.COMMON_MODULE.log("Módulo Common Assets call all onReadyCommonModule."),c.COMMON_MODULE.log("Módulo Common Assets sent the messages."),c.COMMON_MODULE.log("Módulo Common Assets launched onReadyCommonModule."),c.COMMON_MODULE.log(`Getting the old version with key:${f.MODULE_VERSION}`);const r=await c.COMMON_MODULE.getSettings(f.MODULE_VERSION);let t="1.0.6";if(await c.COMMON_MODULE.addReadyCommonAssetsChanges(),te(),Hooks.callAll("onReadyCommonModule",{}),r===t){c.COMMON_MODULE.log(`Módulo Common Assets v.${t} carregado com sucesso!`);return}await c.COMMON_MODULE.updateVersions(r,t),c.COMMON_MODULE.log(`Módulo Common Assets ${c.COMMON_MODULE.version} carregado com sucesso!`)})}oe();const p=document,R={MODULE_NAME:"common-assets",TOOGLE_VISIBILITY:"common-assets-toogle-visibility-regions"};Hooks.on("onInitCommonModule",()=>{console.log("Loading Region Utils V1.1.1"),p.COMMON_MODULE.REGION_UTILS={sendMessageToChat:(r,t)=>{const o={user:r,speaker:"Game Master",content:t,whisper:game.users.filter(e=>e.isGM).map(e=>e._id)};ChatMessage.create(o,{})},stop:r=>{const t=r?.region?.shapes[0];if(console.log("event:",r,",shape:",t),!t){console.error("shape not found");return}const o=t.width,e=t.height,n=t.x+Math.round(o/2),s=t.y+Math.round(e/2),i=r?.data?.token;i.x=n,i.y=s,console.log("Token indo para x:",n,",y:",s),i.update({x:i.x,y:i.y})},toggleVisibilityRegions:async()=>{p.COMMON_MODULE.debug("toggleVisibilityRegions called");const r=game.scenes.current;if(!r){p.COMMON_MODULE.log("No scene active");return}r.regions.forEach(t=>{p.COMMON_MODULE.debug("region",t),t.update({visibility:!t.visibility})})},registerKeybindings:async()=>{game.keybindings.register(R.MODULE_NAME,R.TOOGLE_VISIBILITY,{name:"Alternar visão das regiões da cena",hint:"Liga/desliga visibilidade das regiões da cena atual.",editable:[{key:"KeyG",modifiers:["Shift"]}],onDown:async()=>{p.COMMON_MODULE.debug("onDown will be called"),p.COMMON_MODULE.REGION_UTILS.toggleVisibilityRegions()},restricted:!0,reservedModifiers:[],precedence:CONST.KEYBINDING_PRECEDENCE.NORMAL})}},p.COMMON_MODULE.REGION_UTILS.registerKeybindings()});const M=document;function re(){M.COMMON_MODULE.HIDE_UNIDENTIFY={removeButtonsFromItemContext:(r,t)=>{if(M.COMMON_MODULE.debug("removeButtonsFromItemContext called"),game.user.isGM){M.COMMON_MODULE.debugMode&&M.COMMON_MODULE.debug("is GM - not removing Identify button from Item Sheet context menu");return}if(r.system.identified){M.COMMON_MODULE.debug("Item:",r.name," - Item is identified - not removing Identify button from Item Sheet context menu");return}["DND5E.Identify","DND5E.ContextMenuActionAttune"].forEach(n=>{const s=t.findIndex(i=>i.name===n);s!==-1&&(M.COMMON_MODULE.debug("Item:",r.name," - Removing",n,"button from Item Sheet context menu at index",s),t.splice(s,1))})},removeItemSheetIdentifyInformations:(r,t)=>{if(game.user.isGM){M.COMMON_MODULE.debugMode&&M.COMMON_MODULE.debug("removing Info from Item Sheet");return}r.item.system.identified||(M.querySelectorAll(".dnd5e.sheet.item .sheet-header .item-subtitle label:has(input:not([disabled]))").forEach(e=>e.remove()),M.querySelectorAll(".toggle-identified").forEach(e=>e.remove()))},removeCharacterSheetIdentifyInformation:r=>{if(game.user.isGM){if(!M.COMMON_MODULE.debugMode){M.COMMON_MODULE.debug("removing Info from Item Sheet");return}M.COMMON_MODULE.debug("is GM in debug mode - removing information from Item Sheet")}}},Hooks.on("renderItemSheet5e",(r,t)=>{M.COMMON_MODULE.debug("dnd5e.renderItemSheet5e called"),M.COMMON_MODULE.HIDE_UNIDENTIFY.removeItemSheetIdentifyInformations(r,t)}),Hooks.on("dnd5e.getItemContextOptions",(r,t)=>{M.COMMON_MODULE.debug("dnd5e.getItemContextOptions called"),M.COMMON_MODULE.HIDE_UNIDENTIFY.removeButtonsFromItemContext(r,t)}),Hooks.on("renderDocumentSheetV2",r=>{M.COMMON_MODULE.debug("renderDocumentSheetV2 called with parameters:",r),M.COMMON_MODULE.HIDE_UNIDENTIFY.removeCharacterSheetIdentifyInformation(r)})}Hooks.on("onReadyCommonModule",()=>{M.COMMON_MODULE.debug("onReadyCommonModule called"),re()});class ne{constructor(t,o,e=!1,n="screen",s){this.action=t,this.label=o,this.defaultValue=e,this.type=n,this.callback=s}}const D=document;class ie{constructor(){}createButton(t,o,e=!1,n="screen",s){return new ne(t,o,e,n,s)}createDialog(t,o="",e,n,s,i=void 0,a=void 0,l,O){if(D.COMMON_MODULE.debug("Dialog Utils creating dialog width: ",l," height: ",O),!n||!n.length||n.length===0)throw new Error("DIALOG_UTILS.createDialog: buttons array must have at least one button");const h={window:{title:t,resizable:!0},content:`<style>${o}</style>
|
|
2
|
+
<div>${e}</div>`,buttons:n,submit:s,position:{width:l,height:O,left:i,top:a}};D.COMMON_MODULE.debug("Dialog Utils dialog options: ",h);const g=new foundry.applications.api.DialogV2(h);return g.render({force:!0}),g}}Hooks.on("onReadyCommonModule",async r=>{D.COMMON_MODULE.debug("Dialog Utils loading on onReadyCommonModule"),Hooks.callAll("onInitDialogUtils",{}),D.COMMON_MODULE.DIALOG_UTILS=new ie,D.COMMON_MODULE.debug("Dialog Utils ready"),Hooks.callAll("onReadyDialogUtils",{})});const u=document;function se(r){let t=u.querySelectorAll("div.ability-score[data-ability='hon']");if(t.length==0){u.COMMON_MODULE.debug("This sheet not contain honrror field or system not enable honrror field");return}u.COMMON_MODULE.debug("Hability hero removed, npc sheet detected"),t.forEach(o=>o.remove())}function ae(r){if(!game.user.isGM)return;let t=r?.querySelectorAll("div.mod span.operator.increment");if(t.length==0){u.COMMON_MODULE.error("Hability Hero operator increment not found");return}let o=t.item(0);if(o.onclick=e=>{e.preventDefault();const n=document.querySelectorAll("form.editable div.ability-score.flipped[data-ability='hon'] input");if(n.length!=1){u.COMMON_MODULE.error("Hability hero increment hero points not found input to increment ore found more then one, close others sheets before changing hero points");return}const s=n.item(0);if(s.value==null||s.value==""){u.COMMON_MODULE.error("Hability hero increment hero points not found input value to increment");return}const a=parseInt(s.value,10)+1;s.value=a.toString(),u.COMMON_MODULE.info(`Hability hero increment hero points to ${a}`)},t=r?.querySelectorAll("div.mod span.operator.reduce"),t.length==0){u.COMMON_MODULE.error("Hability Hero operator reduce not found");return}o=t.item(0),o.onclick=e=>{e.preventDefault();const n=document.querySelectorAll("form.editable div.ability-score.flipped[data-ability='hon'] input");if(n.length!=1){u.COMMON_MODULE.error("Hability hero increment hero points not found input to increment ore found more then one, close others sheets before changing hero points");return}const s=n.item(0);if(s.value==null||s.value==""){u.COMMON_MODULE.error("Hability hero increment hero points not found input value to increment, close others sheets before changing hero points");return}const i=parseInt(s.value,10);if(i==0){u.COMMON_MODULE.error("You haven´t hero points to decrement");return}const a=Math.floor(i/2);s.value=a.toString(),u.COMMON_MODULE.info(`Hability hero decrement hero points to ${a}`)}}function le(r){let t={};r.onclick=o=>{o.preventDefault(),u.COMMON_MODULE.log("clicou na habilidade");const e=u.COMMON_MODULE.DIALOG_UTILS.createButton("cancel","Cancelar",!0,"action",n=>{t.close()});u.COMMON_MODULE.log("Hero Points dialog closed."),t=u.COMMON_MODULE.DIALOG_UTILS.createDialog("Sobre Hero Points","",`
|
|
3
|
+
<div class="hero-points-info-content">
|
|
4
|
+
<img class="heroic-action-img"
|
|
5
|
+
src="/modules/common-assets/images/cover/heropoint.webp"
|
|
6
|
+
alt="Ícone representando uma ação heróica em um RPG de fantasia"
|
|
7
|
+
/>
|
|
8
|
+
|
|
9
|
+
<p>
|
|
10
|
+
<strong>Hero Points</strong> são semelhantes a pontos de inspiração, mas não são limitados a 1.
|
|
11
|
+
Você começa com zero pontos e eles são acumulativos, diferente de inspiração, em que se pode ter apenas 1 ponto ativo.
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
<p>
|
|
15
|
+
<strong>Como obter:</strong> quando chegar na sua vez, se você fizer algo que incremente não somente o seu
|
|
16
|
+
background como o de algum colega (semelhante ao ponto de inspiração, mas sem precisar se colocar em situação ruim),
|
|
17
|
+
você ganha 1 ponto. A ação deve melhorar a história tanto do seu personagem quanto a dos demais jogadores.
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
<p>
|
|
21
|
+
<strong>Exemplo de ação heróica:</strong> você sabe que um meio-orc do grupo tem fobia de aranha.
|
|
22
|
+
O mestre descreve uma aranha se aproximando e o jogador dono do personagem não percebe.
|
|
23
|
+
Você decide atacar a aranha antes que seu colega se desespere e note a presença dela.
|
|
24
|
+
Ou, se você é um bardo e sabe que um dos jogadores teve um amor perdido,
|
|
25
|
+
canta uma música na sua rodada para dar inspiração dizendo que é sobre o amor perdido desse personagem.
|
|
26
|
+
É importante que tudo faça sentido na história atual, na história do outro jogador e na sua própria.
|
|
27
|
+
Você pode inclusive ajustar a narração, por exemplo, inventando que havia uma aranha que o mestre nem citou
|
|
28
|
+
e dizer que a matou com uma flecha antes que seu amigo entrasse em pânico.
|
|
29
|
+
</p>
|
|
30
|
+
|
|
31
|
+
<p>
|
|
32
|
+
A jogada deve ser rápida e já pensada durante a vez dos outros; você não pode parar para planejar apenas quando sua vez começa.
|
|
33
|
+
Ela precisa ser ágil para incrementar a narração. Se tudo isso for atendido e o mestre concordar,
|
|
34
|
+
1 ponto de heroísmo é acrescentado ao personagem.
|
|
35
|
+
</p>
|
|
36
|
+
|
|
37
|
+
<p>
|
|
38
|
+
<strong>Usando uma Ação Heróica (gastando pontos):</strong> o ponto ganho pode ser gasto para realizar uma ação especial envolvendo dois personagens;
|
|
39
|
+
o alvo pode ser um jogador ou um NPC, aliado ou inimigo.
|
|
40
|
+
</p>
|
|
41
|
+
|
|
42
|
+
<p>
|
|
43
|
+
<strong>Como reduzir os pontos:</strong> apenas o Mestre pode reduzir ou aumentar o valor total. Os pontos não são gastos de 1 em 1, quando os pontos são gastos,
|
|
44
|
+
divide-se o total por 2 (arredondando para baixo).
|
|
45
|
+
Exemplos: se você tem 5 pontos, passa a ter 2; se tem 3, passa a ter 1; se tem 1 ponto, passa a ter 0.
|
|
46
|
+
</p>
|
|
47
|
+
</div>
|
|
48
|
+
`,[e],new Array)}}function ce(r){const t=u.querySelectorAll("form.sheet"),o=t.item(0)?.classList.contains("editable")??!1;if(t.length==0){u.COMMON_MODULE.error("Hability hero not enable to convert for hero, your cmpaing not use? Code error: 01");return}u.COMMON_MODULE.debug("Hability hero found : "+t.length),t.forEach(e=>{e.querySelectorAll("div.ability-score.flipped[data-ability='hon']").forEach(s=>{const i=s;if(u.COMMON_MODULE.debug("found one hability "+i.innerHTML,",isEditable",o),i.querySelectorAll("div.score").length!=1){u.COMMON_MODULE.error("Hability hero not enable to convert for hero, your cmpaing not use? Code error: 02");return}let l=i.querySelectorAll("div.score").item(0)?.innerHTML??"0";if(!game.user.isGM){let h=i.querySelectorAll("input");o&&(l=h.item(0).value)}u.COMMON_MODULE.debug("Hability hero score: ",l),i.innerHTML=`
|
|
49
|
+
<label class="common-assets attribute" title="clique para mais informações">hero</label>
|
|
50
|
+
<div class="mod">
|
|
51
|
+
<span class="operator reduce" title"para editar, altere o personagem para o modo editável"></span>
|
|
52
|
+
<span class="operator increment" title"para editar, altere o personagem para o modo editável"></span>
|
|
53
|
+
</div>
|
|
54
|
+
<div class="score">${l}</div>
|
|
55
|
+
`,ae(i);const O=i.querySelectorAll("label")?.item(0);if(O==null){u.COMMON_MODULE.warn("Hability hero not enable to convert for hero, your cmpaing not use? Code error: 01");return}le(O)})})}function ue(){Hooks.on("renderDocumentSheetV2",async r=>{const t=r;if(!t.actor){u.COMMON_MODULE.debug("Isnt a actor sheet");return}if(u.COMMON_MODULE.debug("Hability hero called ",t),t.actor.type!="character"){se(),u.COMMON_MODULE.debug("Hability hero ignoreted sheet because isnt a player sheet, type:",t.actor.type);return}ce()})}Hooks.on("onReadyCommonModule",async()=>{u.COMMON_MODULE.info("Starting Hability hero processing"),ue(),u.COMMON_MODULE.info("Hability hero initialized")});var U={},b={},E={},G;function N(){if(G)return E;G=1,Object.defineProperty(E,"__esModule",{value:!0}),E.StringsUtil=void 0;class r{left(o,e){return e>0?o.slice(0,e):""}trim(o){return o.trim()}right(o,e){return e>0?o.slice(-e):""}repeat(o,e,n){return e>0?Array.from({length:e},()=>o).join(n):""}leftPadding(o,e,n){return e>0?o.padStart(e,n).slice(-e):""}rightPadding(o,e,n){return e>0?o.padEnd(e,n).slice(0,e):""}count(o,e){return o.split(e).length-1}hashNumber(o){let e=0,n,s;if(o.length===0)return e;for(n=0;n<o.length;n++)s=o.codePointAt(n),e=(e<<5)-e+s,e|=0;return e}hashString(o){return this.hashNumber(o).toString(36)}}return E.StringsUtil=r,E}var H;function T(){if(H)return b;H=1,Object.defineProperty(b,"__esModule",{value:!0}),b.DatesUtil=void 0;const r=N();class t{stringUtil=new r.StringsUtil;addDays(e,n){const s=new Date(e);return s.setDate(e.getDate()+n),s}parseYYYYMMDDHHMMSS(e){if(e.length!==14)throw new Error("Date format YYYYMMDDHHMMSS incorrect!");const n=this.stringUtil.right(e,6);if(isNaN(Number(n)))throw new Error("Time must be numeric integer");const s=this.stringUtil.left(n,2);if(isNaN(Number(s)))throw new Error("Hour must be numeric integer");const i=this.stringUtil.left(this.stringUtil.right(n,4),2);if(isNaN(Number(i)))throw new Error("Minute must be numeric integer");const a=this.stringUtil.right(n,2);if(isNaN(Number(a)))throw new Error("Second must be numeric integer");const l=this.parseYYYYMMDD(this.stringUtil.left(e,8));return l.setHours(Number.parseInt(s,10)),l.setMinutes(Number.parseInt(i,10)),l.setSeconds(Number.parseInt(a,10)),l}parseYYYYMMDD(e){if(e.length!==8)throw new Error("Date format YYYYMMDD incorrect!");const n=this.stringUtil.left(e,4);if(isNaN(Number(n)))throw new Error("Year must be numeric integer");const s=this.stringUtil.right(this.stringUtil.left(e,6),2);if(isNaN(Number(s)))throw new Error("Month must be numeric integer");const i=this.stringUtil.right(e,2);if(isNaN(Number(i)))throw new Error("Day must be numeric integer");return this.parse(Number.parseInt(n,10),Number.parseInt(s,10),Number.parseInt(i,10))}parse(e,n,s,i=0,a=0,l=0){return new Date(e,n-1,s,i,a,l)}getYear(e){return e.getFullYear()}getMonth(e){return e.getMonth()+1}getMonthIndex(e){return e.getMonth()}getDay(e){return e.getDate()}getDayOfWeak(e){return e.getDay()+1}getDayOfWeakIndex(e){return e.getDay()}toString(e,n=14){if(n<1)return"";n>14&&(n=14);const s=e.getFullYear().toString().padStart(4,"0"),i=(e.getMonth()+1).toString().padStart(2,"0"),a=e.getDate().toString().padStart(2,"0"),l=e.getHours().toString().padStart(2,"0"),O=e.getMinutes().toString().padStart(2,"0"),h=e.getSeconds().toString().padStart(2,"0"),g=`${s}${i}${a}${l}${O}${h}`;return this.stringUtil.left(g,n)}}return b.DatesUtil=t,b}var y={},k;function de(){if(k)return y;k=1,Object.defineProperty(y,"__esModule",{value:!0}),y.KeyTool=void 0;const r=N(),t="10";class o{stringUtil=new r.StringsUtil;generateUUID(){var n=new Date().getTime(),s=typeof performance<"u"&&performance.now&&performance.now()*1e3||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(i){var a=Math.random()*16;return n>0?(a=(n+a)%16|0,n=Math.floor(n/16)):(a=(s+a)%16|0,s=Math.floor(s/16)),(i==="x"?a:a&3|8).toString(16)})}build(n,s){if(n>=1e3||n<0)throw new Error("Cluster must be between 0-999");if(s<0)throw new Error("ProccessID must be >= 0");s=s%1e6;const i=this.stringUtil.right("0000"+Math.round(Math.random()*9999),4),a=this.generateUUID();return t+this.stringUtil.right("000"+n,3)+this.stringUtil.right("000000"+s,6)+i+"--"+a}}return y.KeyTool=o,y}var v={},x;function Me(){if(x)return v;x=1,Object.defineProperty(v,"__esModule",{value:!0}),v.ObjectsUtil=void 0;class r{shallowCopy(o){return JSON.parse(JSON.stringify(o))}partialCopy(o,e,n){const s=this.shallowCopy(e);for(const i of n)s[i]=o[i];return s}}return v.ObjectsUtil=r,v}var I={},_={},q;function F(){if(q)return _;q=1,Object.defineProperty(_,"__esModule",{value:!0}),_.InjectorFactory=void 0;class r{factory;constructor(o){this.factory=o}build(){return this.factory()}}return _.InjectorFactory=r,_}var C={},Y;function P(){if(Y)return C;Y=1,Object.defineProperty(C,"__esModule",{value:!0}),C.injectController=void 0;const r=F();class t{registrations=new Map;registerByClass(e){let n;return e instanceof r.InjectorFactory?n=e.build().constructor.name:n=e.constructor.name,this.registerByName(n,e)}registerByName(e,n){return this.registrations.set(e,n),this}resolve(e){if(!this.registrations.has(e))throw new Error("key ["+e+"] not registered");const n=this.registrations.get(e);return n instanceof r.InjectorFactory?n.build():n}has(e){return typeof e!="string"&&(e=e.constructor.name),this.registrations.has(e)}clearAll(){return this.registrations.clear(),this}unregister(e){return typeof e!="string"&&(e=e.constructor.name),this.registrations.delete(e),this}}return C.injectController=new t,C}var B;function ge(){return B||(B=1,(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.injectController=r.InjectorFactory=void 0;var t=F();Object.defineProperty(r,"InjectorFactory",{enumerable:!0,get:function(){return t.InjectorFactory}});var o=P();Object.defineProperty(r,"injectController",{enumerable:!0,get:function(){return o.injectController}})})(I)),I}var S={},w={},V;function K(){return V||(V=1,(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.Level=void 0,(function(t){t.CRITICAL="CRITICAL",t.ERROR="ERROR",t.WARN="WARN",t.INFO="INFO",t.DEBUG="DEBUG"})(r.Level||(r.Level={}))})(w)),w}var j={},W;function me(){return W||(W=1,(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.LogGenericImpl=r.BUILD_DATE_KEY=void 0;const t=T(),o=P(),e=K();r.BUILD_DATE_KEY="LogGenericImpl.BuildDate";const n={[e.Level.DEBUG]:0,[e.Level.INFO]:1,[e.Level.WARN]:2,[e.Level.ERROR]:3,[e.Level.CRITICAL]:4};class s{#t=e.Level.INFO;#o;#r;#n;#i;#s;#e;#a;#l=new t.DatesUtil;constructor(a={prefix:"",hasDate:!0,hasLevel:!0,format:""}){const l="LogGenericImpl.";this.#o=o.injectController.has(l+e.Level.CRITICAL)?o.injectController.resolve(l+e.Level.CRITICAL):console.error,this.#r=o.injectController.has(l+e.Level.ERROR)?o.injectController.resolve(l+e.Level.ERROR):console.error,this.#n=o.injectController.has(l+e.Level.WARN)?o.injectController.resolve(l+e.Level.WARN):console.warn,this.#i=o.injectController.has(l+e.Level.INFO)?o.injectController.resolve(l+e.Level.INFO):console.info,this.#s=o.injectController.has(l+e.Level.DEBUG)?o.injectController.resolve(l+e.Level.DEBUG):console.debug,this.#a=o.injectController.has(r.BUILD_DATE_KEY)?o.injectController.resolve(r.BUILD_DATE_KEY):()=>new Date,this.#e=a}level(a=void 0){return a!=null&&(this.#t=a),this.#t}isCompatible(a){const l=n[this.#t];return n[a]>=l}log(a,l,...O){if(!this.isCompatible(l))return;const h=this.#l.toString(this.#a(),14),g=[];this.#e.prefix&&g.push(this.#e.prefix),this.#e.hasLevel&&g.push(`[${l}]`),this.#e.hasDate&&g.push(h);const X=g.join(" ");X?a(X,...O):a(...O)}critical(...a){this.log(this.#o,e.Level.CRITICAL,...a)}error(...a){this.log(this.#r,e.Level.ERROR,...a)}warn(...a){this.log(this.#n,e.Level.WARN,...a)}info(...a){this.log(this.#i,e.Level.INFO,...a)}debug(...a){this.log(this.#s,e.Level.DEBUG,...a)}}r.LogGenericImpl=s})(j)),j}var z;function Oe(){return z||(z=1,(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.BUILD_DATE_KEY=r.LogGenericImpl=r.Level=void 0;var t=K();Object.defineProperty(r,"Level",{enumerable:!0,get:function(){return t.Level}});var o=me();Object.defineProperty(r,"LogGenericImpl",{enumerable:!0,get:function(){return o.LogGenericImpl}}),Object.defineProperty(r,"BUILD_DATE_KEY",{enumerable:!0,get:function(){return o.BUILD_DATE_KEY}})})(S)),S}var $;function he(){return $||($=1,(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.BUILD_DATE_KEY=r.LogGenericImpl=r.Level=r.InjectorFactory=r.injectController=r.StringsUtil=r.ObjectsUtil=r.KeyTool=r.DatesUtil=void 0;var t=T();Object.defineProperty(r,"DatesUtil",{enumerable:!0,get:function(){return t.DatesUtil}});var o=de();Object.defineProperty(r,"KeyTool",{enumerable:!0,get:function(){return o.KeyTool}});var e=Me();Object.defineProperty(r,"ObjectsUtil",{enumerable:!0,get:function(){return e.ObjectsUtil}});var n=N();Object.defineProperty(r,"StringsUtil",{enumerable:!0,get:function(){return n.StringsUtil}});var s=ge();Object.defineProperty(r,"injectController",{enumerable:!0,get:function(){return s.injectController}}),Object.defineProperty(r,"InjectorFactory",{enumerable:!0,get:function(){return s.InjectorFactory}});var i=Oe();Object.defineProperty(r,"Level",{enumerable:!0,get:function(){return i.Level}}),Object.defineProperty(r,"LogGenericImpl",{enumerable:!0,get:function(){return i.LogGenericImpl}}),Object.defineProperty(r,"BUILD_DATE_KEY",{enumerable:!0,get:function(){return i.BUILD_DATE_KEY}})})(U)),U}var J=he();J.injectController.registerByName("HelloWorld","Hello World"),console.log(J.injectController.resolve("HelloWorld")+" InjectController")})();
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "taulukko-common-scripts-dnd5ed",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Taulukko Common Scripts for Foundry dnd5ed",
|
|
5
|
+
"main": "dist/common-scripts.iife.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
+
"build": "tsc && vite build",
|
|
9
|
+
"vite-version": "vite --version"
|
|
10
|
+
},
|
|
11
|
+
"keywords": ["foundry", "dnd5e", "common-scripts", "utilities"],
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"files": [
|
|
14
|
+
"dist/**/*"
|
|
15
|
+
],
|
|
16
|
+
"author": "Edson Vicente Carli Junior",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"typescript": "^5.9.2",
|
|
20
|
+
"vite": "^7.3.0"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"taulukko-commons": "^1.3.0"
|
|
24
|
+
}
|
|
25
|
+
}
|