Better management of roles effects
This commit is contained in:
parent
8a8bd489f3
commit
c49289b88f
@ -1114,12 +1114,13 @@ export class PegasusUtility {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static async processTactician(friends) {
|
static async processTactician() {
|
||||||
// Tactician management
|
// Tactician management
|
||||||
let toApply = {}
|
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) {
|
for (let token of tacticianTokens) {
|
||||||
token.refresh()
|
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) {
|
for (let friend of friends) {
|
||||||
if (friend.actor.id != token.actor.id) {
|
if (friend.actor.id != token.actor.id) {
|
||||||
let existing = toApply[friend.actor.id] || { actor: friend.actor, add: false, level: 0, names: [] }
|
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
|
// Enhancer management
|
||||||
let toApply = {}
|
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) {
|
for (let token of enhancerTokens) {
|
||||||
token.refresh()
|
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) {
|
for (let friend of friends) {
|
||||||
if (friend.actor.id != token.actor.id) {
|
if (friend.actor.id != token.actor.id) {
|
||||||
let existing = toApply[friend.actor.id] || { actor: friend.actor, add: false, level: 0, names: [] }
|
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
|
// Agitator management
|
||||||
let toApply = {}
|
let toApply = {}
|
||||||
let agitatorTokens = canvas.tokens.placeables.filter(token => token.actor.isAgitator())
|
let agitatorTokens = canvas.tokens.placeables.filter(token => token.actor.isAgitator())
|
||||||
for (let token of agitatorTokens) {
|
for (let token of agitatorTokens) {
|
||||||
token.refresh()
|
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) {
|
for (let ennemy of ennemies) {
|
||||||
if (ennemy.actor.id != token.actor.id) {
|
if (ennemy.actor.id != token.actor.id) {
|
||||||
let existing = toApply[ennemy.actor.id] || { actor: ennemy.actor, add: false, level: 0, names: [] }
|
let existing = toApply[ennemy.actor.id] || { actor: ennemy.actor, add: false, level: 0, names: [] }
|
||||||
@ -1269,26 +1280,9 @@ export class PegasusUtility {
|
|||||||
this.lastRoleEffectProcess = now
|
this.lastRoleEffectProcess = now
|
||||||
console.log("=========================+> Searching/Processing roles effects")
|
console.log("=========================+> Searching/Processing roles effects")
|
||||||
|
|
||||||
let friends = canvas.tokens.placeables.filter(token => token.actor.type == "character" && token.document.disposition == 1)
|
await this.processTactician()
|
||||||
let ennemies = canvas.tokens.placeables.filter(token => token.actor.type == "character" && token.document.disposition == -1)
|
await this.processEnhancer()
|
||||||
|
await this.processAgitator()
|
||||||
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()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,7 +253,7 @@
|
|||||||
],
|
],
|
||||||
"title": "Pegasus RPG",
|
"title": "Pegasus RPG",
|
||||||
"url": "https://www.uberwald.me/data/files/fvtt-pegasus-rpg",
|
"url": "https://www.uberwald.me/data/files/fvtt-pegasus-rpg",
|
||||||
"version": "10.0.31",
|
"version": "10.0.32",
|
||||||
"download": "https://www.uberwald.me/gitea/uberwald/fvtt-pegasus-rpg/archive/fvtt-pegasus-rpg-v10.0.31.zip",
|
"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"
|
"background": "systems/fvtt-pegasus-rpg/images/ui/pegasus_welcome_page.webp"
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user