Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

Commit

Permalink
version 0.5.19
Browse files Browse the repository at this point in the history
  • Loading branch information
p4535992 committed Mar 27, 2022
1 parent 6fb0c8f commit d50d024
Show file tree
Hide file tree
Showing 11 changed files with 247 additions and 131 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 0.5.19

- Big update transfer all the flags from `token.data.flags` to `token.actor.data.flags`.

### 0.5.13-14-15-16-17-18

- Solved loop on mutliple delete active effect
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 <a href=\"https://www.flaticon.com/authors/freepik\" title=\"Freepik\">Freepik</a>, from <a href=\"https://www.flaticon.com/\" title=\"Flaticon\"> www.flaticon.com</a>. Moon icon made by <a href=\"https://www.flaticon.com/authors/iconixar\" title=\"iconixar\">iconixar</a> from <a href=\"https://www.flaticon.com/\" title=\"Flaticon\"> www.flaticon.com</a>",
"version": "0.5.18",
"version": "0.5.19",
"scripts": {
"package": "gulp package",
"build": "gulp build && gulp link",
Expand Down
3 changes: 1 addition & 2 deletions src/conditional-visibility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ Hooks.once('libChangelogsReady', function () {
libChangelogs.register(
CONSTANTS.MODULE_NAME,
`
- Little bug fix
- Integration with mid-qol optional rule, when a token make a attack it will visible for the duration of the attack.
- Big update transfer all the flags from 'token.data.flags' to 'token.actor.data.flags'.
`,
'minor',
);
Expand Down
2 changes: 2 additions & 0 deletions src/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
"conditional-visibility.setting.idStealthSkill.hint": "[This is system dependent] Make sense only with 'Auto hide on stealth rolls' setting set to true. Here you can configure what attribute id is used from the system for tell is a stealth roll.For example, in D&D5e system, the attribute used is the id of the skill \"ste\" so you'd put that in this setting.",
"conditional-visibility.setting.idLangStealthSkill.name": "The lang key of the attribute used from the system for the stealth skill",
"conditional-visibility.setting.idLangStealthSkill.hint": "[This is system dependent] Make sense only with 'Auto hide on stealth rolls' setting set to true. Here you can configure what attribute id is used from the system for tell is a stealth roll.For example, in D&D5e system, the attribute used is the lang key of the skill \"DND5E.SkillSte\" so you'd put that in this setting.",
"conditional-visibility.setting.pathAttributesSenses.name": "The data path to the senses of the actor",
"conditional-visibility.setting.pathAttributesSenses.hint": "[This is system dependent] This is the data path from the actor data object for the senses associated to the system",

"conditional-visibility.setting.npcType.name": "NPC actor type",
"conditional-visibility.setting.npcType.hint": "Here you can configure what the type of NPC actor of your system for the sight check. For example, in D&D5e system, the type is on the property \"actor.type\" an is value is 'npc', so you'd put \"npc\" in this setting.",
Expand Down
8 changes: 4 additions & 4 deletions src/module.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 <a href=\"https://www.flaticon.com/authors/freepik\" title=\"Freepik\">Freepik</a>, from <a href=\"https://www.flaticon.com/\" title=\"Flaticon\"> www.flaticon.com</a>. Moon icon made by <a href=\"https://www.flaticon.com/authors/iconixar\" title=\"iconixar\">iconixar</a> from <a href=\"https://www.flaticon.com/\" title=\"Flaticon\"> www.flaticon.com</a>",
"version": "0.5.18",
"version": "0.5.19",
"author": "Greg Ludington, p4535992, Szefo09, Teshynil",
"type": "module",
"socket": true,
Expand Down Expand Up @@ -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.18/module.zip",
"readme": "https://github.com/p4535992/conditional-visibility/blob/v0.5.18/README.md",
"changelog": "https://github.com/p4535992/conditional-visibility/blob/v0.5.18/changelog.md",
"download": "https://github.com/p4535992/conditional-visibility/releases/download/v0.5.19/module.zip",
"readme": "https://github.com/p4535992/conditional-visibility/blob/v0.5.19/README.md",
"changelog": "https://github.com/p4535992/conditional-visibility/blob/v0.5.19/changelog.md",
"bugs": "https://github.com/p4535992/conditional-visibility/issues",
"allowBugReporter": true,
"dependencies": [
Expand Down
26 changes: 18 additions & 8 deletions src/module/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import {
isStringEquals,
mergeByProperty,
prepareActiveEffectForConditionalVisibility,
repairAndSetFlag,
repairAndUnSetFlag,
shouldIncludeVision,
warn,
} from './lib/lib';
Expand Down Expand Up @@ -746,7 +748,8 @@ const API = {
game.modules.get('midi-qol')?.active &&
<boolean>(<any>(<any>game.settings.get('midi-qol', 'ConfigSettings'))?.optionalRules)?.removeHiddenInvis
) {
await token.document.unsetFlag(CONSTANTS.MODULE_NAME, ConditionalVisibilityFlags.FORCE_VISILE);
// await token.document.unsetFlag(CONSTANTS.MODULE_NAME, ConditionalVisibilityFlags.FORCE_VISILE);
repairAndUnSetFlag(token,ConditionalVisibilityFlags.FORCE_VISILE);
}
}
}
Expand All @@ -765,9 +768,11 @@ const API = {
game.modules.get('midi-qol')?.active &&
<boolean>(<any>(<any>game.settings.get('midi-qol', 'ConfigSettings'))?.optionalRules)?.removeHiddenInvis
) {
await token.document.setFlag(CONSTANTS.MODULE_NAME, ConditionalVisibilityFlags.FORCE_VISILE, true);
// await token.document.setFlag(CONSTANTS.MODULE_NAME, ConditionalVisibilityFlags.FORCE_VISILE, true);
repairAndSetFlag(token,ConditionalVisibilityFlags.FORCE_VISILE, true);
}
await token.document.unsetFlag(CONSTANTS.MODULE_NAME, ConditionalVisibilityFlags.FORCE_VISILE);
// await token.document.unsetFlag(CONSTANTS.MODULE_NAME, ConditionalVisibilityFlags.FORCE_VISILE);
repairAndUnSetFlag(token,ConditionalVisibilityFlags.FORCE_VISILE);
}
},

