diff --git a/lang/en.json b/lang/en.json index a48c8b7..209d555 100644 --- a/lang/en.json +++ b/lang/en.json @@ -27,9 +27,12 @@ "ACTIVEAURAS.FORM_Height": "Check Token Height", "ACTIVEAURAS.FORM_Alignment": "Check Alignment", "ACTIVEAURAS.FORM_Type": "Check creature type", + "ACTIVEAURAS.FORM_Any": "Any", "ACTIVEAURAS.FORM_Good": "Good", "ACTIVEAURAS.FORM_Neutral": "Neutral", "ACTIVEAURAS.FORM_Evil": "Evil", + "ACTIVEAURAS.FORM_Lawful": "Lawful", + "ACTIVEAURAS.FORM_Chaotic": "Chaotic", "ACTIVEAURAS.FORM_SaveEnable": "Save Type To Prevent", "ACTIVEAURAS.FORM_SaveDC": "Save DC", "ACTIVEAURAS.FORM_TypePrompt": "humanoid/beast etc", diff --git a/lang/es.json b/lang/es.json index bf9d474..7ad36ab 100644 --- a/lang/es.json +++ b/lang/es.json @@ -27,9 +27,12 @@ "ACTIVEAURAS.FORM_Height": "Comprobar altura del token", "ACTIVEAURAS.FORM_Alignment": "Comprobar Alineamiento", "ACTIVEAURAS.FORM_Type": "Comprobar tipo de criatura", + "ACTIVEAURAS.FORM_Any": "Ningún", "ACTIVEAURAS.FORM_Good": "Bueno", "ACTIVEAURAS.FORM_Neutral": "Neutral", "ACTIVEAURAS.FORM_Evil": "Malvado", + "ACTIVEAURAS.FORM_Lawful": "Legítimo", + "ACTIVEAURAS.FORM_Chaotic": "Caótico", "ACTIVEAURAS.FORM_SaveEnable": "Tipo de Salvación para evitar", "ACTIVEAURAS.FORM_SaveDC": "CD de la TS", "ACTIVEAURAS.FORM_TypePrompt": "humanoide/bestia, etc", diff --git a/lang/fr.json b/lang/fr.json index c95bb54..7211630 100644 --- a/lang/fr.json +++ b/lang/fr.json @@ -27,9 +27,12 @@ "ACTIVEAURAS.FORM_Height": "Vérifier la Hauteur du Token", "ACTIVEAURAS.FORM_Alignment": "Vérifier l'Alignement ", "ACTIVEAURAS.FORM_Type": "Vérifier le type de la créature", + "ACTIVEAURAS.FORM_Any": "N'importe quel", "ACTIVEAURAS.FORM_Good": "Bon", "ACTIVEAURAS.FORM_Neutral": "Neutre", "ACTIVEAURAS.FORM_Evil": "Mauvais", + "ACTIVEAURAS.FORM_Lawful": "Légitime", + "ACTIVEAURAS.FORM_Chaotic": "Chaotique", "ACTIVEAURAS.FORM_SaveEnable": "Type de la sauvegarde", "ACTIVEAURAS.FORM_SaveDC": "DD de la sauvegarde", "ACTIVEAURAS.FORM_TypePrompt": "ex: humanoid/beast ... liste en anglais", diff --git a/lang/ja.json b/lang/ja.json index e08eeb5..8f0567a 100644 --- a/lang/ja.json +++ b/lang/ja.json @@ -27,9 +27,12 @@ "ACTIVEAURAS.FORM_Height": "コマの高度を考慮する", "ACTIVEAURAS.FORM_Alignment": "属性を確認する", "ACTIVEAURAS.FORM_Type": "クリーチャーの種別を確認する", + "ACTIVEAURAS.FORM_Any": "[EN] Any", "ACTIVEAURAS.FORM_Good": "善", "ACTIVEAURAS.FORM_Neutral": "中立", "ACTIVEAURAS.FORM_Evil": "悪", + "ACTIVEAURAS.FORM_Lawful": "[EN] Lawful", + "ACTIVEAURAS.FORM_Chaotic": "[EN] Chaotic", "ACTIVEAURAS.FORM_SaveEnable": "セーヴ時の能力値", "ACTIVEAURAS.FORM_SaveDC": "セーヴDC", "ACTIVEAURAS.FORM_TypePrompt": "humanoid/beast など", diff --git a/lang/ko.json b/lang/ko.json index b1a5245..12d6754 100644 --- a/lang/ko.json +++ b/lang/ko.json @@ -27,9 +27,12 @@ "ACTIVEAURAS.FORM_Height": "토큰 높이 확인", "ACTIVEAURAS.FORM_Alignment": "성향 확인", "ACTIVEAURAS.FORM_Type": "생물체 유형 확인", + "ACTIVEAURAS.FORM_Any": "[EN] Any", "ACTIVEAURAS.FORM_Good": "선", "ACTIVEAURAS.FORM_Neutral": "중립", "ACTIVEAURAS.FORM_Evil": "악", + "ACTIVEAURAS.FORM_Lawful": "[EN] Lawful", + "ACTIVEAURAS.FORM_Chaotic": "[EN] Chaotic", "ACTIVEAURAS.FORM_SaveEnable": "방해할 내성 굴림 유형", "ACTIVEAURAS.FORM_SaveDC": "내성 굴림 난이도", "ACTIVEAURAS.FORM_TypePrompt": "인간형/야수 기타", diff --git a/lang/zh-tw.json b/lang/zh-tw.json index 4d07d4e..3ca7601 100644 --- a/lang/zh-tw.json +++ b/lang/zh-tw.json @@ -27,9 +27,12 @@ "ACTIVEAURAS.FORM_Height": "檢查棋子高度", "ACTIVEAURAS.FORM_Alignment": "檢查對齊", "ACTIVEAURAS.FORM_Type": "檢查生物類型", + "ACTIVEAURAS.FORM_Any": "[EN] Any", "ACTIVEAURAS.FORM_Good": "好", "ACTIVEAURAS.FORM_Neutral": "中性", "ACTIVEAURAS.FORM_Evil": "邪惡", + "ACTIVEAURAS.FORM_Lawful": "[EN] Lawful", + "ACTIVEAURAS.FORM_Chaotic": "[EN] Chaotic", "ACTIVEAURAS.FORM_SaveEnable": "保存類型到預設", "ACTIVEAURAS.FORM_SaveDC": "保存DC", "ACTIVEAURAS.FORM_TypePrompt": "類人生物/野獸等", diff --git a/src/AAhtml.js b/src/AAhtml.js index 2871810..70d5cdc 100644 --- a/src/AAhtml.js +++ b/src/AAhtml.js @@ -17,21 +17,26 @@ Hooks.on("renderActiveEffectConfig", async (sheet, html) => { const AuraTab = game.i18n.format("ACTIVEAURAS.tabname"); const FormCheckHeight = game.i18n.format("ACTIVEAURAS.FORM_Height"); const FormCheckAlignment = game.i18n.format("ACTIVEAURAS.FORM_Alignment"); - const FormCheckType = game.i18n.format("ACTIVEAURAS.FORM_Type") - const FormGood = game.i18n.format("ACTIVEAURAS.FORM_Good") - const FormNeutral = game.i18n.format("ACTIVEAURAS.FORM_Neutral") - const FormEvil = game.i18n.format("ACTIVEAURAS.FORM_Evil") - const FormTypePrompt = game.i18n.format("ACTIVEAURAS.FORM_TypePrompt") - const FormRadiusPrompt = game.i18n.format("ACTIVEAURAS.FORM_RadiusPrompt") - const HostileTurn = game.i18n.format("ACTIVEAURAS.FORM_HostileTurn") - const ActivateOnce = game.i18n.format("ACTIVEAURAS.FORM_ActivateOnce") - const Wildcard = game.i18n.format("ACTIVEAURAS.FORM_Wildcard") - const Extra = game.i18n.format("ACTIVEAURAS.FORM_Extra") + const FormCheckType = game.i18n.format("ACTIVEAURAS.FORM_Type"); + const FormAny = game.i18n.format("ACTIVEAURAS.FORM_Any"); + const FormGood = game.i18n.format("ACTIVEAURAS.FORM_Good"); + const FormNeutral = game.i18n.format("ACTIVEAURAS.FORM_Neutral"); + const FormEvil = game.i18n.format("ACTIVEAURAS.FORM_Evil"); + const FormLawful = game.i18n.format("ACTIVEAURAS.FORM_Lawful"); + const FormChaotic = game.i18n.format("ACTIVEAURAS.FORM_Chaotic"); + const FormTypePrompt = game.i18n.format("ACTIVEAURAS.FORM_TypePrompt"); + const FormRadiusPrompt = game.i18n.format("ACTIVEAURAS.FORM_RadiusPrompt"); + const HostileTurn = game.i18n.format("ACTIVEAURAS.FORM_HostileTurn"); + const ActivateOnce = game.i18n.format("ACTIVEAURAS.FORM_ActivateOnce"); + const Wildcard = game.i18n.format("ACTIVEAURAS.FORM_Wildcard"); + const Extra = game.i18n.format("ACTIVEAURAS.FORM_Extra"); const tab = ` ${AuraTab}`; let type = flags[AA_MODULE_NAME]?.type ? flags[AA_MODULE_NAME]?.type : ""; - let alignment = flags[AA_MODULE_NAME]?.alignment ? flags[AA_MODULE_NAME]?.alignment : ""; + let alignment = flags[AA_MODULE_NAME]?.alignment ? flags[AA_MODULE_NAME]?.alignment : {}; + let gne_alignment = alignment?.gne ? alignment?.gne : ""; + let lnc_alignment = alignment?.lnc ? alignment?.lnc : ""; let contents = `
@@ -43,9 +48,9 @@ Hooks.on("renderActiveEffectConfig", async (sheet, html) => {
@@ -55,11 +60,17 @@ Hooks.on("renderActiveEffectConfig", async (sheet, html) => {
- + + + + + +
@@ -114,12 +125,16 @@ Hooks.on("renderActiveEffectConfig", async (sheet, html) => {
`; html.find(".tabs .item").last().after(tab); - if (!flags[AA_MODULE_NAME]?.applied) html.find(".tab").last().after(contents); - else html.find(".tab").last().after(appliedAuraContent); + if (!flags[AA_MODULE_NAME]?.applied) { + html.find(".tab").last().after(contents); + } + else { + html.find(".tab").last().after(appliedAuraContent); + } - let $isAura = html.find(`input[name="flags.${AA_MODULE_NAME}.isAura"]`) - let $specifics = html.find(`#specifics`) - let $targets = html.find(`select[name="flags.${AA_MODULE_NAME}.aura"]`) + let $isAura = html.find(`input[name="flags.${AA_MODULE_NAME}.isAura"]`); + let $specifics = html.find(`#specifics`); + let $targets = html.find(`select[name="flags.${AA_MODULE_NAME}.aura"]`); $isAura.on("change", function () { @@ -130,12 +145,12 @@ Hooks.on("renderActiveEffectConfig", async (sheet, html) => { break; case false: $targets.closest(".form-group").hide(500); - $specifics.hide(500) + $specifics.hide(500); break; } html.css({ height: "auto" }); $targets.trigger("change") - }) + }); $targets.on("change", function () { const targets = $(this).val(); @@ -148,7 +163,7 @@ Hooks.on("renderActiveEffectConfig", async (sheet, html) => { } } html.css({ height: "auto" }); - }) + }); $isAura.trigger("change"); html.css({ height: "auto" }); }); \ No newline at end of file diff --git a/src/aura.js b/src/aura.js index 6960be8..24b773d 100644 --- a/src/aura.js +++ b/src/aura.js @@ -20,7 +20,7 @@ class ActiveAuras { const sceneCombat = game.combats.filter(c => c.scene?.id === sceneID) if (game.settings.get("ActiveAuras", "combatOnly") && !sceneCombat[0]?.started) { if (AAdebug) { console.warn("Active Auras not active when not in combat") } - return;w + return; } if (sceneID !== canvas.id) return ui.notifications.warn("An update was called on a non viewed scene, auras will be updated when you return to that scene") @@ -122,7 +122,7 @@ class ActiveAuras { static UpdateToken(map, canvasToken, tokenId) { if (canvasToken.data.flags['multilevel-tokens']) return; if (canvasToken.actor === null) return; - if (canvasToken.actor.data.type == "vehicle") return + if (canvasToken.actor.data.type == "vehicle") return; let tokenAlignment; if (game.system.id === "dnd5e" || game.system.id === "sw5e") { try { @@ -132,32 +132,47 @@ class ActiveAuras { } } const MapKey = canvasToken.scene.id; - let MapObject = AuraMap.get(MapKey) + let MapObject = AuraMap.get(MapKey); let checkEffects = MapObject.effects; //Check for other types of X aura if the aura token is moved if (tokenId && canvasToken.id !== tokenId) { - checkEffects = checkEffects.filter(i => i.entityId === tokenId) - let duplicateEffect = [] + checkEffects = checkEffects.filter(i => i.entityId === tokenId); + let duplicateEffect = []; checkEffects.forEach(e => duplicateEffect = (MapObject.effects.filter(i => (i.data?.label === e.data?.label) && i.entityId !== tokenId))); - checkEffects = checkEffects.concat(duplicateEffect) + checkEffects = checkEffects.concat(duplicateEffect); } for (const auraEffect of checkEffects) { - const auraTargets = auraEffect.data.flags?.ActiveAuras?.aura + const auraTargets = auraEffect.data.flags?.ActiveAuras?.aura; const { radius, height, hostile, wildcard, extra } = auraEffect.data.flags?.ActiveAuras; let { type, alignment } = auraEffect.data.flags?.ActiveAuras; - const { parentActorLink, parentActorId } = auraEffect + const { parentActorLink, parentActorId } = auraEffect; type = type !== undefined ? type.toLowerCase() : ""; - alignment = alignment !== undefined ? alignment.toLowerCase() : ""; - if (alignment && !tokenAlignment.includes(alignment) && !tokenAlignment.includes("any")) continue; // cleaned up alignment check and moved here. + if (alignment !== undefined && (alignment?.gne !== undefined || alignment?.lnc !== undefined)) { + let gne = alignment?.gne !== undefined ? alignment?.gne.toLowerCase() : ''; + let lnc = alignment?.lnc !== undefined ? alignment?.lnc.toLowerCase() : ''; + if (gne === '' && lnc === '') { + alignment = "[a-z ]+"; + } + else if (gne === 'neutral' && lnc === 'neutral') { + alignment = '((true|neutral) )?neutral'; + } + else if (gne === 'neutral' && lnc === '') { + alignment = '((lawful|neutral|chaotic|true) )?neutral'; + } + else if (lnc === 'neutral' && gne === '') { + alignment = '((true )?neutral|neutral (good|neutral|evil))'; + } + else { + alignment = `${lnc !== '' ? lnc : '(lawful|neutral|chaotic)'} ${gne !== '' ? gne : '(good|neutral|evil)'}`; + } + } else { + alignment = "[a-z ]+"; + } + if (alignment && !tokenAlignment.match(new RegExp(`^${alignment}$`)) && !tokenAlignment.includes("any")) continue; let auraEntity, distance; - /* - let auraType = auraEffect.data.flags?.ActiveAuras?.type !== undefined ? auraEffect.data.flags?.ActiveAuras?.type.toLowerCase() : ""; - let auraAlignment = auraEffect.data.flags?.ActiveAuras?.alignment !== undefined ? auraEffect.data.flags?.ActiveAuras?.alignment.toLowerCase() : ""; - let hostileTurn = auraEffect.data.flags?.ActiveAuras?.hostile - */ const auraEntityType = auraEffect.entityType switch (auraEntityType) {