From 0d144ef2a93eca38e4889999e4cdf20d51015fe5 Mon Sep 17 00:00:00 2001 From: sladecraven Date: Wed, 19 Jan 2022 21:25:59 +0100 Subject: [PATCH] Fix tokens update --- modules/pegasus-actor.js | 94 ++++++++++++++++++++-------------------- system.json | 2 +- 2 files changed, 49 insertions(+), 47 deletions(-) diff --git a/modules/pegasus-actor.js b/modules/pegasus-actor.js index 331d675..8395bbb 100644 --- a/modules/pegasus-actor.js +++ b/modules/pegasus-actor.js @@ -579,54 +579,56 @@ export class PegasusActor extends Actor { /* -------------------------------------------- */ async computeNRGHealth() { - let updates = {} - let phyDiceValue = PegasusUtility.getDiceValue(this.data.data.statistics.phy.value) + this.data.data.secondary.health.bonus + this.data.data.statistics.phy.mod; - if (phyDiceValue != this.data.data.secondary.health.max) { - updates['data.secondary.health.max'] = phyDiceValue - updates['data.secondary.health.value'] = phyDiceValue - } - let mndDiceValue = PegasusUtility.getDiceValue(this.data.data.statistics.mnd.value) + this.data.data.secondary.delirium.bonus + this.data.data.statistics.mnd.mod; - if (mndDiceValue != this.data.data.secondary.delirium.max) { - updates['data.secondary.delirium.max'] = mndDiceValue - updates['data.secondary.delirium.value'] = mndDiceValue - } - let stlDiceValue = PegasusUtility.getDiceValue(this.data.data.statistics.stl.value) + this.data.data.secondary.stealthhealth.bonus + this.data.data.statistics.stl.mod; - if (stlDiceValue != this.data.data.secondary.stealthhealth.max) { - updates['data.secondary.stealthhealth.max'] = stlDiceValue - updates['data.secondary.stealthhealth.value'] = stlDiceValue - } - - let socDiceValue = PegasusUtility.getDiceValue(this.data.data.statistics.soc.value) + this.data.data.secondary.socialhealth.bonus + this.data.data.statistics.soc.mod; - if (socDiceValue != this.data.data.secondary.socialhealth.max) { - updates['data.secondary.socialhealth.max'] = socDiceValue - updates['data.secondary.socialhealth.value'] = socDiceValue - } - - let nrgValue = PegasusUtility.getDiceValue(this.data.data.statistics.foc.value) + this.data.data.nrg.mod + this.data.data.statistics.foc.mod; - if (nrgValue != this.data.data.nrg.max) { - updates['data.nrg.max'] = nrgValue - updates['data.nrg.value'] = nrgValue - } - if (nrgValue != this.data.data.combat.stunthreshold) { - updates['data.combat.stunthreshold'] = nrgValue - } - - let mrLevel = (this.data.data.statistics.agi.value + this.data.data.statistics.str.value) - this.data.data.statistics.phy.value - mrLevel = (mrLevel < 1) ? 1 : mrLevel; - if (mrLevel != this.data.data.mr.value) { - updates['data.mr.value'] = mrLevel - } + if ( this.isOwner || game.user.isGM) { + let updates = {} + let phyDiceValue = PegasusUtility.getDiceValue(this.data.data.statistics.phy.value) + this.data.data.secondary.health.bonus + this.data.data.statistics.phy.mod; + if (phyDiceValue != this.data.data.secondary.health.max) { + updates['data.secondary.health.max'] = phyDiceValue + updates['data.secondary.health.value'] = phyDiceValue + } + let mndDiceValue = PegasusUtility.getDiceValue(this.data.data.statistics.mnd.value) + this.data.data.secondary.delirium.bonus + this.data.data.statistics.mnd.mod; + if (mndDiceValue != this.data.data.secondary.delirium.max) { + updates['data.secondary.delirium.max'] = mndDiceValue + updates['data.secondary.delirium.value'] = mndDiceValue + } + let stlDiceValue = PegasusUtility.getDiceValue(this.data.data.statistics.stl.value) + this.data.data.secondary.stealthhealth.bonus + this.data.data.statistics.stl.mod; + if (stlDiceValue != this.data.data.secondary.stealthhealth.max) { + updates['data.secondary.stealthhealth.max'] = stlDiceValue + updates['data.secondary.stealthhealth.value'] = stlDiceValue + } + + let socDiceValue = PegasusUtility.getDiceValue(this.data.data.statistics.soc.value) + this.data.data.secondary.socialhealth.bonus + this.data.data.statistics.soc.mod; + if (socDiceValue != this.data.data.secondary.socialhealth.max) { + updates['data.secondary.socialhealth.max'] = socDiceValue + updates['data.secondary.socialhealth.value'] = socDiceValue + } + + let nrgValue = PegasusUtility.getDiceValue(this.data.data.statistics.foc.value) + this.data.data.nrg.mod + this.data.data.statistics.foc.mod; + if (nrgValue != this.data.data.nrg.max) { + updates['data.nrg.max'] = nrgValue + updates['data.nrg.value'] = nrgValue + } + if (nrgValue != this.data.data.combat.stunthreshold) { + updates['data.combat.stunthreshold'] = nrgValue + } + + let mrLevel = (this.data.data.statistics.agi.value + this.data.data.statistics.str.value) - this.data.data.statistics.phy.value + mrLevel = (mrLevel < 1) ? 1 : mrLevel; + if (mrLevel != this.data.data.mr.value) { + updates['data.mr.value'] = mrLevel + } - let race = this.getRace() - if ( race && race.name && (race.name != this.data.data.biodata.racename) ) { - updates['data.biodata.racename'] = race.name + let race = this.getRace() + if ( race && race.name && (race.name != this.data.data.biodata.racename) ) { + updates['data.biodata.racename'] = race.name + } + let role = this.getRole() + if ( role && role.name && (role.name != this.data.data.biodata.rolename)) { + updates['data.biodata.rolename'] = role.name + } + //console.log("UPD", updates, this.data.data.biodata) + await this.update(updates) } - let role = this.getRole() - if ( role && role.name && (role.name != this.data.data.biodata.rolename)) { - updates['data.biodata.rolename'] = role.name - } - //console.log("UPD", updates, this.data.data.biodata) - await this.update(updates) } /* -------------------------------------------- */ diff --git a/system.json b/system.json index 71c8e8b..35fbc17 100644 --- a/system.json +++ b/system.json @@ -163,6 +163,6 @@ "templateVersion": 61, "title": "Pegasus RPG", "url": "https://www.uberwald.me/data/files/fvtt-pegasus-rpg", - "version": "0.1.9", + "version": "0.1.10", "background" : "./images/ui/pegasus_welcome_page.webp" }