Expand All @@ -778,17 +783,20 @@ const API = {
for (const token of tokens) {
const arr = getSensesFromToken(token.document, true);
for (const atcvEffect of arr) {
await token.document.unsetFlag(CONSTANTS.MODULE_NAME, atcvEffect.visionId);
// await token.document.unsetFlag(CONSTANTS.MODULE_NAME, atcvEffect.visionId);
repairAndUnSetFlag(token,atcvEffect.visionId);
}
const arr2 = getConditionsFromToken(token.document, true);
for (const atcvEffect of arr2) {
await token.document.unsetFlag(CONSTANTS.MODULE_NAME, atcvEffect.visionId);
// await token.document.unsetFlag(CONSTANTS.MODULE_NAME, atcvEffect.visionId);
repairAndUnSetFlag(token,atcvEffect.visionId);
}
if (
game.modules.get('midi-qol')?.active &&
<boolean>(<any>(<any>game.settings.get('midi-qol', 'ConfigSettings'))?.optionalRules)?.removeHiddenInvis
) {
await token.document.unsetFlag(CONSTANTS.MODULE_NAME, ConditionalVisibilityFlags.FORCE_VISILE);
// await token.document.unsetFlag(CONSTANTS.MODULE_NAME, ConditionalVisibilityFlags.FORCE_VISILE);
repairAndUnSetFlag(token,ConditionalVisibilityFlags.FORCE_VISILE);
}
}
},
Expand All @@ -805,13 +813,15 @@ const API = {
game.modules.get('midi-qol')?.active &&
<boolean>(<any>(<any>game.settings.get('midi-qol', 'ConfigSettings'))?.optionalRules)?.removeHiddenInvis
) {
await token.document.unsetFlag(CONSTANTS.MODULE_NAME, ConditionalVisibilityFlags.FORCE_VISILE);
//await token.document.unsetFlag(CONSTANTS.MODULE_NAME, ConditionalVisibilityFlags.FORCE_VISILE);
repairAndUnSetFlag(token,ConditionalVisibilityFlags.FORCE_VISILE);
}
const sourceVisionLevels = getConditionsFromToken(token.document, true) ?? [];
for (const sourceVision of sourceVisionLevels) {
if (isStringEquals(sourceVision.visionId, conditionId)) {
const atcvEffect = sourceVision; //AtcvEffect.fromSenseData(senseDataEffect, 1);
await token?.document.setFlag(CONSTANTS.MODULE_NAME, conditionId, atcvEffect);
// await token?.document.setFlag(CONSTANTS.MODULE_NAME, conditionId, atcvEffect);
repairAndSetFlag(token,ConditionalVisibilityFlags.FORCE_VISILE, atcvEffect);
}
}
}
Expand Down
58 changes: 6 additions & 52 deletions src/module/conditional-visibility-models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,35 +437,12 @@ export class VisionCapabilities {
return sensesTmp;
}

