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.13
Browse files Browse the repository at this point in the history
  • Loading branch information
p4535992 committed Mar 26, 2022
1 parent e28b5a5 commit 00ca882
Show file tree
Hide file tree
Showing 10 changed files with 122 additions and 58 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
### 0.5.13

- Little bug fix
- Integration with mid-qol optional rule, when a token make a attack it will visible for the duration of the attack.

### 0.5.12

- Solved module incompatibility with [Less Fog](https://github.com/trdischat/lessfog/)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ This module uses the [ATE](https://github.com/kandashi/Active-Token-Lighting) li
- [FUTURE FEATURE] This module used many feature of the [Dfred convenient effects](https://github.com/DFreds/dfreds-convenient-effects/) module, but is not multisystem (yet) i invite you to support Dfred for is marvelous work and beg him to make that module multisystem.
- With levels module enabled and active, **if the scene is with "Token vision" set to false (unchecked box)**, after selected a token and click on the canvas with the option "Release on left click" enable the hidden token are visible for a small instant this is a incompatibility with the [Levels](https://github.com/theripper93/Levels) module i cannot solve, the simple solution is just enable the token vision on the current scene.
- [NOT SOLVED] There is a small incompatibility with the Dfred convenient effects module, for some strange reason the passive effect are applied has temporary effect here the issue related https://github.com/DFreds/dfreds-convenient-effects/issues/137, it's seem Dfred manage only temporary effect so we leave this issue _not resolved_
- [PATCHED] The module "less fog" breaks the dm view of tokens. The gm still see an invisible token as other tokens, but the players don't so is a minor issue. The solution is just make sure the module 'Less Fog' settings panel 'Reveal Tokens' is false (uncheked box), is itoptional but advisable to set 'Reveal to All Players' is false (uncheked box) either.
- [TODO] Better intgration with [ATE]() for now yu must do some manual settings... hoope for the future to do a better automatize.
- [PATCHED] The module "less fog" breaks the dm view of tokens. The gm still see an invisible token as other tokens, but the players don't so is a minor issue. The solution is just make sure the module 'Less Fog' settings 'Reveal Tokens' and 'Reveal to All Players' are set to false (uncheked box) both.
- [TODO] Better intgration with [ATE](https://github.com/kandashi/Active-Token-Lighting) for now yu must do some manual settings... hoope for the future to do a better automatize.

## Usage

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.12",
"version": "0.5.13",
"scripts": {
"package": "gulp package",
"build": "gulp build && gulp link",
Expand Down
7 changes: 3 additions & 4 deletions src/conditional-visibility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,16 @@ Hooks.once('libChangelogsReady', function () {
libChangelogs.registerConflict(
CONSTANTS.MODULE_NAME,
'less-fog',
`With less-fog module enabled and active, The module "less fog" breaks the dm view of tokens. The gm still see an invisible token as other tokens, but the players don't so is a minor issue. The solution is just make sure the module 'Less Fog' settings panel 'Reveal Tokens' is false (uncheked box), is itoptional but advisable to set 'Reveal to All Players' is false (uncheked box) either.`,
`With less-fog module enabled and active. The module "less fog" breaks the dm view of tokens. The gm still see an invisible token as other tokens, but the players don't so is a minor issue. The solution is just make sure the module 'Less Fog' settings 'Reveal Tokens' and 'Reveal to All Players' are set to false (uncheked box) both.`,
'minor',
);

//@ts-ignore
libChangelogs.register(
CONSTANTS.MODULE_NAME,
`
- Solved module incompatibility with [Less Fog](https://github.com/trdischat/lessfog/)
- Add check only for condition and sense effect not disable, now if the effect is disabled is not consider from the checker very useful whith [Dfreds Panel Effects](https://github.com/DFreds/dfreds-effects-panel)
- Moved all the initialization to the init hook and made it non-async, because the hooks/wrappers/settings need to be registered before the canvas is drawn. This fixes the issue that the tokens are initially visible after login.
- Little bug fix
- Integration with mid-qol optional rule, when a token make a attack it will visible for the duration of the attack.
`,
'minor',
);
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.12",
"version": "0.5.13",
"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.12/module.zip",
"readme": "https://github.com/p4535992/conditional-visibility/blob/v0.5.12/README.md",
"changelog": "https://github.com/p4535992/conditional-visibility/blob/v0.5.12/changelog.md",
"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",
"bugs": "https://github.com/p4535992/conditional-visibility/issues",
"allowBugReporter": true,
"dependencies": [
Expand Down
45 changes: 41 additions & 4 deletions src/module/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ import {
warn,
} from './lib/lib';
import EffectInterface from './effects/effect-interface';
import { AtcvEffect, AtcvEffectConditionFlags, SenseData } from './conditional-visibility-models';
import {
AtcvEffect,
AtcvEffectConditionFlags,
ConditionalVisibilityFlags,
SenseData,
} from './conditional-visibility-models';
import { EnhancedConditions } from './cub/enhanced-conditions';
import { canvas, game } from './settings';
import Effect, { EffectSupport } from './effects/effect';
Expand Down Expand Up @@ -697,9 +702,22 @@ const API = {
return isStringEquals(senseData.id, AtcvEffectConditionFlags.HIDDEN);
});
if (senseDataEffect) {
const atcvEffect = AtcvEffect.fromSenseData(senseDataEffect, value);
// const atcvEffect = AtcvEffect.fromSenseData(senseDataEffect, value);
for (const token of tokens) {
(this as typeof API).addEffectConditionalVisibilityOnToken(token.id, atcvEffect, false);
//(this as typeof API).addEffectConditionalVisibilityOnToken(token.id, atcvEffect, false);
const sourceVisionLevels = getConditionsFromToken(token.document, true) ?? [];
for (const sourceVision of sourceVisionLevels) {
if (isStringEquals(sourceVision.visionId, AtcvEffectConditionFlags.HIDDEN)) {
const atcvEffect = sourceVision; //AtcvEffect.fromSenseData(senseDataEffect, 1);
await token?.document.setFlag(CONSTANTS.MODULE_NAME, AtcvEffectConditionFlags.HIDDEN, atcvEffect);
}
}
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);
}
}
}
},
Expand All @@ -709,10 +727,17 @@ const API = {
const sourceVisionLevels = getConditionsFromToken(token.document, true) ?? [];
for (const sourceVision of sourceVisionLevels) {
if (isStringEquals(sourceVision.visionId, AtcvEffectConditionFlags.HIDDEN)) {
const atcvEffect = sourceVision; //AtcvEffect.fromSenseData(senseDataEffect, 1);
// const atcvEffect = sourceVision; //AtcvEffect.fromSenseData(senseDataEffect, 1);
await token.document.unsetFlag(CONSTANTS.MODULE_NAME, AtcvEffectConditionFlags.HIDDEN);
}
}
if (
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.unsetFlag(CONSTANTS.MODULE_NAME, ConditionalVisibilityFlags.FORCE_VISILE);
}
},

Expand All @@ -729,6 +754,12 @@ const API = {
for (const atcvEffect of arr2) {
await token.document.unsetFlag(CONSTANTS.MODULE_NAME, 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);
}
}
},

Expand All @@ -740,6 +771,12 @@ const API = {
// const senseDataEffect = allSensesAndConditionsData.find((senseData) => {
// return isStringEquals(senseData.id, conditionId);
// });
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);
}
const sourceVisionLevels = getConditionsFromToken(token.document, true) ?? [];
for (const sourceVision of sourceVisionLevels) {
if (isStringEquals(sourceVision.visionId, conditionId)) {
Expand Down
8 changes: 6 additions & 2 deletions src/module/conditional-visibility-models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ export class AtcvEffect {
i18n(effect.name),
effect.icon,
undefined,
effect.isDisabled
effect.isDisabled,
);
/*
let sensesOrConditions: SenseData[] = [];
Expand All @@ -311,7 +311,7 @@ export class AtcvEffect {
i18n(activeEffect.data.label),
<string>activeEffect.data.icon,
undefined,
activeEffect.data.disabled
activeEffect.data.disabled,
);
/*
let sensesOrConditions: SenseData[] = [];
Expand Down Expand Up @@ -344,6 +344,10 @@ export interface SenseData {
conditionType: string; // indicate the type of CV usually they are or 'sense' or 'condition' not both, **THIS IS ESSENTIAL FOR USE SENSE AND CONDITION NOT REGISTERED ON THE MODULE IF NOT FOUNDED BY DEFAULT IS CONSIDERED A SENSE**, so now you can just modify the AE and you are not forced to call the registered macro of the module CV, this is very useful for integration with other modules.
}

export enum ConditionalVisibilityFlags {
FORCE_VISILE = 'forcevisible',
}

export enum AtcvEffectSenseFlags {
// additional generic
NONE = 'none',
Expand Down
79 changes: 42 additions & 37 deletions src/module/lib/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
VisionCapabilities,
SenseData,
CheckerDebugData,
ConditionalVisibilityFlags,
} from '../conditional-visibility-models.js';
import EmbeddedCollection from '@league-of-foundry-developers/foundry-vtt-types/src/foundry/common/abstract/embedded-collection.mjs';
import {
Expand Down Expand Up @@ -357,9 +358,13 @@ export function shouldIncludeVision(sourceToken: Token, targetToken: Token): boo
return true;
}
// 1) Check if target token is hidden with standard hud feature of foundry and only GM can see
if(targetToken.data.hidden){
if (targetToken.data.hidden) {
return false;
}
// 1.1) Check if target token is with the 'Force Visible' flag for Midi Qol integration
if (targetToken.document.getFlag(CONSTANTS.MODULE_NAME, ConditionalVisibilityFlags.FORCE_VISILE)) {
return true;
}

// ===============================================
// 0 - Checkout the ownership of the target and the disposition of the target
Expand Down Expand Up @@ -433,13 +438,13 @@ export function shouldIncludeVision(sourceToken: Token, targetToken: Token): boo
// 1 - Preparation of the active effect
// =========================================

const sourceVisionLevels =
getSensesFromToken(sourceToken.document, true).filter((atcvEffect) =>{
const sourceVisionLevels =
getSensesFromToken(sourceToken.document, true).filter((atcvEffect) => {
return !atcvEffect.visionIsDisabled;
}) ?? [];

const targetVisionLevels =
getConditionsFromToken(targetToken.document, true).filter((atcvEffect) =>{
const targetVisionLevels =
getConditionsFromToken(targetToken.document, true).filter((atcvEffect) => {
return !atcvEffect.visionIsDisabled;
}) ?? [];

Expand Down Expand Up @@ -519,7 +524,7 @@ export function shouldIncludeVision(sourceToken: Token, targetToken: Token): boo
}`,
);
return true;
}else{
} else {
return false;
}
}
Expand All @@ -535,37 +540,37 @@ export function shouldIncludeVision(sourceToken: Token, targetToken: Token): boo
// THIS WILL BE CHECK ONLY IF ONE CONDITION IS PRESENT ON THE TARGET AND THE CONDITION TYPE IS 'HIDDEN'
if (game.settings.get(CONSTANTS.MODULE_NAME, 'autoPassivePerception')) {
//if (sourceVisionLevels.length === 0) {
let isTheCaseWhenOnlyTheHiddenConditionIsPresentOnTarget = true;
let currentHiddenValue = 0;
for (const targetVisionLevel of targetVisionLevels) {
if (!isStringEquals(targetVisionLevel.visionId, AtcvEffectConditionFlags.HIDDEN)) {
isTheCaseWhenOnlyTheHiddenConditionIsPresentOnTarget = false;
break;
} else {
currentHiddenValue = <number>targetVisionLevel.visionLevelValue;
}
}
if (!currentHiddenValue) {
currentHiddenValue = 0;
let isTheCaseWhenOnlyTheHiddenConditionIsPresentOnTarget = true;
let currentHiddenValue = 0;
for (const targetVisionLevel of targetVisionLevels) {
if (!isStringEquals(targetVisionLevel.visionId, AtcvEffectConditionFlags.HIDDEN)) {
isTheCaseWhenOnlyTheHiddenConditionIsPresentOnTarget = false;
break;
} else {
currentHiddenValue = <number>targetVisionLevel.visionLevelValue;
}
// if (currentHiddenValue < stealthedPassive && game.settings.get(CONSTANTS.MODULE_NAME, 'autoPassivePerception')) {
// debug(
// `(8.1) Is the case when only the hidden condition is present on target but stealth passive > the the hidden value state : Is true, target ${
// targetToken.data.name
// } ${'is visible'} to source ${sourceToken.data.name}`,
// );
// currentHiddenValue = stealthedPassive;
// }
if (isTheCaseWhenOnlyTheHiddenConditionIsPresentOnTarget) {
if (perceptionPassive >= currentHiddenValue) {
debug(
`(8.2) Check if the current perception passive value is >= of the 'Hidden Perception passive value': Is true, target ${
targetToken.data.name
} ${'is visible'} to source ${sourceToken.data.name}`,
);
return true;
}
}
if (!currentHiddenValue) {
currentHiddenValue = 0;
}
// if (currentHiddenValue < stealthedPassive && game.settings.get(CONSTANTS.MODULE_NAME, 'autoPassivePerception')) {
// debug(
// `(8.1) Is the case when only the hidden condition is present on target but stealth passive > the the hidden value state : Is true, target ${
// targetToken.data.name
// } ${'is visible'} to source ${sourceToken.data.name}`,
// );
// currentHiddenValue = stealthedPassive;
// }
if (isTheCaseWhenOnlyTheHiddenConditionIsPresentOnTarget) {
if (perceptionPassive >= currentHiddenValue) {
debug(
`(8.2) Check if the current perception passive value is >= of the 'Hidden Perception passive value': Is true, target ${
targetToken.data.name
} ${'is visible'} to source ${sourceToken.data.name}`,
);
return true;
}
}
//}
}
debug(
Expand Down Expand Up @@ -1172,7 +1177,7 @@ function _getCVFromToken(
effectNameToSet,
<string>effectEntity.data.icon,
undefined,
effectEntity.data.disabled
effectEntity.data.disabled,
);
if (!atcvEffectTmp.visionId) {
continue;
Expand Down Expand Up @@ -1244,7 +1249,7 @@ export function retrieveAtcvEffectFromActiveEffect(
effectName: string,
effectIcon: string,
isSense: boolean | undefined = undefined,
isDisabled:boolean,
isDisabled: boolean,
): AtcvEffect {
const atcvEffect: AtcvEffect = <any>{};

Expand Down
10 changes: 8 additions & 2 deletions src/module/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
AtcvEffect,
AtcvEffectConditionFlags,
AtcvEffectSenseFlags,
ConditionalVisibilityFlags,
SenseData,
VisionCapabilities,
} from './conditional-visibility-models';
Expand Down Expand Up @@ -87,7 +88,8 @@ export const setupHooks = (): void => {
// //@ts-ignore
// game[CONSTANTS.MODULE_NAME].API = window.ConditionalVisibility.API;

setApi(API);
//@ts-ignore
setApi(window.ConditionalVisibility.API);
};

export const readyHooks = (): void => {
Expand Down Expand Up @@ -223,7 +225,11 @@ const module = {
if (!game.user?.isGM && !isPlayerOwned) {
return;
}
if (change.flags && change.flags[CONSTANTS.MODULE_NAME]) {
if (
change.flags &&
change.flags[CONSTANTS.MODULE_NAME] &&
!getProperty(change, `flags.${CONSTANTS.MODULE_NAME}.${ConditionalVisibilityFlags.FORCE_VISILE}`)
) {
const sourceVisionCapabilities: VisionCapabilities = new VisionCapabilities(<Token>document.object);
const p = getProperty(change, `flags.${CONSTANTS.MODULE_NAME}`);
for (const key in p) {
Expand Down
Loading

0 comments on commit 00ca882

Please sign in to comment.