Skip to content

Commit

Permalink
Merge pull request #89 from kandashi/0.1.52
Browse files Browse the repository at this point in the history
once per turn and only hostile turns
  • Loading branch information
kandashi authored Mar 4, 2021
2 parents cfab902 + 05ba9a4 commit 53ad045
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 9 deletions.
3 changes: 3 additions & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
"ACTIVEAURAS.FORM_TypePrompt": "humanoid/beast etc",
"ACTIVEAURAS.FORM_RadiusPrompt": "Measured by your grid scale",
"ACTIVEAURAS.FORM_SavePrompt": "str/dex/con/wis/int/cha",
"ACTIVEAURAS.FORM_TimePrompt": "Special Expiry for the Applied Effect",
"ACTIVEAURAS.FORM_HostileTurn": "Only apply during the current combatants turn",
"ACTIVEAURAS.FORM_ActivateOnce": "Only trigger the aura once per turn",

"ACTIVEAURAS.ApplyLog":"ActiveAuras | Applied '{effectDataLabel}' to {tokenName}",
"ACTIVEAURAS.RemoveLog":"ActiveAuras | Removed '{effectDataLabel}' from {tokenName}",
Expand Down
3 changes: 3 additions & 0 deletions lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
"ACTIVEAURAS.FORM_TypePrompt": "humanoide/bestia, etc",
"ACTIVEAURAS.FORM_RadiusPrompt": "Medido con tu escala de cuadrícula",
"ACTIVEAURAS.FORM_SavePrompt": "fue/des/con/sab/int/car",
"ACTIVEAURAS.FORM_TimePrompt": "[EN] Special Expiry for the Applied Effect",
"ACTIVEAURAS.FORM_HostileTurn": "[EN] Only apply during the current combatants turn",
"ACTIVEAURAS.FORM_ActivateOnce": "[EN] Only trigger the aura once per turn",

"ACTIVEAURAS.ApplyLog":"ActiveAuras | '{effectDataLabel}' aplicado a {tokenName}",
"ACTIVEAURAS.RemoveLog":"ActiveAuras | '{effectDataLabel}' quitado de {tokenName}",
Expand Down
3 changes: 3 additions & 0 deletions lang/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
"ACTIVEAURAS.FORM_TypePrompt": "humanoid/beast など",
"ACTIVEAURAS.FORM_RadiusPrompt": "グリッドスケールで測定する",
"ACTIVEAURAS.FORM_SavePrompt": "str/dex/con/wis/int/cha",
"ACTIVEAURAS.FORM_TimePrompt": "[EN] Special Expiry for the Applied Effect",
"ACTIVEAURAS.FORM_HostileTurn": "[EN] Only apply during the current combatants turn",
"ACTIVEAURAS.FORM_ActivateOnce": "[EN] Only trigger the aura once per turn",

"ACTIVEAURAS.ApplyLog":"Active Auras | {effectDataLabel}が{tokenName}に適用されました。",
"ACTIVEAURAS.RemoveLog":"Active Auras | {effectDataLabel}が{tokenName}から取り除かれました。",
Expand Down
5 changes: 4 additions & 1 deletion lang/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
"ACTIVEAURAS.FORM_SaveDC": "내성 굴림 난이도",
"ACTIVEAURAS.FORM_TypePrompt": "인간형/야수 기타",
"ACTIVEAURAS.FORM_RadiusPrompt": "격자 척도로 측정",
"ACTIVEAURAS.FORM_SavePrompt": "str/dex/con/wis/int/cha",
"ACTIVEAURAS.FORM_SavePrompt": "str/dex/con/wis/int/cha",
"ACTIVEAURAS.FORM_TimePrompt": "[EN] Special Expiry for the Applied Effect",
"ACTIVEAURAS.FORM_HostileTurn": "[EN] Only apply during the current combatants turn",
"ACTIVEAURAS.FORM_ActivateOnce": "[EN] Only trigger the aura once per turn",

