MDL/ADRL fixes + MR fixes

This commit is contained in:
LeRatierBretonnien 2023-09-19 13:52:09 +02:00
parent 552ff9564a
commit bbf0f31d4c
3 changed files with 32 additions and 26 deletions

View File

@ -1924,6 +1924,18 @@ export class PegasusActor extends Actor {
await this.createEmbeddedDocuments('Item', newItems) await this.createEmbeddedDocuments('Item', newItems)
} }
/* -------------------------------------------- */
checkEFfectsHindranceDeletion(statKey) {
let toRem = []
let effects = this.items.filter(effect => effect.type == 'effect' && effect.system.oneuse &&
effect.system.hindrance && (effect.system.stataffected == statKey || effect.system.stataffected == "all"))
for (let effect of effects) {
toRem.push(effect.id)
}
if (toRem.length > 0) {
this.deleteEmbeddedDocuments('Item', toRem)
}
}
/* -------------------------------------------- */ /* -------------------------------------------- */
computeCurrentHindrances(statKey) { computeCurrentHindrances(statKey) {
@ -1935,15 +1947,9 @@ export class PegasusActor extends Actor {
if (overCapacity > 0) { if (overCapacity > 0) {
hindrancesDices += overCapacity hindrancesDices += overCapacity
} }
let effects = this.items.filter(item => item.type == 'effect') let effects = this.items.filter(effect => effect.type == 'effect' && effect.system.hindrance && (effect.system.stataffected == statKey || effect.system.stataffected == "all"))
for (let effect of effects) { for (let effect of effects) {
if (effect.system.hindrance && ( effect.system.stataffected == statKey || effect.system.stataffected == "all")) {
hindrancesDices += effect.system.effectlevel hindrancesDices += effect.system.effectlevel
if ( effect.system.oneuse) {
effect.system.isUSed = true // Ensure deletion
this.deleteEmbeddedDocuments('Item', [effect.id])
}
}
} }
if (statKey.toLowerCase() == "stl" && this.system.secondary.concealment.status == "exposed") { if (statKey.toLowerCase() == "stl" && this.system.secondary.concealment.status == "exposed") {
hindrancesDices += 1 hindrancesDices += 1

View File

@ -801,11 +801,11 @@ export class PegasusUtility {
} }
} }
} }
if (toRem.length > 0) {
//console.log("Going to remove one use effects", toRem)
let actor = game.actors.get(rollData.actorId) let actor = game.actors.get(rollData.actorId)
if (toRem.length > 0) {
actor.deleteEmbeddedDocuments('Item', toRem) actor.deleteEmbeddedDocuments('Item', toRem)
} }
actor.checkEFfectsHindranceDeletion(rollData.statKey)
} }
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@ -252,7 +252,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": "11.0.20", "version": "11.0.21",
"download": "https://www.uberwald.me/gitea/uberwald/fvtt-pegasus-rpg/archive/fvtt-pegasus-rpg-v11.0.20.zip", "download": "https://www.uberwald.me/gitea/uberwald/fvtt-pegasus-rpg/archive/fvtt-pegasus-rpg-v11.0.21.zip",
"background": "systems/fvtt-pegasus-rpg/images/ui/pegasus_welcome_page.webp" "background": "systems/fvtt-pegasus-rpg/images/ui/pegasus_welcome_page.webp"
} }