Fix #115 fix negative effect

This commit is contained in:
sladecraven 2022-10-07 17:45:53 +02:00
parent 8fac4dcb36
commit b2dd8edab2
3 changed files with 17 additions and 8 deletions

View File

@ -1744,7 +1744,7 @@ export class PegasusActor extends Actor {
let effects = this.items.filter(item => item.type == 'effect') let effects = this.items.filter(item => item.type == 'effect')
for (let effect of effects) { for (let effect of effects) {
effect = duplicate(effect) effect = duplicate(effect)
if (!effect.system.hindrance && !effect.system.statdice if (!effect.system.hindrance && !effect.system.statdice && !effect.system.reducedicevalue
&& (effect.system.stataffected != "notapplicable" || effect.system.specaffected.length > 0) && (effect.system.stataffected != "notapplicable" || effect.system.specaffected.length > 0)
&& effect.system.stataffected != "special" && effect.system.stataffected != "special"
&& effect.system.stataffected != "powerroll" && effect.system.stataffected != "powerroll"
@ -2214,17 +2214,26 @@ export class PegasusActor extends Actor {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
processVehicleStatEffects() { processVehicleStatEffects() {
let effects = this.items.filter(effect => effect.type == "effect" && effect.system.genre == "positive" && effect.system.statdice) let bonus = 0
let effectsPlus = this.items.filter(effect => effect.type == "effect" && effect.system.genre == "positive" && effect.system.statdice)
let effectsMinus = this.items.filter(effect => effect.type == "effect" && effect.system.genre == "negative" && effect.system.reducedicevalue)
for (let statKey in this.system.statistics) { for (let statKey in this.system.statistics) {
let stat = duplicate(this.system.statistics[statKey]) let stat = duplicate(this.system.statistics[statKey])
let bonus = 0 for (let effect of effectsPlus) {
for (let effect of effects) {
if (effect.system.stataffected == statKey) { if (effect.system.stataffected == statKey) {
bonus += Number(effect.system.effectlevel) bonus += Number(effect.system.effectlevel)
} }
} }
for (let effect of effectsMinus) {
if (effect.system.stataffected == statKey) {
bonus -= Number(effect.system.effectlevel)
}
}
if (bonus != stat.bonuseffect) { if (bonus != stat.bonuseffect) {
stat.bonuseffect = bonus stat.bonuseffect = bonus
if (stat.currentlevel > stat.bonuseffect+stat.level) {
stat.currentlevel = stat.bonuseffect+stat.level
}
this.update({ [`system.statistics.${statKey}`]: stat }) this.update({ [`system.statistics.${statKey}`]: stat })
} }
} }

View File

@ -544,7 +544,7 @@ export class PegasusUtility {
/* -------------------------------------------- */ /* -------------------------------------------- */
static getDiceFromLevel(level = 0) { static getDiceFromLevel(level = 0) {
level = Number(level) level = Math.max( Number(level), 0)
return this.diceList[level]; return this.diceList[level];
} }
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@ -253,7 +253,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": "10.1.7", "version": "10.1.8",
"download": "https://www.uberwald.me/gitea/uberwald/fvtt-pegasus-rpg/archive/fvtt-pegasus-rpg-v10.1.7.zip", "download": "https://www.uberwald.me/gitea/uberwald/fvtt-pegasus-rpg/archive/fvtt-pegasus-rpg-v10.1.8.zip",
"background": "systems/fvtt-pegasus-rpg/images/ui/pegasus_welcome_page.webp" "background": "systems/fvtt-pegasus-rpg/images/ui/pegasus_welcome_page.webp"
} }