Skip to content

Commit

Permalink
Merge pull request #62 from p4535992/master
Browse files Browse the repository at this point in the history
Added/Updated compatibility with tagger 1.2.1
  • Loading branch information
p4535992 authored Nov 30, 2021
2 parents 9f3ac23 + ffebbe0 commit d00e729
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 27 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

![Trigger Happy](https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2FLeague-of-Foundry-Developers%2Fleague-repo-status%2Fshields-endpoint%2Ffvtt-module-trigger-happy.json&style=for-the-badge)

![Latest Release Download Count](https://img.shields.io/github/downloads/League-of-Foundry-Developers/fvtt-module-trigger-happy/latest/v0.8.14.zip?color=2b82fc&label=DOWNLOADS&style=for-the-badge)
![Latest Release Download Count](https://img.shields.io/github/downloads/League-of-Foundry-Developers/fvtt-module-trigger-happy/latest/module.zip?color=2b82fc&label=DOWNLOADS&style=for-the-badge)

[![Forge Installs](https://img.shields.io/badge/dynamic/json?label=Forge%20Installs&query=package.installs&suffix=%25&url=https%3A%2F%2Fforge-vtt.com%2Fapi%2Fbazaar%2Fpackage%2Ftrigger-happy&colorB=006400&style=for-the-badge)](https://forge-vtt.com/bazaar#package=trigger-happy)

Expand Down
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.8.15

- Classic... after only 10 hours from the new release a incompatibility with the Tagger module version 1.2.1, now the `hasTags` is not async anymore and all the method return placeableobjets now return documents
- Update README.md, made banner latest count generic so we don't need to touch that anymore
## 0.8.14

- Add `@Door[id]{label}` like a effect
Expand Down
8 changes: 4 additions & 4 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "trigger-happy",
"title": "Trigger Happy",
"description": "Automate everything in your world by creating triggers for your players to spring traps or anything you can think of!",
"version": "0.8.14",
"version": "0.8.15",
"author": "KaKaRoTo, tposney, p4535992",
"type": "module",
"socket": true,
Expand Down Expand Up @@ -60,9 +60,9 @@
],
"url": "https://github.com/League-of-Foundry-Developers/fvtt-module-trigger-happy",
"manifest": "https://github.com/League-of-Foundry-Developers/fvtt-module-trigger-happy/releases/latest/download/module.json",
"download": "https://github.com/League-of-Foundry-Developers/fvtt-module-trigger-happy/releases/download/v0.8.14/module.zip",
"readme": "https://github.com/League-of-Foundry-Developers/fvtt-module-trigger-happy/blob/v0.8.14/README.md",
"changelog": "https://github.com/League-of-Foundry-Developers/fvtt-module-trigger-happy/blob/v0.8.14/changelog.md",
"download": "https://github.com/League-of-Foundry-Developers/fvtt-module-trigger-happy/releases/download/v0.8.15/module.zip",
"readme": "https://github.com/League-of-Foundry-Developers/fvtt-module-trigger-happy/blob/v0.8.15/README.md",
"changelog": "https://github.com/League-of-Foundry-Developers/fvtt-module-trigger-happy/blob/v0.8.15/changelog.md",
"bugs": "https://github.com/League-of-Foundry-Developers/fvtt-module-trigger-happy/issues",
"minimumCoreVersion": "0.8.3",
"compatibleCoreVersion": "0.8.9",
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": "trigger-happy",
"title": "Trigger Happy",
"description": "Automate everything in your world by creating triggers for your players to spring traps or anything you can think of!",
"version": "0.8.13",
"version": "0.8.15",
"scripts": {
"package": "gulp package",
"build": "gulp clean && gulp build && gulp link",
Expand Down
42 changes: 21 additions & 21 deletions trigger.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ Hooks.once('ready', () => {
// Do something
Hooks.on('PreStairwayTeleport', (data) => {
const { sourceSceneId, sourceData, selectedTokenIds, targetSceneId, targetData, userId } = data;
// const event = {
// x: sourceData.x,
// y: sourceData.y,
// const event = {
// x: sourceData.x,
// y: sourceData.y,
// sceneId: sourceSceneId,
// id: sourceData.name,
// name: sourceData.label
Expand All @@ -198,7 +198,7 @@ Hooks.once('ready', () => {
if(sourceSceneId){
let clickStairway = game.triggers._retrieveFromIdOrName(game.triggers._getStairways(sourceSceneId), sourceData.name);
if(!clickStairway) game.triggers._retrieveFromIdOrName(game.triggers._getStairways(sourceSceneId), sourceData.label);
upStairways.push(clickStairway);
upStairways.push(clickStairway);
}
if (upStairways.length === 0){
return;
Expand Down Expand Up @@ -382,7 +382,7 @@ export class TriggerHappy {
const triggersTmp = this._retrieveAllFromEntity(entity) ?? [];
for(let trigger of triggersTmp){
if(trigger != null && trigger != undefined){
trigger = await this._checkTagsOnTrigger(entity, trigger, filterTags);
trigger = this._checkTagsOnTrigger(entity, trigger, filterTags);
if(trigger){
if(trigger instanceof String){
trigger = trigger.toLowerCase(); // force lowercase for avoid miss typing from the user
Expand All @@ -396,7 +396,7 @@ export class TriggerHappy {
if(!trigger){
break;
}
trigger = await this._checkTagsOnTrigger(entity, trigger, filterTags);
trigger = this._checkTagsOnTrigger(entity, trigger, filterTags);
if(!trigger){
break;
}
Expand Down Expand Up @@ -441,7 +441,7 @@ export class TriggerHappy {
}
}

async _checkTagsOnTrigger(entity, trigger, filterTags){
_checkTagsOnTrigger(entity, trigger, filterTags){
// If is a placeable object
if(
this.arrayPlaceableObjects.find((el) => {
Expand All @@ -456,14 +456,14 @@ export class TriggerHappy {
if(this.taggerModuleActive && window.Tagger && filterTags){
// Check if the current placeable object has the specific tags from the global module settings
// const tagsFromPlaceableObject = Tagger.getTags(trigger) || [];
const tagsFromSetting =
const tagsFromSetting =
game.settings.get(TRIGGER_HAPPY_MODULE_NAME, 'enableTaggerIntegration')?.split(',') || [];
const filteredTagsFromSetting = tagsFromSetting.filter(function (el) {
return el != null && el != undefined && el != '';
});
if (filteredTagsFromSetting.length > 0) {
// Check if every tags on settings is included on the current placeableObject tag list
const isValid = await Tagger.hasTags(trigger, filteredTagsFromSetting,
const isValid = Tagger.hasTags(trigger, filteredTagsFromSetting,
{ caseInsensitive: true, sceneId: game.scenes.current.id });
if(!isValid){
trigger = null;
Expand All @@ -472,7 +472,7 @@ export class TriggerHappy {
// Check if the current placeable object has the specific tags from the specific placeable object settings
if(trigger && filterTags && filterTags.length > 0){
// Check if the current placeable object has the specific tag from the @TAG[label] annotation
const isValid = await Tagger.hasTags(trigger, filterTags,
const isValid = Tagger.hasTags(trigger, filterTags,
{ caseInsensitive: true, sceneId: game.scenes.current.id });
if(!isValid){
trigger = null;
Expand Down Expand Up @@ -690,7 +690,7 @@ export class TriggerHappy {
_isNoteTrigger(note, trigger, type) {
const isTrigger =
(trigger.trigger instanceof Note && trigger.trigger.id === note.id) ||
(trigger.trigger instanceof NoteDocument && trigger.trigger.id === note.id) ||
(trigger.trigger instanceof NoteDocument && trigger.trigger.id === note.id) ||
(trigger.trigger.documentName === 'JournalEntry' && trigger.trigger.sceneNote?.id === note.id);
if (!isTrigger) return false;
if (type === EVENT_TRIGGER_ENTITY_TYPES.CLICK)
Expand Down Expand Up @@ -765,7 +765,7 @@ export class TriggerHappy {
_isWallTrigger(wall, trigger, type) {
const isTrigger =
(trigger.trigger instanceof Wall && trigger.trigger.id === wall.id) ||
(trigger.trigger instanceof WallDocument && trigger.trigger.id === wall.id) ||
(trigger.trigger instanceof WallDocument && trigger.trigger.id === wall.id) ||
(trigger.trigger instanceof DoorControl && trigger.trigger.doorControl?.id === wall.id);
if (!isTrigger) return false;
if (type === EVENT_TRIGGER_ENTITY_TYPES.CLICK)
Expand Down Expand Up @@ -903,7 +903,7 @@ export class TriggerHappy {
const upJournals = this._getPlaceablesAt(journals, position);
// TODO this not work find a better solution this work only because when click on canavs there can be only one stairways at the time
const upStairways = this._getPlaceablesAt(stairways, position);
if (upTokens.length === 0 && upDrawings.length === 0 &&
if (upTokens.length === 0 && upDrawings.length === 0 &&
upNotes.length === 0 && upStairways.length === 0 && upJournals.length === 0){
return;
}
Expand Down Expand Up @@ -945,7 +945,7 @@ export class TriggerHappy {
const notes = this._getPlaceablesAt(this._getNotes(), position);
const journals = this._getPlaceablesAt(this._getJournals(), position);
const stairways = this._getPlaceablesAt(this._getStairways(), position);
if (tokens.length === 0 && drawings.length === 0 &&
if (tokens.length === 0 && drawings.length === 0 &&
notes.length === 0 && journals.length === 0){
return true;
}
Expand Down Expand Up @@ -1049,7 +1049,7 @@ export class TriggerHappy {
//if (!(trigger.trigger instanceof WallDocument)) return false;
if (!(
(trigger.trigger instanceof Wall) ||
(trigger.trigger instanceof WallDocument) ||
(trigger.trigger instanceof WallDocument) ||
(trigger.trigger instanceof DoorControl)
)
){
Expand All @@ -1059,7 +1059,7 @@ export class TriggerHappy {
return false;
}
const onClose = trigger.options.includes(EVENT_TRIGGER_ENTITY_TYPES.DOOR_CLOSE);
const onOpen = !trigger.options.includes(EVENT_TRIGGER_ENTITY_TYPES.DOOR_CLOSE) ||
const onOpen = !trigger.options.includes(EVENT_TRIGGER_ENTITY_TYPES.DOOR_CLOSE) ||
trigger.options.includes(EVENT_TRIGGER_ENTITY_TYPES.DOOR_OPEN);
return (update.ds === 1 && onOpen) || (update.ds === 0 && onClose && wallDocument.data.ds === 1);
});
Expand Down Expand Up @@ -1214,7 +1214,7 @@ export class TriggerHappy {
return chatMessage;
}
else if(entity == TRIGGER_ENTITY_TYPES.COMPENDIUM){
// compendium links can only be effects not triggers
// compendium links can only be effects not triggers
// e.g. @Compendium[SupersHomebrewPack.classes.AH3dUnrFxZHDvY2o]{Bard}
const parts = idOrName.split(".");
if (parts.length !== 3){
Expand All @@ -1224,14 +1224,14 @@ export class TriggerHappy {
return compendiumLink;
}
else if(entity == TRIGGER_ENTITY_TYPES.SOUND_LINK){
// sound links can only be effects not triggers
// sound links can only be effects not triggers
// e.g. @Sound[Test|Medieval_Fantasy City Under Attack audio atmosphere]{Attack}
const [playlistName, soundName] = idOrName.split('|')
let soundLink = new SoundLink(playlistName, soundName, label);
return soundLink;
}
else if(entity == TRIGGER_ENTITY_TYPES.PLAYLIST){
// playlist can only be effects not triggers
// playlist can only be effects not triggers
const playlistTarget = this._retrieveFromIdOrName(this._getPlaylists(), idOrName);
return playlistTarget;
}
Expand Down Expand Up @@ -1514,15 +1514,15 @@ export class TriggerHappy {
_getPlaylistSounds(){
// game.playlists.contents[0].data.sounds
const placeablesSounds = [];
game.playlists.contents.forEach((playlist, key) => {
game.playlists.contents.forEach((playlist, key) => {
placeablesSounds.push(...Object.values(playlist.sounds));
});
return placeablesSounds ?? [];
}

_getPlaylists(){
const placeablesPlaylists = [];
game.playlists.contents.forEach((playlist, key) => {
game.playlists.contents.forEach((playlist, key) => {
placeablesPlaylists.push(playlist);
});
return placeablesPlaylists ?? [];
Expand Down

0 comments on commit d00e729

Please sign in to comment.