// async refreshSenses() {
// for (const [key, value] of this.senses.entries()) {
// // const statusSight = value.statusSight;
// // const visionLevelValue = value.visionLevelValue;
// //await this.token.document.setFlag(CONSTANTS.MODULE_NAME, key, visionLevelValue);
// const atcvEffectFlagData = AtcvEffectFlagData.fromAtcvEffect(value);
// await this.token.document.setFlag(CONSTANTS.MODULE_NAME, key, atcvEffectFlagData);
// if (value.statusSight?.path) {
// setProperty(this.token, <string>value.statusSight?.path, value.visionLevelValue);
// }
// }
// }

// retrieveSenseValue(statusSense: string): number | undefined {
// let sense: number | undefined = undefined;
// for (const statusEffect of this.senses.values()) {
// const statusSight = <SenseData>statusEffect.statusSight;
// if (statusSense == statusSight.id) {
// sense = this.senses.get(statusSense)?.visionLevelValue;
// break;
// }
// }
// return sense;
// }

addSenses() {
Promise.all(
API.SENSES.map(async (statusSight) => {
const atcvEffectFlagData = <AtcvEffect>this.token?.document?.getFlag(CONSTANTS.MODULE_NAME, statusSight.id);
// const atcvEffectFlagData = <AtcvEffect>this.token?.document?.getFlag(CONSTANTS.MODULE_NAME, statusSight.id);
const atcvEffectFlagData = <AtcvEffect>this.token?.actor?.getFlag(CONSTANTS.MODULE_NAME, statusSight.id)
?? <AtcvEffect>this.token?.document?.getFlag(CONSTANTS.MODULE_NAME, statusSight.id);
if (atcvEffectFlagData) {
let visionLevelValue = atcvEffectFlagData.visionLevelValue || 0;
let visionDistanceValue = atcvEffectFlagData.visionDistanceValue || 0;
Expand Down Expand Up @@ -509,23 +486,12 @@ export class VisionCapabilities {
return coditionsTmp;
}

// async refreshConditions() {
// for (const [key, value] of this.conditions.entries()) {
// //const statusSight = value.statusSight;
// // const visionLevelValue = value.visionLevelValue;
// // await this.token.document.setFlag(CONSTANTS.MODULE_NAME, key, visionLevelValue);
// const atcvEffectFlagData = AtcvEffectFlagData.fromAtcvEffect(value);
// await this.token.document.setFlag(CONSTANTS.MODULE_NAME, key, atcvEffectFlagData);
// if (value.statusSight?.path) {
// setProperty(this.token, <string>value.statusSight?.path, value.visionLevelValue);
// }
// }
// }

addConditions() {
Promise.all(
API.CONDITIONS.map(async (statusSight) => {
const atcvEffectFlagData = <AtcvEffect>this.token.document?.getFlag(CONSTANTS.MODULE_NAME, statusSight.id);
// const atcvEffectFlagData = <AtcvEffect>this.token.document?.getFlag(CONSTANTS.MODULE_NAME, statusSight.id);
const atcvEffectFlagData = <AtcvEffect>this.token?.actor?.getFlag(CONSTANTS.MODULE_NAME, statusSight.id)
?? <AtcvEffect>this.token.document?.getFlag(CONSTANTS.MODULE_NAME, statusSight.id);
if (atcvEffectFlagData) {
let visionLevelValue = atcvEffectFlagData.visionLevelValue || 0;
let visionDistanceValue = atcvEffectFlagData.visionDistanceValue || 0;
Expand Down Expand Up @@ -558,18 +524,6 @@ export class VisionCapabilities {
}),
);
}

// retrieveConditionValue(statusSense: string): number | undefined {
// let sense: number | undefined = undefined;
// for (const statusEffect of this.conditions.values()) {
// const statusSight = <SenseData>statusEffect.statusSight;
// if (statusSense == statusSight.id) {
// sense = this.senses.get(statusSense)?.visionLevelValue;
// break;
// }
// }
// return sense;
// }
}

export class CheckerDebugData {
Expand Down
Loading

0 comments on commit d50d024

Please sign in to comment.