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.3
Browse files Browse the repository at this point in the history
  • Loading branch information
p4535992 committed Mar 21, 2022
1 parent ec7ff04 commit 38cf5c8
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 36 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### 0.5.1-2
### 0.5.1-2-3

- Remove all forEach fro performance
- Add some old api for retrocomaptibility

### 0.5.0 [BREKING CHANGES]
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.2",
"version": "0.5.3",
"scripts": {
"package": "gulp package",
"build": "gulp build && gulp link",
Expand Down
2 changes: 1 addition & 1 deletion src/conditional-visibility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Hooks.once('libChangelogsReady', function () {
libChangelogs.register(
CONSTANTS.MODULE_NAME,
`
- Bug fix
- Remove all forEach for performance
`,
'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.2",
"version": "0.5.3",
"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.2/module.zip",
"readme": "https://github.com/p4535992/conditional-visibility/blob/v0.5.2/README.md",
"changelog": "https://github.com/p4535992/conditional-visibility/blob/v0.5.2/changelog.md",
"download": "https://github.com/p4535992/conditional-visibility/releases/download/v0.5.3/module.zip",
"readme": "https://github.com/p4535992/conditional-visibility/blob/v0.5.3/README.md",
"changelog": "https://github.com/p4535992/conditional-visibility/blob/v0.5.3/changelog.md",
"bugs": "https://github.com/p4535992/conditional-visibility/issues",
"allowBugReporter": true,
"dependencies": [
Expand Down
8 changes: 4 additions & 4 deletions src/module/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ const API = {
if (!Array.isArray(inAttributes)) {
throw error('setSenses | inAttributes must be of type array');
}
for(const attribute of inAttributes){
for (const attribute of inAttributes) {
if (typeof attribute !== 'object') {
throw error('setSenses | each entry in the inAttributes array must be of type object');
}
Expand All @@ -190,7 +190,7 @@ const API = {
if (!Array.isArray(inAttributes)) {
throw error('setConditions | inAttributes must be of type array');
}
for(const attribute of inAttributes){
for (const attribute of inAttributes) {
if (typeof attribute !== 'object') {
throw error('setConditions | each entry in the inAttributes array must be of type object');
}
Expand Down Expand Up @@ -1078,7 +1078,7 @@ const API = {
throw error('updateSourceCVArr | inAttributes must be of type array');
}
const [sourceToken] = inAttributes;
for(const t of <Token[]>canvas.tokens?.placeables){
for (const t of <Token[]>canvas.tokens?.placeables) {
t.updateSource();
t.document.update();
Hooks.callAll('sightRefresh', t);
Expand All @@ -1090,7 +1090,7 @@ const API = {
}
const [sourceToken] = inAttributes;
// Hooks.callAll('sightRefresh', sourceToken);
for(const t of <Token[]>canvas.tokens?.placeables){
for (const t of <Token[]>canvas.tokens?.placeables) {
Hooks.callAll('sightRefresh', t);
}
},
Expand Down
4 changes: 2 additions & 2 deletions src/module/conditional-visibility-models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,12 +367,12 @@ export class VisionCapabilities {
// CONDITIONS
this.addConditions();

for(const sense of getSensesFromToken(srcToken.document)) {
for (const sense of getSensesFromToken(srcToken.document)) {
if (sense.visionType === 'sense' && !this.senses.has(sense.visionId)) {
this.senses.set(sense.visionId, sense);
}
}
for(const condition of getConditionsFromToken(srcToken.document)) {
for (const condition of getConditionsFromToken(srcToken.document)) {
if (condition.visionType === 'condition' && !this.conditions.has(condition.visionId)) {
this.conditions.set(condition.visionId, condition);
}
Expand Down
2 changes: 1 addition & 1 deletion src/module/lib/javascript-array-matrix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ const ArrayMatrix$2 = function ArrayMatrix() {
dive into the matrix, and place the item
at the correct vertices.
*/
for(const item of data){
for (const item of data) {
let pointer = 0;
let plane = matrix;

Expand Down
16 changes: 8 additions & 8 deletions src/module/lib/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export function enumKeys<O extends object, K extends keyof O = keyof O>(obj: O):
* @param prop
*/
export function mergeByProperty(target: any[], source: any[], prop: any) {
for(const sourceElement of source){
for (const sourceElement of source) {
const targetElement = target.find((targetElement) => {
return sourceElement[prop] === targetElement[prop];
});
Expand Down Expand Up @@ -941,7 +941,7 @@ export async function prepareActiveEffectForConditionalVisibility(
if (sense.visionLevelValue != actve) {
//@ts-ignore
const data = <ActiveEffectData>duplicateExtended(activeEffectFounded.data);
for(const aee of data?.changes) {
for (const aee of data?.changes) {
if (aee.key.startsWith('ATCV.') && !aee.key.startsWith('ATCV.condition') && aee.value) {
aee.value = String(sense.visionLevelValue);
}
Expand Down Expand Up @@ -994,7 +994,7 @@ export async function prepareActiveEffectForConditionalVisibility(
if (condition.visionLevelValue != actve) {
//@ts-ignore
const data = <ActiveEffectData>duplicateExtended(activeEffectFounded.data);
for(const aee of data?.changes) {
for (const aee of data?.changes) {
if (aee.key.startsWith('ATCV.') && !aee.key.startsWith('ATCV.condition') && aee.value) {
aee.value = String(condition.visionLevelValue);
}
Expand Down Expand Up @@ -1388,7 +1388,7 @@ export function retrieveAtcvEffectFromActiveEffect(
}

const effectEntityChanges = effectChanges.sort((a, b) => <number>a.priority - <number>b.priority);
for(const change of effectEntityChanges) {
for (const change of effectEntityChanges) {
if (change.key.startsWith('ATCV.') && !change.key.startsWith('ATCV.condition') && change.value) {
if (atcvEffect.visionId === null || atcvEffect.visionId === undefined) {
atcvEffect.visionId = change.key.slice(5);
Expand All @@ -1412,7 +1412,7 @@ export function retrieveAtcvEffectFromActiveEffect(

if (!Array.isArray(providedTags)) providedTags = [providedTags];

for(const t of providedTags) {
for (const t of providedTags) {
if (!(typeof t === 'string' || t instanceof RegExp)) {
error(`'ATCV.conditionTargets' in array must be of type string or regexp`);
}
Expand All @@ -1429,7 +1429,7 @@ export function retrieveAtcvEffectFromActiveEffect(

if (!Array.isArray(providedTags)) providedTags = [providedTags];

for(const t of providedTags) {
for (const t of providedTags) {
if (!(typeof t === 'string' || t instanceof RegExp)) {
error(`'ATCV.conditionSources' in array must be of type string or regexp`);
}
Expand Down Expand Up @@ -1699,13 +1699,13 @@ export async function toggleStealth(event) {
const conditionsOrderByName = getConditionsFromToken(this.object).sort((a, b) =>
a.visionName.localeCompare(b.visionName),
);
for (const [i, item] of sensesOrderByName.entries()) {
for (const [i, item] of sensesOrderByName.entries()) {
if (item.visionId === AtcvEffectSenseFlags.NONE) {
sensesOrderByName.splice(i, 1);
sensesOrderByName.unshift(item);
}
}
for (const [i, item] of conditionsOrderByName.entries()) {
for (const [i, item] of conditionsOrderByName.entries()) {
if (item.visionId === AtcvEffectConditionFlags.NONE) {
conditionsOrderByName.splice(i, 1);
conditionsOrderByName.unshift(item);
Expand Down
2 changes: 1 addition & 1 deletion src/module/libwrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ export function sightLayerPrototypeTestVisibilityHandler(wrapped, ...args) {
mySources = <Token[]>canvas.tokens?.controlled;
} else {
const uniqueIds = new Set();
for(const element of this.sources) {
for (const element of this.sources) {
const isDuplicate = uniqueIds.has(element.key);
uniqueIds.add(element.key);
if (!isDuplicate) {
Expand Down
23 changes: 10 additions & 13 deletions src/module/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,14 @@ export const setupHooks = async (): Promise<void> => {
//@ts-ignore
window.ConditionalVisibility.hide = ConditionalVisibility.API.hide;

// if (game[CONSTANTS.MODULE_NAME]) {
// game[CONSTANTS.MODULE_NAME] = {};
// }
// if (game[CONSTANTS.MODULE_NAME].API) {
// game[CONSTANTS.MODULE_NAME].API = {};
// }
// //@ts-ignore
// game[CONSTANTS.MODULE_NAME].API = window.ConditionalVisibility.API;

if (game[CONSTANTS.MODULE_NAME]) {
game[CONSTANTS.MODULE_NAME] = {};
}
if (game[CONSTANTS.MODULE_NAME].API) {
game[CONSTANTS.MODULE_NAME].API = {};
}
//@ts-ignore
game.modules.get(CONSTANTS.MODULE_NAME)?.api = API;
game[CONSTANTS.MODULE_NAME].API = window.ConditionalVisibility.API;
};

export const readyHooks = async (): Promise<void> => {
Expand Down Expand Up @@ -313,7 +310,7 @@ const module = {
} // Fine for
// TODO check better solution
// conditionalVisibilitySocket.executeForEveryone('sightRefreshCV', sourceToken);
for(const t of <Token[]>canvas.tokens?.placeables){
for (const t of <Token[]>canvas.tokens?.placeables) {
t.updateSource({ defer: true, deleted: false, noUpdateFog: false });
// t.document.update();
// Hooks.callAll('sightRefresh', t);
Expand Down Expand Up @@ -408,7 +405,7 @@ const module = {
}
// TODO check better solution
// conditionalVisibilitySocket.executeForEveryone('updateSourceCV', tokenToSet);
for(const t of <Token[]>canvas.tokens?.placeables){
for (const t of <Token[]>canvas.tokens?.placeables) {
t.updateSource({ defer: true, deleted: false, noUpdateFog: false });
// t.document.update();
// Hooks.callAll('sightRefresh', t);
Expand All @@ -431,7 +428,7 @@ const module = {
await sourceToken?.document.unsetFlag(CONSTANTS.MODULE_NAME, sense?.visionId);
// TODO check better solution
//conditionalVisibilitySocket.executeForEveryone('updateSourceCV', sourceToken);
for(const t of <Token[]>canvas.tokens?.placeables){
for (const t of <Token[]>canvas.tokens?.placeables) {
t.updateSource({ defer: true, deleted: false, noUpdateFog: false });
// t.document.update();
// Hooks.callAll('sightRefresh', t);
Expand Down

0 comments on commit 38cf5c8

Please sign in to comment.