From ff57953e75384af396523fc378f746adc21d6a9e Mon Sep 17 00:00:00 2001 From: LeRatierBretonnien Date: Fri, 15 Sep 2023 07:33:44 +0200 Subject: [PATCH] Manage status --- modules/pegasus-actor.js | 110 ++++++++++++++++++--------------------- system.json | 4 +- template.json | 2 +- 3 files changed, 53 insertions(+), 63 deletions(-) diff --git a/modules/pegasus-actor.js b/modules/pegasus-actor.js index 55d70c2..3c7753b 100644 --- a/modules/pegasus-actor.js +++ b/modules/pegasus-actor.js @@ -92,7 +92,7 @@ export class PegasusActor extends Actor { return actor; } - if (data.type == 'character'|| this.type == 'npc') { + if (data.type == 'character' || this.type == 'npc') { } @@ -764,6 +764,10 @@ export class PegasusActor extends Actor { /* -------------------------------------------- */ modifyStun(incDec) { + if ( incDec < 0 && (this.system.secondary.confidence.status == "anxious" || this.system.secondary.confidence.status == "lostface") ) { + ui.notifications.warn("Unable to recover STUN because of Confidence status : " + this.system.secondary.confidence.status) + return + } let myself = this let combat = duplicate(myself.system.combat) combat.stunlevel += incDec @@ -1244,25 +1248,6 @@ export class PegasusActor extends Actor { nrg.max += item.system.features.nrgcost.value await this.update({ 'system.nrg': nrg }) } - /* NO MORE USED - if (item.system.features.bonushealth.flag) { - let health = duplicate(this.system.secondary.health) - health.value -= Number(item.system.features.bonushealth.value) || 0 - health.max -= Number(item.system.features.bonushealth.value) || 0 - await this.update({ 'system.secondary.health': health }) - } - if (item.system.features.bonusdelirium.flag) { - let delirium = duplicate(this.system.secondary.delirium) - delirium.value -= Number(item.system.features.bonusdelirium.value) || 0 - delirium.max -= Number(item.system.features.bonusdelirium.value) || 0 - await this.update({ 'system.secondary.delirium': delirium }) - } - if (item.system.features.bonusnrg.flag) { - let nrg = duplicate(this.system.nrg) - nrg.value -= Number(item.system.features.bonusnrg.value) || 0 - nrg.max -= Number(item.system.features.bonusnrg.value) || 0 - await this.update({ 'system.nrg': nrg }) - }*/ this.disableWeaverPerk(item) PegasusUtility.createChatWithRollMode(item.name, { content: await renderTemplate(`systems/fvtt-pegasus-rpg/templates/chat-perk-ready.html`, { name: this.name, perk: duplicate(item) }) @@ -1343,7 +1328,7 @@ export class PegasusActor extends Actor { /* -------------------------------------------- */ getTraumaState() { this.traumaState = "none" - if (this.type == "character"|| this.type == 'npc') { + if (this.type == "character" || this.type == 'npc') { if (this.system.secondary.delirium.status == "trauma") { this.traumaState = "trauma" } @@ -1445,36 +1430,6 @@ export class PegasusActor extends Actor { if (this.isOwner || game.user.isGM) { let updates = {} - /* No more used - let phyDiceValue = PegasusUtility.getDiceValue(this.system.statistics.phy.value) + this.system.secondary.health.bonus + this.system.statistics.phy.mod + PegasusUtility.getDiceValue(this.system.statistics.phy.bonuseffect); - if (phyDiceValue != this.system.secondary.health.max) { - updates['system.secondary.health.max'] = phyDiceValue - } - if (this.computeValue) { - updates['system.secondary.health.value'] = phyDiceValue - } - let mndDiceValue = PegasusUtility.getDiceValue(this.system.statistics.mnd.value) + this.system.secondary.delirium.bonus + this.system.statistics.mnd.mod + PegasusUtility.getDiceValue(this.system.statistics.mnd.bonuseffect); - if (mndDiceValue != this.system.secondary.delirium.max) { - updates['system.secondary.delirium.max'] = mndDiceValue - } - if (this.computeValue) { - updates['system.secondary.delirium.value'] = mndDiceValue - } - let stlDiceValue = PegasusUtility.getDiceValue(this.system.statistics.stl.value) + this.system.secondary.stealthhealth.bonus + this.system.statistics.stl.mod + PegasusUtility.getDiceValue(this.system.statistics.stl.bonuseffect); - if (stlDiceValue != this.system.secondary.stealthhealth.max) { - updates['system.secondary.stealthhealth.max'] = stlDiceValue - } - if (this.computeValue) { - updates['system.secondary.stealthhealth.value'] = stlDiceValue - } - - let socDiceValue = PegasusUtility.getDiceValue(this.system.statistics.soc.value) + this.system.secondary.socialhealth.bonus + this.system.statistics.soc.mod + PegasusUtility.getDiceValue(this.system.statistics.soc.bonuseffect); - if (socDiceValue != this.system.secondary.socialhealth.max) { - updates['system.secondary.socialhealth.max'] = socDiceValue - } - if (this.computeValue) { - updates['system.secondary.socialhealth.value'] = socDiceValue - }*/ let nrgValue = PegasusUtility.getDiceValue(this.system.statistics.foc.value) + this.system.nrg.mod + this.system.statistics.foc.mod + PegasusUtility.getDiceValue(this.system.statistics.foc.bonuseffect) if (nrgValue != this.system.nrg.absolutemax) { @@ -1530,7 +1485,6 @@ export class PegasusActor extends Actor { } this.computeThreatLevel() } - if (this.isOwner || game.user.isGM) { // Update current hindrance level let hindrance = this.system.combat.hindrancedice @@ -1541,6 +1495,36 @@ export class PegasusActor extends Actor { if (this.system.secondary.health.status == "severlywounded" || this.system.secondary.health.status == "defeated") { hindrance += 3 } + /* Manage confidence */ + if (this.system.secondary.confidence.status == "shaken" || this.system.secondary.confidence.status == "anxious" || + this.system.secondary.confidence.status == "lostface") { + if (!this.items.find(it => it.name.toLowerCase() == "fear" && it.type == "effect")) { + let effect = await PegasusUtility.getEffectFromCompendium("Fear") + this.createEmbeddedDocuments('Item', [effect]) + } + } + /* Manage flag state for status */ + this.defeatedDisplayed = this.defeatedDisplayed && this.system.secondary.health.status != "defeated" + this.deliriumDisplayed = this.deliriumDisplayed && this.system.secondary.delirium.status != "defeated" + this.concealmentDisplayed = this.concealmentDisplayed && this.system.secondary.concealment.status != "defeated" + this.confidenceDisplayed = this.confidenceDisplayed && this.system.secondary.confidence.status != "defeated" + /* Then display relevant messages */ + if (!this.defeatedDisplayed && this.system.secondary.health.status == "defeated") { + ChatMessage.create({ content: `DEFEATED : ${this.name} must make a Death Save!` }) + this.defeatedDisplayed = true + } + if (!this.deliriumDisplayed && this.system.secondary.delirium.status == "defeated") { + ChatMessage.create({ content: `DEFEATED : ${this.name} must make a Madness Check!` }) + this.deliriumDisplayed = true + } + if (!this.concealmentDisplayed && this.system.secondary.concealment.status == "located") { + ChatMessage.create({ content: `${this.name} has been discovered! You can not longer hide and either must fight/surrender or make a run for it` }) + this.concealmentDisplayed = true + } + if (!this.confidenceDisplayed && this.system.secondary.confidence.status == "lostface") { + ChatMessage.create({ content: `${this.name} have Lost Face! You can not longer make any Social Rolls, all social rolls against your character is considered an automatic success until healed!` }) + this.confidenceDisplayed = true + } } this.system.combat.hindrancedice = hindrance this.getTraumaState() @@ -1914,7 +1898,7 @@ export class PegasusActor extends Actor { } /* -------------------------------------------- */ - computeCurrentHindrances() { + computeCurrentHindrances(statKey) { let hindrancesDices = 0 if (this.type == "character" || this.type == 'npc') { @@ -1932,6 +1916,12 @@ export class PegasusActor extends Actor { hindrancesDices += effect.system.effectlevel } } + if (statKey.toLowerCase() == "stl" && this.system.secondary.concealment.status == "exposed") { + hindrancesDices += 1 + } + if (statKey.toLowerCase() == "stl" && (this.system.secondary.concealment.status == "detected" || this.system.secondary.concealment.status == "located")) { + hindrancesDices += 3 + } } if (this.type == "vehicle") { if (this.system.stun.value > 0) { @@ -1958,7 +1948,7 @@ export class PegasusActor extends Actor { /* -------------------------------------------- */ addHindrancesList(effectsList) { - if (this.type == "character"|| this.type == 'npc') { + if (this.type == "character" || this.type == 'npc') { if (this.system.combat.stunlevel > 0) { effectsList.push({ label: "Stun Hindrance", type: "hindrance", foreign: true, actorId: this.id, applied: false, value: 2 }) } @@ -2057,7 +2047,7 @@ export class PegasusActor extends Actor { if (statKey == 'phy' && subKey == "dmg-res") { let armors = this.getArmors() for (let armor of armors) { - rollData.armorsList.push({ label: `Armor ${armor.name}`, type: "armor", applied: false, value: armor.system.resistance, adrl:armor.system.adrl }) + rollData.armorsList.push({ label: `Armor ${armor.name}`, type: "armor", applied: false, value: armor.system.resistance, adrl: armor.system.adrl }) } } if (useShield) { @@ -2210,7 +2200,7 @@ export class PegasusActor extends Actor { } if (statKey == "mr") { - if (this.type == "character"|| this.type == 'npc') { + if (this.type == "character" || this.type == 'npc') { rollData.mrVehicle = PegasusUtility.checkIsVehicleCrew(this.id) if (rollData.mrVehicle) { rollData.effectsList.push({ @@ -2229,9 +2219,9 @@ export class PegasusActor extends Actor { }) } } - } - - rollData.hindranceDices = this.computeCurrentHindrances() + } + + rollData.hindranceDices = this.computeCurrentHindrances(statKey) this.processSizeBonus(rollData) this.addEffects(rollData, isInit, isPower, subKey == "power-dmg") @@ -2250,7 +2240,7 @@ export class PegasusActor extends Actor { processSizeBonus(rollData) { if (rollData.defenderTokenId) { let diffSize = 0 - if (this.type == "character"|| this.type == 'npc') { + if (this.type == "character" || this.type == 'npc') { this.system.biodata.sizenum = this.system.biodata?.sizenum ?? 0 this.system.biodata.sizebonus = this.system.biodata?.sizebonus ?? 0 diffSize = rollData.defenderSize - this.system.biodata.sizenum + this.system.biodata.sizebonus diff --git a/system.json b/system.json index 86874bb..a4acb1a 100644 --- a/system.json +++ b/system.json @@ -252,7 +252,7 @@ ], "title": "Pegasus RPG", "url": "https://www.uberwald.me/data/files/fvtt-pegasus-rpg", - "version": "11.0.8", - "download": "https://www.uberwald.me/gitea/uberwald/fvtt-pegasus-rpg/archive/fvtt-pegasus-rpg-v11.0.8.zip", + "version": "11.0.9", + "download": "https://www.uberwald.me/gitea/uberwald/fvtt-pegasus-rpg/archive/fvtt-pegasus-rpg-v11.0.9.zip", "background": "systems/fvtt-pegasus-rpg/images/ui/pegasus_welcome_page.webp" } \ No newline at end of file diff --git a/template.json b/template.json index 282bd0f..186ddfb 100644 --- a/template.json +++ b/template.json @@ -172,7 +172,7 @@ "type": "value", "ismax": true, "iscombat": true, - "status": "healthy", + "status": "healthy", "bonus": 0, "max": 0 },