diff --git a/modules/pegasus-actor.js b/modules/pegasus-actor.js index cf6b2ef..bbb1a85 100644 --- a/modules/pegasus-actor.js +++ b/modules/pegasus-actor.js @@ -237,7 +237,7 @@ export class PegasusActor extends Actor { nrg.activated += item.data.data.costspent nrg.value -= item.data.data.costspent nrg.max -= item.data.data.costspent - this.update({ 'data.nrg': nrg }) + await this.update({ 'data.nrg': nrg }) let effects = [] for (let effect of item.data.data.effectsgained) { @@ -250,7 +250,7 @@ export class PegasusActor extends Actor { } else { nrg.activated -= item.data.data.costspent nrg.max += item.data.data.costspent - this.update({ 'data.nrg': nrg }) + await this.update({ 'data.nrg': nrg }) let toRem = [] for (let item of this.data.items) { @@ -520,24 +520,26 @@ export class PegasusActor extends Actor { let updateOK = true if (status == "ready") { this.cleanPerkEffects(itemId) + await this.updateEmbeddedDocuments('Item', [{ _id: itemId, 'data.used1': false, 'data.used3': false, 'data.used3': false }] ) // Reset on Ready if (item.data.data.features.nrgcost.flag) { let nrg = duplicate(this.data.data.nrg) nrg.activated -= item.data.data.features.nrgcost.value - this.update({ 'data.nrg': nrg }) + nrg.max += item.data.data.features.nrgcost.value + await this.update({ 'data.nrg': nrg }) } if (item.data.data.features.bonushealth.flag) { let health = duplicate(this.data.data.secondary.health) - health.bonus -= item.data.data.features.bonushealth.value + health.bonus -= Number(item.data.data.features.bonushealth.value) || 0 this.update({ 'data.secondary.health': health }) } if (item.data.data.features.bonusdelirium.flag) { - let delirium = duplicate(this.data.data.delirium.delirium) - delirium.bonus -= item.data.data.features.bonusdelirium.value + let delirium = duplicate(this.data.data.secondary.delirium) + delirium.bonus -= Number(item.data.data.features.bonusdelirium.value) || 0 this.update({ 'data.secondary.delirium': delirium }) } if (item.data.data.features.bonusnrg.flag) { let nrg = duplicate(this.data.data.nrg) - nrg.mod -= item.data.data.features.bonusnrg.value + nrg.mod -= Number(item.data.data.features.bonusnrg.value) || 0 this.update({ 'data.nrg': nrg }) } this.disableWeaverPerk(item) @@ -555,10 +557,11 @@ export class PegasusActor extends Actor { } // Manage additional flags if (item.data.data.features.nrgcost.flag) { - if (this.data.data.nrg.value >= item.data.data.features.nrgcost.value) { + if ( (this.data.data.nrg.value >= item.data.data.features.nrgcost.value) && (this.data.data.nrg.max >= item.data.data.features.nrgcost.value)) { let nrg = duplicate(this.data.data.nrg) nrg.activated += item.data.data.features.nrgcost.value nrg.value -= item.data.data.features.nrgcost.value + nrg.max -= item.data.data.features.nrgcost.value this.update({ 'data.nrg': nrg }) } else { updateOK = false @@ -567,17 +570,17 @@ export class PegasusActor extends Actor { } if (item.data.data.features.bonushealth.flag) { let health = duplicate(this.data.data.secondary.health) - health.bonus += item.data.data.features.bonushealth.value + health.bonus += Number(item.data.data.features.bonushealth.value) || 0 this.update({ 'data.secondary.health': health }) } if (item.data.data.features.bonusdelirium.flag) { - let delirium = duplicate(this.data.data.delirium.delirium) - delirium.bonus += item.data.data.features.bonusdelirium.value + let delirium = duplicate(this.data.data.secondary.delirium) + delirium.bonus += Number(item.data.data.features.bonusdelirium.value) || 0 this.update({ 'data.secondary.delirium': delirium }) } if (item.data.data.features.bonusnrg.flag) { let nrg = duplicate(this.data.data.nrg) - nrg.mod += item.data.data.features.bonusnrg.value + nrg.mod += Number(item.data.data.features.bonusnrg.value) || 0 this.update({ 'data.nrg': nrg }) } this.enableWeaverPerk(item) @@ -610,29 +613,28 @@ export class PegasusActor extends Actor { 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 + //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 + //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 + //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 + //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.nrg.absolutemax) { + updates['data.nrg.absolutemax'] = nrgValue } nrgValue = PegasusUtility.getDiceValue(this.data.data.statistics.foc.value) + this.data.data.statistics.foc.mod; if (nrgValue != this.data.data.combat.stunthreshold) { diff --git a/system.json b/system.json index fa10e4b..0a11c0b 100644 --- a/system.json +++ b/system.json @@ -180,9 +180,9 @@ "styles": [ "styles/simple.css" ], - "templateVersion": 75, + "templateVersion": 77, "title": "Pegasus RPG", "url": "https://www.uberwald.me/data/files/fvtt-pegasus-rpg", - "version": "0.4.10", + "version": "0.4.12", "background" : "./images/ui/pegasus_welcome_page.webp" } diff --git a/template.json b/template.json index 8383695..6df1ff0 100644 --- a/template.json +++ b/template.json @@ -109,6 +109,7 @@ "nrg": { "label": "NRG", "type": "value", + "absolutemax": 0, "value": 0, "max": 0, "mod": 0, @@ -268,36 +269,42 @@ "label": "NRG cost to use", "flag": false, "type": "number", + "isvalid": true, "value": 0 }, "range": { "label": "Range", "flag": false, "type": "range", + "isvalid": true, "value": "" }, "nbtargets": { "label": "# Targets", "flag": false, "type": "string", + "isvalid": true, "value": "" }, "bonushealth": { "label": "Bonus to Health", "flag": false, "type": "string", + "isvalid": true, "value": "" }, "bonusnrg": { "label": "Bonus to NRG", "flag": false, "type": "string", + "isvalid": true, "value": "" }, "bonusdelirium": { "label": "Bonus to Delirium", "flag": false, "type": "string", + "isvalid": true, "value": "" } }, diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index 1d7844a..9132e6b 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -88,6 +88,7 @@ Cur Mod Max + / {{data.nrg.absolutemax}} @@ -169,6 +170,7 @@ Cur Mod Max + / {{data.nrg.absolutemax}}