Fix tokens update

This commit is contained in:
sladecraven 2022-01-19 21:25:59 +01:00
parent 97c27f43ba
commit 0d144ef2a9
2 changed files with 49 additions and 47 deletions

View File

@ -579,54 +579,56 @@ export class PegasusActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
async computeNRGHealth() { async computeNRGHealth() {
let updates = {} if ( this.isOwner || game.user.isGM) {
let phyDiceValue = PegasusUtility.getDiceValue(this.data.data.statistics.phy.value) + this.data.data.secondary.health.bonus + this.data.data.statistics.phy.mod; let updates = {}
if (phyDiceValue != this.data.data.secondary.health.max) { let phyDiceValue = PegasusUtility.getDiceValue(this.data.data.statistics.phy.value) + this.data.data.secondary.health.bonus + this.data.data.statistics.phy.mod;
updates['data.secondary.health.max'] = phyDiceValue if (phyDiceValue != this.data.data.secondary.health.max) {
updates['data.secondary.health.value'] = phyDiceValue 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) { let mndDiceValue = PegasusUtility.getDiceValue(this.data.data.statistics.mnd.value) + this.data.data.secondary.delirium.bonus + this.data.data.statistics.mnd.mod;
updates['data.secondary.delirium.max'] = mndDiceValue if (mndDiceValue != this.data.data.secondary.delirium.max) {
updates['data.secondary.delirium.value'] = mndDiceValue 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) { let stlDiceValue = PegasusUtility.getDiceValue(this.data.data.statistics.stl.value) + this.data.data.secondary.stealthhealth.bonus + this.data.data.statistics.stl.mod;
updates['data.secondary.stealthhealth.max'] = stlDiceValue if (stlDiceValue != this.data.data.secondary.stealthhealth.max) {
updates['data.secondary.stealthhealth.value'] = stlDiceValue 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; 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) { if (socDiceValue != this.data.data.secondary.socialhealth.max) {
updates['data.secondary.socialhealth.max'] = socDiceValue updates['data.secondary.socialhealth.max'] = socDiceValue
updates['data.secondary.socialhealth.value'] = 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; 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) { if (nrgValue != this.data.data.nrg.max) {
updates['data.nrg.max'] = nrgValue updates['data.nrg.max'] = nrgValue
updates['data.nrg.value'] = nrgValue updates['data.nrg.value'] = nrgValue
} }
if (nrgValue != this.data.data.combat.stunthreshold) { if (nrgValue != this.data.data.combat.stunthreshold) {
updates['data.combat.stunthreshold'] = nrgValue 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 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; mrLevel = (mrLevel < 1) ? 1 : mrLevel;
if (mrLevel != this.data.data.mr.value) { if (mrLevel != this.data.data.mr.value) {
updates['data.mr.value'] = mrLevel updates['data.mr.value'] = mrLevel
} }
let race = this.getRace() let race = this.getRace()
if ( race && race.name && (race.name != this.data.data.biodata.racename) ) { if ( race && race.name && (race.name != this.data.data.biodata.racename) ) {
updates['data.biodata.racename'] = race.name 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)
} }
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@ -163,6 +163,6 @@
"templateVersion": 61, "templateVersion": 61,
"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": "0.1.9", "version": "0.1.10",
"background" : "./images/ui/pegasus_welcome_page.webp" "background" : "./images/ui/pegasus_welcome_page.webp"
} }