Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Lawful-Neutral-Chaotic alignment selectors #237

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions lang/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 など",
Expand Down
3 changes: 3 additions & 0 deletions lang/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "인간형/야수 기타",
Expand Down
3 changes: 3 additions & 0 deletions lang/zh-tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "類人生物/野獸等",
Expand Down
69 changes: 42 additions & 27 deletions src/AAhtml.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = `<a class="item" data-tab="ActiveAuras"><i class="fas fa-broadcast-tower"></i> ${AuraTab}</a>`;
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 = `
<div class="tab" data-tab="ActiveAuras">
Expand All @@ -43,9 +48,9 @@ Hooks.on("renderActiveEffectConfig", async (sheet, html) => {
<label>${FormTargetsName}:</label>
<select name="flags.${AA_MODULE_NAME}.aura" data-dtype="String" value=${flags[AA_MODULE_NAME]?.aura}>
<option value="None" ${flags[AA_MODULE_NAME]?.aura === 'None' ? 'selected' : ''}></option>
<option value="Enemy"${flags[AA_MODULE_NAME]?.aura === 'Enemy' ? 'selected' : ''}>${FormTargetsEnemy}</option>
<option value="Allies"${flags[AA_MODULE_NAME]?.aura === 'Allies' ? 'selected' : ''}>${FormTargetsAllies}</option>
<option value="All"${flags[AA_MODULE_NAME]?.aura === 'All' ? 'selected' : ''}>${FormTargetsAll}</option>
<option value="Enemy" ${flags[AA_MODULE_NAME]?.aura === 'Enemy' ? 'selected' : ''}>${FormTargetsEnemy}</option>
<option value="Allies" ${flags[AA_MODULE_NAME]?.aura === 'Allies' ? 'selected' : ''}>${FormTargetsAllies}</option>
<option value="All" ${flags[AA_MODULE_NAME]?.aura === 'All' ? 'selected' : ''}>${FormTargetsAll}</option>
</select>
</div>
<div id="specifics">
Expand All @@ -55,11 +60,17 @@ Hooks.on("renderActiveEffectConfig", async (sheet, html) => {
</div>
<div class="form-group">
<label>${FormCheckAlignment}:</label>
<select name="flags.${AA_MODULE_NAME}.alignment" data-dtype="String" value=${alignment}>
<option value="" ${flags[AA_MODULE_NAME]?.alignment === '' ? 'selected' : ''}></option>
<option value="good"${flags[AA_MODULE_NAME]?.alignment === 'good' ? 'selected' : ''}>${FormGood}</option>
<option value="neutral"${flags[AA_MODULE_NAME]?.alignment === 'neutral' ? 'selected' : ''}>${FormNeutral}</option>
<option value="evil"${flags[AA_MODULE_NAME]?.alignment === 'evil' ? 'selected' : ''}>${FormEvil}</option>
<select name="flags.${AA_MODULE_NAME}.alignment.gne" data-dtype="String" value=${gne_alignment}>
<option value="" ${gne_alignment === '' ? 'selected' : ''}>${FormAny}</option>
<option value="good" ${gne_alignment === 'good' ? 'selected' : ''}>${FormGood}</option>
<option value="neutral" ${gne_alignment === 'neutral' ? 'selected' : ''}>${FormNeutral}</option>
<option value="evil" ${gne_alignment === 'evil' ? 'selected' : ''}>${FormEvil}</option>
</select>
<select name="flags.${AA_MODULE_NAME}.alignment.lnc" data-dtype="String" value=${lnc_alignment}>
<option value="" ${lnc_alignment === '' ? 'selected' : ''}>${FormAny}</option>
<option value="lawful" ${lnc_alignment === 'lawful' ? 'selected' : ''}>${FormLawful}</option>
<option value="neutral" ${lnc_alignment === 'neutral' ? 'selected' : ''}>${FormNeutral}</option>
<option value="chaotic" ${lnc_alignment === 'chaotic' ? 'selected' : ''}>${FormChaotic}</option>
</select>
</div>
<div class="form-group">
Expand Down Expand Up @@ -114,12 +125,16 @@ Hooks.on("renderActiveEffectConfig", async (sheet, html) => {
</div>`;

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 () {
Expand All @@ -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();

Expand All @@ -148,7 +163,7 @@ Hooks.on("renderActiveEffectConfig", async (sheet, html) => {
}
}
html.css({ height: "auto" });
})
});
$isAura.trigger("change");
html.css({ height: "auto" });
});
45 changes: 30 additions & 15 deletions src/aura.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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 {
Expand All @@ -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) {
Expand Down