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.23
Browse files Browse the repository at this point in the history
  • Loading branch information
p4535992 committed Mar 31, 2022
1 parent cf72490 commit 49cd138
Show file tree
Hide file tree
Showing 6 changed files with 243 additions and 209 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.23

- Bug fix on unset flag and repair method

### 0.5.22

- Solved https://github.com/p4535992/conditional-visibility/issues/25
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.22",
"version": "0.5.23",
"scripts": {
"package": "gulp package",
"build": "gulp build && gulp link",
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.22",
"version": "0.5.23",
"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.22/module.zip",
"readme": "https://github.com/p4535992/conditional-visibility/blob/v0.5.22/README.md",
"changelog": "https://github.com/p4535992/conditional-visibility/blob/v0.5.22/changelog.md",
"download": "https://github.com/p4535992/conditional-visibility/releases/download/v0.5.23/module.zip",
"readme": "https://github.com/p4535992/conditional-visibility/blob/v0.5.23/README.md",
"changelog": "https://github.com/p4535992/conditional-visibility/blob/v0.5.23/changelog.md",
"bugs": "https://github.com/p4535992/conditional-visibility/issues",
"allowBugReporter": true,
"dependencies": [
Expand Down
61 changes: 50 additions & 11 deletions src/module/lib/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1878,42 +1878,42 @@ export async function repairAndSetFlag(token: Token, key: string, value: AtcvEff
let updateKey = '';
if (!aee.key.startsWith('ATCV.condition')) {
updateKey = aee.key.slice(5);
if(aee.value != String(value?.visionLevelValue)){
if (aee.value != String(value?.visionLevelValue)) {
thereISADifference = true;
}
} else if (aee.key.startsWith('ATCV.conditionElevation')) {
if(aee.value != String(value?.visionElevation)){
if (aee.value != String(value?.visionElevation)) {
thereISADifference = true;
}
} else if (aee.key.startsWith('ATCV.conditionDistance')) {
if(aee.value != String(value?.visionDistanceValue)){
if (aee.value != String(value?.visionDistanceValue)) {
thereISADifference = true;
}
} else if (aee.key.startsWith('ATCV.conditionTargets')) {
if(aee.value != String(value?.visionTargets)){
if (aee.value != String(value?.visionTargets)) {
thereISADifference = true;
}
} else if (aee.key.startsWith('ATCV.conditionSources')) {
if(aee.value != String(value?.visionSources)){
if (aee.value != String(value?.visionSources)) {
thereISADifference = true;
}
} else if (aee.key.startsWith('ATCV.conditionTargetImage')) {
if(aee.value != String(value?.visionTargetImage)){
if (aee.value != String(value?.visionTargetImage)) {
thereISADifference = true;
}
} else if (aee.key.startsWith('ATCV.conditionType')) {
if(aee.value != String(value?.visionType)){
if (aee.value != String(value?.visionType)) {
thereISADifference = true;
}
}
if(updateKey === value.visionId){
if (updateKey === value.visionId) {
break;
}else{
} else {
thereISADifference = false;
}
}
}
}else{
} else {
thereISADifference = true;
}
if (token.document.getFlag(CONSTANTS.MODULE_NAME, key)) {
Expand All @@ -1938,7 +1938,7 @@ export async function repairAndSetFlag(token: Token, key: string, value: AtcvEff
await token.actor.unsetFlag(CONSTANTS.MODULE_NAME, 'conditionType');
}

if(thereISADifference){
if (thereISADifference) {
await token.actor?.setFlag(CONSTANTS.MODULE_NAME, key, value);
let data: AtcvEffect[] = [];
if (value.visionType === 'sense') {
Expand Down Expand Up @@ -2011,6 +2011,45 @@ export async function repairAndUnSetFlag(token: Token, key: string) {
await token.actor.unsetFlag(CONSTANTS.MODULE_NAME, 'conditionType');
}
await token.actor?.unsetFlag(CONSTANTS.MODULE_NAME, key);

const isSense = !!API.SENSES.find((sense: SenseData) => {
return isStringEquals(sense.id, key);
});
const isCondition = !!API.CONDITIONS.find((sense: SenseData) => {
return isStringEquals(sense.id, key);
});
let data: AtcvEffect[] = [];
if (isSense) {
// data = <AtcvEffect[]>token.actor?.getFlag(CONSTANTS.MODULE_NAME, ConditionalVisibilityFlags.DATA_SENSES) ?? [];
data = getSensesFromToken(token.document, true);
} else if (isCondition) {
// data = <AtcvEffect[]>token.actor?.getFlag(CONSTANTS.MODULE_NAME, ConditionalVisibilityFlags.DATA_CONDITIONS) ?? [];
data = getConditionsFromToken(token.document, true);
} else {
return;
}
//Find index of specific object using findIndex method.
const objIndex = data.findIndex((obj) => obj.visionId === key);
if (objIndex >= 0) {
//Update object's name property.
data.splice(objIndex, 1); // 2nd parameter means remove one item only
}
data = data.filter((a) => {
return (
a.visionLevelValue != 0 &&
a.visionLevelValue != undefined &&
a.visionLevelValue != null &&
is_real_number(a.visionLevelValue) &&
!a.visionIsDisabled
);
});
if (isSense) {
await token.actor?.setFlag(CONSTANTS.MODULE_NAME, ConditionalVisibilityFlags.DATA_SENSES, data);
} else if (isCondition) {
await token.actor?.setFlag(CONSTANTS.MODULE_NAME, ConditionalVisibilityFlags.DATA_CONDITIONS, data);
} else {
// DO NOTHING
}
// canvas.perception.schedule({
// lighting: { refresh: true },
// sight: { refresh: true },
Expand Down
3 changes: 1 addition & 2 deletions src/module/libwrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ export function sightLayerPrototypeTestVisibilityHandler(wrapped, ...args) {
// this.sources is a map of selected tokens (may be size 0) all tokens
// contribute to the vision so iterate through the tokens
// TODO find a better and fat way to prepera the sources array

let mySources: Token[] = [];
if (!this.sources || this.sources.size === 0) {
// return res;
Expand Down Expand Up @@ -328,7 +328,6 @@ export function sightLayerPrototypeTestVisibilityHandler(wrapped, ...args) {
break;
}
}


if (game.settings.get(CONSTANTS.MODULE_NAME, 'debug')) {
const sourcesNames = <string[]>mySources.map((e) => {
Expand Down
Loading

0 comments on commit 49cd138

Please sign in to comment.