From cf47a9d9524f3447598ac641f6b1eb8e0f5dc6fe Mon Sep 17 00:00:00 2001 From: p4535992 Date: Sat, 26 Mar 2022 15:49:50 +0100 Subject: [PATCH] version 0.5.14 --- CHANGELOG.md | 2 +- package.json | 2 +- src/module.json | 8 ++++---- src/module/api.ts | 11 ++++++++++- src/module/module.ts | 25 ++++++++++++++++++++++--- src/module/settings.ts | 8 ++++++++ src/module/systems/dnd5e.ts | 1 + src/module/systems/generic.ts | 1 + src/module/systems/pf2e.ts | 1 + 9 files changed, 49 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 992602a..816c821 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -### 0.5.13 +### 0.5.13-14 - Little bug fix - Integration with mid-qol optional rule, when a token make a attack it will visible for the duration of the attack. diff --git a/package.json b/package.json index a7007a8..fe4b969 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "name": "conditional-visibility", "title": "Conditional Visibility", "description": "Hide tokens from some players, but not others, based on the senses the players have. Uses unknown, newspaper, and foggy icons made by Freepik, from www.flaticon.com. Moon icon made by iconixar from www.flaticon.com", - "version": "0.5.13", + "version": "0.5.14", "scripts": { "package": "gulp package", "build": "gulp build && gulp link", diff --git a/src/module.json b/src/module.json index 735756c..0e64199 100644 --- a/src/module.json +++ b/src/module.json @@ -2,7 +2,7 @@ "name": "conditional-visibility", "title": "Conditional Visibility", "description": "Hide tokens from some players, but not others, based on the senses the players have. Uses unknown, newspaper, and foggy icons made by Freepik, from www.flaticon.com. Moon icon made by iconixar from www.flaticon.com", - "version": "0.5.13", + "version": "0.5.14", "author": "Greg Ludington, p4535992, Szefo09, Teshynil", "type": "module", "socket": true, @@ -61,9 +61,9 @@ "manifestPlusVersion": "1.2.0", "url": "https://github.com/p4535992/conditional-visibility", "manifest": "https://github.com/p4535992/conditional-visibility/releases/latest/download/module.json", - "download": "https://github.com/p4535992/conditional-visibility/releases/download/v0.5.13/module.zip", - "readme": "https://github.com/p4535992/conditional-visibility/blob/v0.5.13/README.md", - "changelog": "https://github.com/p4535992/conditional-visibility/blob/v0.5.13/changelog.md", + "download": "https://github.com/p4535992/conditional-visibility/releases/download/v0.5.14/module.zip", + "readme": "https://github.com/p4535992/conditional-visibility/blob/v0.5.14/README.md", + "changelog": "https://github.com/p4535992/conditional-visibility/blob/v0.5.14/changelog.md", "bugs": "https://github.com/p4535992/conditional-visibility/issues", "allowBugReporter": true, "dependencies": [ diff --git a/src/module/api.ts b/src/module/api.ts index 227ea82..ac1a2d0 100644 --- a/src/module/api.ts +++ b/src/module/api.ts @@ -110,12 +110,21 @@ const API = { /** * The attributes used to track dynamic attributes in this system * - * @returns {array} + * @returns {string} */ get STEALTH_ID_LANG_SKILL(): string { return game.settings.get(CONSTANTS.MODULE_NAME, 'idLangStealthSkill') ?? 'Stealth'; }, + /** + * The attributes used to track dynamic attributes in this system + * + * @returns {array} + */ + get PATH_ATTRIBUTES_SENSES(): string { + return game.settings.get(CONSTANTS.MODULE_NAME, 'pathAttributesSenses') ?? `data.attributes.senses`; + }, + /** * Sets the inAttribute used to track the passive perceptions in this system * diff --git a/src/module/module.ts b/src/module/module.ts index 2877769..dd51bf7 100644 --- a/src/module/module.ts +++ b/src/module/module.ts @@ -111,8 +111,23 @@ export const readyHooks = (): void => { }); Hooks.on('updateActor', (actor: Actor, change, options, userId) => { - if (actor.token && getProperty(change, `data.attributes.senses`)) { - module.updateActor(actor.token, change, options, userId); + // TODO for now only dnd5e + let p = getProperty(change, API.PATH_ATTRIBUTES_SENSES); + // TODO to remove + if(!p){ + p = getProperty(change, `data.attributes.senses`); + } + if(p){ + if (actor.token) { + module.updateActor(actor.token, change, options, userId); + }else{ + const token = canvas.tokens?.placeables.find((t:Token) =>{ + return t.actor?.id === actor.id; + }); + if(token){ + module.updateActor(token.document, change, options, userId); + } + } } }); @@ -195,7 +210,11 @@ const module = { } // const sourceVisionCapabilities: VisionCapabilities = new VisionCapabilities(document.object); // TODO for now only dnd5e - const p = getProperty(change, `data.attributes.senses`); + let p = getProperty(change, API.PATH_ATTRIBUTES_SENSES); + // TODO to remove + if(!p){ + p = getProperty(change, `data.attributes.senses`); + } for (const key in p) { const senseOrConditionIdKey = key; const senseOrConditionValue = p[key]; diff --git a/src/module/settings.ts b/src/module/settings.ts index 27cc186..aa81b34 100644 --- a/src/module/settings.ts +++ b/src/module/settings.ts @@ -297,6 +297,14 @@ function defaultSettings(apply = false) { default: apply && SYSTEMS.DATA ? SYSTEMS.DATA.STEALTH_ID_LANG_SKILL : '', type: String, }, + pathAttributesSenses: { + name: `${CONSTANTS.MODULE_NAME}.setting.pathAttributesSenses.name`, + hint: `${CONSTANTS.MODULE_NAME}.setting.pathAttributesSenses.hint`, + scope: 'world', + config: true, + default: apply && SYSTEMS.DATA ? SYSTEMS.DATA.PATH_ATTRIBUTES_SENSES : '', + type: String, + }, }; } diff --git a/src/module/systems/dnd5e.ts b/src/module/systems/dnd5e.ts index b1f8d57..0ef0585 100644 --- a/src/module/systems/dnd5e.ts +++ b/src/module/systems/dnd5e.ts @@ -9,6 +9,7 @@ export default { STEALTH_ACTIVE_SKILL: `data.skills.ste.total`, // STEALTH_ID_SKILL: `ste`, STEALTH_ID_LANG_SKILL: `DND5E.SkillSte`, + PATH_ATTRIBUTES_SENSES: `data.attributes.senses`, NPC_TYPE: `npc`, /** * The set of possible sensory perception types which an Actor may have. diff --git a/src/module/systems/generic.ts b/src/module/systems/generic.ts index 600ef7a..36afeaf 100644 --- a/src/module/systems/generic.ts +++ b/src/module/systems/generic.ts @@ -9,6 +9,7 @@ export default { STEALTH_ACTIVE_SKILL: ``, // STEALTH_ID_SKILL: ``, STEALTH_ID_LANG_SKILL: ``, + PATH_ATTRIBUTES_SENSES: ``, NPC_TYPE: ``, SENSES: [], CONDITIONS: [ diff --git a/src/module/systems/pf2e.ts b/src/module/systems/pf2e.ts index 4f6ff05..a23f241 100644 --- a/src/module/systems/pf2e.ts +++ b/src/module/systems/pf2e.ts @@ -17,6 +17,7 @@ export default { STEALTH_ACTIVE_SKILL: `data.skills.ste.value`, // STEALTH_ID_SKILL: `data.skills.ste`, STEALTH_ID_LANG_SKILL: `PF2E.SkillSte`, // SkillStealth + PATH_ATTRIBUTES_SENSES: `data.attributes.senses`, NPC_TYPE: `npc`, SENSES: [ {