diff --git a/modules/pegasus-utility.js b/modules/pegasus-utility.js index 355dee2..02f1ba1 100644 --- a/modules/pegasus-utility.js +++ b/modules/pegasus-utility.js @@ -1114,12 +1114,13 @@ export class PegasusUtility { } /* -------------------------------------------- */ - static async processTactician(friends) { + static async processTactician() { // Tactician management let toApply = {} - let tacticianTokens = canvas.tokens.placeables.filter(token => token.actor.isTactician()) + let tacticianTokens = canvas.tokens.placeables.filter(token => token.actor.isTactician() && !newToken.document.hidden) for (let token of tacticianTokens) { token.refresh() + let friends = canvas.tokens.placeables.filter(newToken => newToken.actor.type == "character" && !newToken.document.hidden && newToken.document.disposition == token.document.disposition) for (let friend of friends) { if (friend.actor.id != token.actor.id) { let existing = toApply[friend.actor.id] || { actor: friend.actor, add: false, level: 0, names: [] } @@ -1161,12 +1162,13 @@ export class PegasusUtility { } /* -------------------------------------------- */ - static async processEnhancer(friends) { + static async processEnhancer() { // Enhancer management let toApply = {} - let enhancerTokens = canvas.tokens.placeables.filter(token => token.actor.isEnhancer()) + let enhancerTokens = canvas.tokens.placeables.filter(token => token.actor.isEnhancer() && !newToken.document.hidden) for (let token of enhancerTokens) { token.refresh() + let friends = canvas.tokens.placeables.filter(newToken => newToken.actor.type == "character" && !newToken.document.hidden && newToken.document.disposition == token.document.disposition) for (let friend of friends) { if (friend.actor.id != token.actor.id) { let existing = toApply[friend.actor.id] || { actor: friend.actor, add: false, level: 0, names: [] } @@ -1210,12 +1212,21 @@ export class PegasusUtility { } /* -------------------------------------------- */ - static async processAgitator(ennemies) { + static async processAgitator() { // Agitator management let toApply = {} let agitatorTokens = canvas.tokens.placeables.filter(token => token.actor.isAgitator()) for (let token of agitatorTokens) { token.refresh() + if (token.document.disposition == 0) { + continue + } + let disposition = ( token.document.disposition == -1) ? 1 : -1 + let ennemies = canvas.tokens.placeables.filter(newToken => newToken.actor.type == "character" && !newToken.document.hidden && newToken.document.disposition == disposition) + let neutrals = canvas.tokens.placeables.filter(newToken => newToken.actor.type == "character" && !newToken.document.hidden && newToken.document.disposition == 0) + if (neutrals ) { + ennemies = ennemies.concat(neutrals) + } for (let ennemy of ennemies) { if (ennemy.actor.id != token.actor.id) { let existing = toApply[ennemy.actor.id] || { actor: ennemy.actor, add: false, level: 0, names: [] } @@ -1269,26 +1280,9 @@ export class PegasusUtility { this.lastRoleEffectProcess = now console.log("=========================+> Searching/Processing roles effects") - let friends = canvas.tokens.placeables.filter(token => token.actor.type == "character" && token.document.disposition == 1) - let ennemies = canvas.tokens.placeables.filter(token => token.actor.type == "character" && token.document.disposition == -1) - - await this.processTactician(friends) - await this.processEnhancer(friends) - await this.processAgitator(ennemies) - - // Cleanup if disposition has changed - let allTokens = canvas.tokens.placeables.filter(token => token.actor.type == "character") - for (let token of allTokens) { - if (token.document.disposition != -1 && token.actor.hasAgitatorHindrance()) { - token.actor.removeAgitatorHindrance() - } - if (token.document.disposition != 1 && token.actor.hasTacticianBonus()) { - token.actor.removeTacticianEffect() - } - if (token.document.disposition != 1 && token.actor.hasEnhancerBonus()) { - token.actor.removeEnhancerEffect() - } - } + await this.processTactician() + await this.processEnhancer() + await this.processAgitator() } diff --git a/system.json b/system.json index cfcdbb9..baa7f9d 100644 --- a/system.json +++ b/system.json @@ -253,7 +253,7 @@ ], "title": "Pegasus RPG", "url": "https://www.uberwald.me/data/files/fvtt-pegasus-rpg", - "version": "10.0.31", - "download": "https://www.uberwald.me/gitea/uberwald/fvtt-pegasus-rpg/archive/fvtt-pegasus-rpg-v10.0.31.zip", + "version": "10.0.32", + "download": "https://www.uberwald.me/gitea/uberwald/fvtt-pegasus-rpg/archive/fvtt-pegasus-rpg-v10.0.32.zip", "background": "systems/fvtt-pegasus-rpg/images/ui/pegasus_welcome_page.webp" } \ No newline at end of file