"ACTIVEAURAS.ApplyLog":"ActiveAuras | '{effectDataLabel}' 효과가 {tokenName} 캐릭터에게 적용되었습니다",
"ACTIVEAURAS.RemoveLog":"ActiveAuras | '{effectDataLabel}' 효과가 {tokenName} 캐릭터에게 제거되었습니다.",
Expand Down
2 changes: 1 addition & 1 deletion module.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"title": "Active-Auras",
"description": "Active-Auras",
"author": "Kandashi",
"version": "0.1.51",
"version": "0.1.52",
"minimumCoreVersion": "0.7.5",
"compatibleCoreVersion": "0.7.9",
"packs": [
Expand Down
69 changes: 62 additions & 7 deletions src/aura.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,26 @@ Hooks.on("ready", () => {
const FormTypePrompt = game.i18n.format("ACTIVEAURAS.FORM_TypePrompt")
const FormRadiusPrompt = game.i18n.format("ACTIVEAURAS.FORM_RadiusPrompt")
const FormSavePrompt = game.i18n.format("ACTIVEAURAS.FORM_SavePrompt")
const FormTimePrompt = game.i18n.format("ACTIVEAURAS.FORM_TimePrompt")
const HostileTurn = game.i18n.format("ACTIVEAURAS.FORM_HostileTurn")
const ActivateOnce = game.i18n.format("ACTIVEAURAS.FORM_ActivateOnce")
if (game.modules.get("dae").active && game.modules.get("times-up").active) {
var isAttacked = game.i18n.format("dae.isAttacked")
var isDamaged = game.i18n.format("dae.isDamaged")
var action = game.i18n.format("dae.1Action")
var attack = game.i18n.format("dae.1Attack")
var hit = game.i18n.format("dae.1Hit")
var turnStart = game.i18n.format("dae.turnStart")
var turnEnd = game.i18n.format("dae.turnEnd")
}


const tab = `<a class="item" data-tab="ActiveAuras"><i class="fas fa-broadcast-tower"></i> ${AuraTab}</a>`;
let type = flags[MODULE_NAME]?.type ? flags[MODULE_NAME]?.type : "";
let alignment = flags[MODULE_NAME]?.alignment ? flags[MODULE_NAME]?.alignment : "";
let save = flags[MODULE_NAME]?.save ? flags[MODULE_NAME]?.save : "";

const contents = `
let contents = `
<div class="tab" data-tab="ActiveAuras">
<div class="form-group">
<label>${FormIsAura}?</label>
Expand Down Expand Up @@ -136,9 +148,36 @@ Hooks.on("ready", () => {
<div class="form-group">
<label>${FormSaveDC}</label>
<input id="savedc" name="flags.${MODULE_NAME}.savedc" type="number" min="0" value="${flags[MODULE_NAME]?.savedc}"></input>
</div>
</div>
<div class="form-group">
<label>${HostileTurn}</label>
<input name="flags.${MODULE_NAME}.hostile" type="checkbox" ${flags[MODULE_NAME]?.hostile ? 'checked' : ''}></input>
</div>
<div class="form-group">
<label>${ActivateOnce}</label>
<input name="flags.${MODULE_NAME}.onlyOnce" type="checkbox" ${flags[MODULE_NAME]?.onlyOnce ? 'checked' : ''}></input>
</div>`
;

if (game.modules.get("times-up").active) {
contents += `
<div class="form-group">
<label>${FormTimePrompt}</label>
<select name="flags.${MODULE_NAME}.time" data-dtype="String" value=${flags[MODULE_NAME]?.time}>
<option value="None" ${flags[MODULE_NAME]?.time === 'None' ? 'selected' : ''}></option>
<option value="isAttacked"${flags[MODULE_NAME]?.time === 'isAttacked' ? 'selected' : ''}>${isAttacked}</option>
<option value="isDamaged"${flags[MODULE_NAME]?.time === 'isDamaged' ? 'selected' : ''}>${isDamaged}</option>
<option value="1Action"${flags[MODULE_NAME]?.time === '1Action' ? 'selected' : ''}>${action}</option>
<option value="1Attack"${flags[MODULE_NAME]?.time === '1Attack' ? 'selected' : ''}>${attack}</option>
<option value="1Hit"${flags[MODULE_NAME]?.time === '1Hit' ? 'selected' : ''}>${hit}</option>
<option value="turnStart"${flags[MODULE_NAME]?.time === 'turnStart' ? 'selected' : ''}>${turnStart}</option>
<option value="turnEnd"${flags[MODULE_NAME]?.time === 'turnEnd' ? 'selected' : ''}>${turnEnd}</option>
</select>
</div>
</div>`;
`
}
else contents += `</div>`

const appliedAuraContent = `
<div class="tab" data-tab="ActiveAuras">
Expand Down Expand Up @@ -180,10 +219,17 @@ Hooks.on("ready", () => {
}
});

/**
* @todo
* Filter for aura effects on deleted token and remove from canvas tokens
*/
Hooks.on("updateCombat", async (combat, changed, options, userId) => {
if (!("turn" in changed)) return;
if (!gm) return;
let combatant = canvas.tokens.get(combat.combatant.tokenId);
let previousTurn = combat.turns[changed.turn - 1 > -1 ? changed.turn - 1 : combat.turns.length - 1]
let previousCombatant = canvas.tokens.get(previousTurn.tokenId)
previousCombatant.update({"flags.ActiveAuras" : false })
if (debug) console.log("updateCombat, main aura")
await MainAura(combatant.data, "combat update")
});

Hooks.on("preDeleteToken", async (_scene, token) => {
if (!gm) return;
if (IsAuraToken(token, canvas)) {
Expand Down Expand Up @@ -576,6 +622,7 @@ Hooks.on("ready", () => {
let auraHeight = auraEffect.data.flags?.ActiveAuras?.height;
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

//{data: testEffect.data, parentActorLink :testEffect.parent.data.token.actorLink, parentActorId : testEffect.parent._id, tokenId: testToken.id}
if (auraEffect.parentActorLink) {
Expand All @@ -598,6 +645,7 @@ Hooks.on("ready", () => {
if (auraTargets === "Enemy" && (auraToken.data.disposition === canvasToken.data.disposition)) continue;
if (auraAlignment !== "" && !tokenAlignment.includes(auraAlignment) && !tokenAlignment.includes("any")) continue;
if (auraType !== "" && !tokenType.includes(auraType) && !tokenType.includes("any")) continue;
if (hostileTurn && canvasToken.data._id !== game.combats.active.current.tokenId) return;
let distance = getDistance(canvasToken, auraToken, game.settings.get("ActiveAuras", "wall-block"), auraHeight)
if ((distance !== false) && (distance <= auraRadius)) {
if (MapObject) {
Expand Down Expand Up @@ -746,6 +794,13 @@ Hooks.on("ready", () => {
}
}
['ignoreSelf', 'hidden', 'height', 'alignment', 'type', 'aura', 'radius', 'save', 'isAura', 'savedc', 'height'].forEach(e => delete effectData.flags.ActiveAuras[e])
if (effectData.flags.ActiveAuras.time) {
effectData.flags.dae.specialDuration.push(effectData.flags.ActiveAuras.time)
}
if (effectData.flags.ActiveAuras.onlyOnce) {
if (await token.getFlag("ActiveAuras", `${oldEffectData.origin}`)) return;
else await token.setFlag("ActiveAuras", `${oldEffectData.origin}`, true)
}
await token.actor.createEmbeddedEntity("ActiveEffect", effectData);
console.log(game.i18n.format("ACTIVEAURAS.ApplyLog", { effectDataLabel: effectData.label, tokenName: token.name }))
}
Expand Down

0 comments on commit 53ad045

Please sign in to comment.