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

Commit

Permalink
version 0.4.21
Browse files Browse the repository at this point in the history
  • Loading branch information
p4535992 committed Mar 13, 2022
1 parent 571068f commit 9a457a0
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 46 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### 0.4.21

- Rename all effects with suffix `(CV)`, for better clarification with other modules

### 0.4.20

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.4.20",
"version": "0.4.21",
"scripts": {
"package": "gulp package",
"build": "gulp build && gulp link",
Expand Down
56 changes: 28 additions & 28 deletions src/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,62 +56,62 @@
"conditional-visibility.lowlightvision": "Low-Light Vision",
"conditional-visibility.greaterdarkvision": "Greater Darkvision",

"conditional-visibility.effects.default.name": "No vision Level",
"conditional-visibility.effects.default.name2": "No vision Level ({number})",
"conditional-visibility.effects.default.name": "No vision Level (CV)",
"conditional-visibility.effects.default.name2": "No vision Level ({number}) (CV)",
"conditional-visibility.effects.default.description": "This sense is used from the module 'Conditional Visibility'",
"conditional-visibility.effects.default.description2": "This sense is used from the module 'Conditional Visibility'",
"conditional-visibility.effects.none.name": "None",
"conditional-visibility.effects.none.name2": "None ({number})",
"conditional-visibility.effects.none.name": "None (CV)",
"conditional-visibility.effects.none.name2": "None ({number}) (CV)",
"conditional-visibility.effects.none.description": "This sense is used from the module 'Conditional Visibility'",
"conditional-visibility.effects.none.description2": "This sense is used from the module 'Conditional Visibility'",
"conditional-visibility.effects.normal.name": "Normal",
"conditional-visibility.effects.normal.name2": "Normal ({number})",
"conditional-visibility.effects.normal.name": "Normal (CV)",
"conditional-visibility.effects.normal.name2": "Normal ({number}) (CV)",
"conditional-visibility.effects.normal.description": "This sense is used from the module 'Conditional Visibility'",
"conditional-visibility.effects.normal.description2": "This sense is used from the module 'Conditional Visibility'",
"conditional-visibility.effects.blinded.name": "Blinded",
"conditional-visibility.effects.blinded.name2": "Blinded ({number})",
"conditional-visibility.effects.blinded.name": "Blinded (CV)",
"conditional-visibility.effects.blinded.name2": "Blinded ({number}) (CV)",
"conditional-visibility.effects.blinded.description": "A blinded creature can't see and automatically fails any ability check that requires sight.<br>Attack rolls against the creature have advantage, and the creature's attack rolls have disadvantage.",
"conditional-visibility.effects.blinded.description2": "A blinded creature can't see and automatically fails any ability check that requires sight.<br>Attack rolls against the creature have advantage, and the creature's attack rolls have disadvantage.",
"conditional-visibility.effects.darkvision.name": "Darkvision",
"conditional-visibility.effects.darkvision.name2": "Darkvision ({number})",
"conditional-visibility.effects.darkvision.name": "Darkvision (CV)",
"conditional-visibility.effects.darkvision.name2": "Darkvision ({number}) (CV)",
"conditional-visibility.effects.darkvision.description": "A monster with Darkvision can see in the dark within a specific radius. The monster can see in dim light within the radius as if it were bright light, and in Darkness as if it were dim light. The monster can't discern color in Darkness, only Shades of Gray. Many Creatures that live Underground have this Special sense.",
"conditional-visibility.effects.darkvision.description2": "A monster with Darkvision can see in the dark within a radius of {number}. The monster can see in dim light within the radius as if it were bright light, and in Darkness as if it were dim light. The monster can't discern color in Darkness, only Shades of Gray. Many Creatures that live Underground have this Special sense.",
"conditional-visibility.effects.tremorsense.name": "Tremor Sense",
"conditional-visibility.effects.tremorsense.name2": "Tremor Sense ({number})",
"conditional-visibility.effects.tremorsense.name": "Tremor Sense (CV)",
"conditional-visibility.effects.tremorsense.name2": "Tremor Sense ({number}) (CV)",
"conditional-visibility.effects.tremorsense.description": "A monster with tremorsense can detect and pinpoint the origin of vibrations within a specific radius, provided that the monster and the source of the vibrations are in contact with the same ground or substance. Tremorsense can't be used to detect flying or incorporeal creatures. Many burrowing creatures, such as ankhegs and umber hulks, have this special sense.",
"conditional-visibility.effects.tremorsense.description2": "A monster with tremorsense can detect and pinpoint the origin of vibrations within a radius of {number}, provided that the monster and the source of the vibrations are in contact with the same ground or substance. Tremorsense can't be used to detect flying or incorporeal creatures. Many burrowing creatures, such as ankhegs and umber hulks, have this special sense.",
"conditional-visibility.effects.seeinvisible.name": "See invisible",
"conditional-visibility.effects.seeinvisible.name2": "See invisible ({number})",
"conditional-visibility.effects.seeinvisible.name": "See invisible (CV)",
"conditional-visibility.effects.seeinvisible.name2": "See invisible ({number}) (CV)",
"conditional-visibility.effects.seeinvisible.description": "For the duration, you see invisible creatures and objects as if they were visible, and you can see into the Ethereal Plane. Ethereal creatures and objects appear ghostly and translucent.",
"conditional-visibility.effects.seeinvisible.description2": "For the duration, you see invisible creatures and objects as if they were visible within a radius of {number}, and you can see into the Ethereal Plane. Ethereal creatures and objects appear ghostly and translucent.",
"conditional-visibility.effects.blindsight.name": "Blind Sight",
"conditional-visibility.effects.blindsight.name2": "Blind Sight ({number})",
"conditional-visibility.effects.blindsight.name": "Blind Sight (CV)",
"conditional-visibility.effects.blindsight.name2": "Blind Sight ({number}) (CV)",
"conditional-visibility.effects.blindsight.description": "A monster with blindsight can perceive its surroundings without relying on sight, within a specific radius.<br>Creatures without eyes, such as grimlocks and gray oozes, typically have this special sense, as do creatures with echolocation or heightened senses, such as bats and true dragons.<br>If a monster is naturally blind, it has a parenthetical note to this effect, indicating that the radius of its blindsight defines the maximum range of its perception.",
"conditional-visibility.effects.blindsight.description2": "A monster with blindsight can perceive its surroundings without relying on sight, within a radius of {number}.<br>Creatures without eyes, such as grimlocks and gray oozes, typically have this special sense, as do creatures with echolocation or heightened senses, such as bats and true dragons.<br>If a monster is naturally blind, it has a parenthetical note to this effect, indicating that the radius of its blindsight defines the maximum range of its perception.",
"conditional-visibility.effects.truesight.name": "True Sight",
"conditional-visibility.effects.truesight.name2": "True Sight ({number})",
"conditional-visibility.effects.truesight.name": "True Sight (CV)",
"conditional-visibility.effects.truesight.name2": "True Sight ({number}) (CV)",
"conditional-visibility.effects.truesight.description": "A monster with truesight can, out to a specific range, see in normal and magical darkness, see invisible creatures and objects, automatically detect visual illusions and succeed on saving throws against them, and perceive the original form of a shapechanger or a creature that is transformed by magic. Furthermore, the monster can see into the Ethereal Plane within the same range.",
"conditional-visibility.effects.truesight.description2": "Within a radius of {number} a monster with truesight can, out to a specific range, see in normal and magical darkness, see invisible creatures and objects, automatically detect visual illusions and succeed on saving throws against them, and perceive the original form of a shapechanger or a creature that is transformed by magic. Furthermore, the monster can see into the Ethereal Plane within the same range.",
"conditional-visibility.effects.devilssight.name": "Devil's sight",
"conditional-visibility.effects.devilssight.name2": "Devil's sight ({number})",
"conditional-visibility.effects.devilssight.name": "Devil's sight (CV)",
"conditional-visibility.effects.devilssight.name2": "Devil's sight ({number}) (CV)",
"conditional-visibility.effects.devilssight.description": "You can see normally in darkness, both magical and nonmagical, to a certain distance.",
"conditional-visibility.effects.devilssight.description2": "You can see normally in darkness, both magical and nonmagical, to a distance of {number}.",
"conditional-visibility.effects.lowlightvision.name": "Low-Light Vision",
"conditional-visibility.effects.lowlightvision.name2": "Low-Light Vision ({number})",
"conditional-visibility.effects.lowlightvision.name": "Low-Light Vision (CV)",
"conditional-visibility.effects.lowlightvision.name2": "Low-Light Vision ({number}) (CV)",
"conditional-visibility.effects.lowlightvision.description": "A creature with low-light vision can see in dim light as though it were bright light, so it ignores the concealed condition due to dim light.",
"conditional-visibility.effects.lowlightvision.description2": "Within a radius of {number} a creature with low-light vision can see in dim light as though it were bright light, so it ignores the concealed condition due to dim light.",
"conditional-visibility.effects.greaterdarkvision.name": "Greater Darkvision",
"conditional-visibility.effects.greaterdarkvision.name2": "Greater Darkvision ({number})",
"conditional-visibility.effects.greaterdarkvision.name": "Greater Darkvision (CV)",
"conditional-visibility.effects.greaterdarkvision.name2": "Greater Darkvision ({number}) (CV)",
"conditional-visibility.effects.greaterdarkvision.description": "A creature with darkvision or greater darkvision can see perfectly well in areas of darkness and dim light, though such vision is in black and white only. Some forms of magical darkness, such as a 4th-level darkness spell, block normal darkvision. A creature with greater darkvision, however, can see through even these forms of magical darkness.",
"conditional-visibility.effects.greaterdarkvision.description2": "Within a radius of {number} a creature with darkvision or greater darkvision can see perfectly well in areas of darkness and dim light, though such vision is in black and white only. Some forms of magical darkness, such as a 4th-level darkness spell, block normal darkvision. A creature with greater darkvision, however, can see through even these forms of magical darkness.",

"conditional-visibility.effects.invisible.name": "Invisible",
"conditional-visibility.effects.invisible.name": "Invisible (CV)",
"conditional-visibility.effects.invisible.description": "This sense is used from the module 'Conditional Visibility'",
"conditional-visibility.effects.obscured.name": "Obscured",
"conditional-visibility.effects.obscured.name": "Obscured (CV)",
"conditional-visibility.effects.obscured.description": "This sense is used from the module 'Conditional Visibility'",
"conditional-visibility.effects.indarkness.name": "In Darkness",
"conditional-visibility.effects.indarkness.name": "In Darkness (CV)",
"conditional-visibility.effects.indarkness.description": "This sense is used from the module 'Conditional Visibility'",
"conditional-visibility.effects.hidden.name": "Hidden",
"conditional-visibility.effects.hidden.name": "Hidden (CV)",
"conditional-visibility.effects.hidden.description": "This sense is used from the module 'Conditional Visibility'",

"conditional-visibility.dialogs.title.hidden": "Roll stealth",
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.4.20",
"version": "0.4.21",
"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.4.20/module.zip",
"readme": "https://github.com/p4535992/conditional-visibility/blob/v0.4.20/README.md",
"changelog": "https://github.com/p4535992/conditional-visibility/blob/v0.4.20/changelog.md",
"download": "https://github.com/p4535992/conditional-visibility/releases/download/v0.4.21/module.zip",
"readme": "https://github.com/p4535992/conditional-visibility/blob/v0.4.21/README.md",
"changelog": "https://github.com/p4535992/conditional-visibility/blob/v0.4.21/changelog.md",
"bugs": "https://github.com/p4535992/conditional-visibility/issues",
"allowBugReporter": true,
"dependencies": [
Expand Down
14 changes: 8 additions & 6 deletions src/module/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,9 @@ const API = {
visionLevel: number | undefined,
) {
const tokens = <Token[]>canvas.tokens?.placeables;
const token = <Token>tokens.find((token) => token.name == i18n(tokenNameOrId) || token.id == tokenNameOrId);
const token = <Token>tokens.find((token) => {
return isStringEquals(token.name, i18n(tokenNameOrId)) || isStringEquals(token.id, tokenNameOrId);
});

if (!token) {
warn(`No token found with reference '${tokenNameOrId}'`, true);
Expand Down Expand Up @@ -673,7 +675,7 @@ const API = {
}
if (senseDataId == sense.id) {
effect = <Effect>effectsDefinition.find((effect: Effect) => {
return effect.customId == sense.id || i18n(effect.name) == i18n(sense.name);
return isStringEquals(effect.customId, sense.id) || isStringEquals(i18n(effect.name), i18n(sense.name));
});
senseData = sense;
break;
Expand All @@ -686,13 +688,13 @@ const API = {
isStringEquals(i18n(sense.name), i18n((<SenseData>senseData).name))
);
});
// const isSense = API.SENSES.find((sense: SenseData) => {
// return sense.id == (<SenseData>senseData).id || i18n(sense.name) == i18n((<SenseData>senseData).name);
// });

if (!effect) {
const senseOrCondition = <SenseData>sensesAndConditionOrderByName.find((sense: SenseData) => {
return sense.id == (<SenseData>senseData).id || i18n(sense.name) == i18n((<SenseData>senseData).name);
return (
isStringEquals(sense.id, (<SenseData>senseData).id) ||
isStringEquals(i18n(sense.name), i18n((<SenseData>senseData).name))
);
});
if (senseOrCondition) {
const atcvChanges = [
Expand Down
2 changes: 1 addition & 1 deletion src/module/conditional-visibility-effect-definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export class ConditionalVisibilityEffectDefinitions {
const senses = await API.getAllSensesAndConditions();
let effectFounded: Effect | undefined = undefined;
for (const senseData of senses) {
if (effect?.customId == senseData.id || i18n(effect.name) == i18n(senseData.name)) {
if (isStringEquals(effect?.customId, senseData.id) || isStringEquals(i18n(effect.name), i18n(senseData.name))) {
effectFounded = effect;
break;
}
Expand Down
25 changes: 23 additions & 2 deletions src/module/lib/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,12 @@ export function cleanUpString(stringToCleanUp: string) {

export function isStringEquals(stringToCheck1: string, stringToCheck2: string, startsWith = true): boolean {
if (stringToCheck1 && stringToCheck2) {
const s1 = cleanUpString(stringToCheck1) ?? '';
const s2 = cleanUpString(stringToCheck2) ?? '';
if (startsWith) {
return cleanUpString(stringToCheck1).startsWith(cleanUpString(stringToCheck2));
return s1.startsWith(s2) || s2.startsWith(s1);
} else {
return cleanUpString(stringToCheck1) === cleanUpString(stringToCheck2);
return s1 === s2;
}
} else {
return stringToCheck1 === stringToCheck2;
Expand Down Expand Up @@ -1160,4 +1162,23 @@ function getTokenLOSheight(token) {
}
}

/**
* Find out if a token is in the range of a particular object
* @param {Object} token - a token
* @param {Object} object - a tile/drawing/light/note
* @returns {Boolean} - true if in range, false if not
**/
export function isTokenInRange(token: Token, object: Tile | Drawing | AmbientLight | Note) {
if (game.modules.get('levels')?.active) {
let rangeTop = <number>object.document.getFlag('levels', 'rangeTop');
let rangeBottom = <number>object.document.getFlag('levels', 'rangeBottom');
if (!rangeTop && rangeTop !== 0) rangeTop = Infinity;
if (!rangeBottom && rangeBottom !== 0) rangeBottom = -Infinity;
const elevation = token.data.elevation;
return elevation <= rangeTop && elevation >= rangeBottom;
} else {
// TODO maybe active aura integration
}
}

// ========================================================================================
7 changes: 3 additions & 4 deletions src/module/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,8 @@ const module = {
for (const tok of tokenArray) {
const sense = (await API.getAllSensesAndConditions()).find((sense: SenseData) => {
return (
i18n(sense.name) == i18n(<string>activeEffect.name) || i18n(sense.name) == i18n(activeEffect.data.label)
isStringEquals(i18n(sense.name), i18n(<string>activeEffect.name)) ||
isStringEquals(i18n(sense.name), i18n(activeEffect.data.label))
);
});
if (sense?.id) {
Expand All @@ -359,7 +360,7 @@ const module = {
for (const effect of effects) {
// I also added this for specifically checking for custom effects.
// It will return undefined if it doesn't exist:
const effectToFoundByName = i18n(effect.name) + ' (CV)';
const effectToFoundByName = i18n(effect.name);
//@ts-ignore
const effectFounded = <Effect>game.dfreds.effectInterface.findCustomEffectByName(effectToFoundByName);
if (!effectFounded) {
Expand All @@ -381,8 +382,6 @@ const module = {
effect.transfer = !disabled;
}
const data = effect.convertToActiveEffectData({ origin, overlay });
data.name = data.name + ' (CV)';
data.label = data.label + ' (CV)';
activeEffectsData.push(data);
}
}
Expand Down

0 comments on commit 9a457a0

Please sign in to comment.