Fix #99 effect stat for vehicle

This commit is contained in:
sladecraven 2022-10-05 21:14:15 +02:00
parent 932573c9ae
commit d8215301b4
2 changed files with 1903 additions and 1883 deletions

View File

@ -124,9 +124,9 @@ export class PegasusActor extends Actor {
this.updateSize() this.updateSize()
} }
if (this.type == 'vehicle') { if (this.type == 'vehicle') {
this.computeVehicleStats(); this.computeVehicleStats()
} }
super.prepareDerivedData(); super.prepareDerivedData()
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -263,8 +263,10 @@ export class PegasusActor extends Actor {
effect.system.stataffected = "mr" effect.system.stataffected = "mr"
effect.system.bonusdice = true effect.system.bonusdice = true
await this.createEmbeddedDocuments('Item', [effect]) await this.createEmbeddedDocuments('Item', [effect])
ChatMessage.create({ content: `Tactician Bonus Dice has been added to ${this.name} (${level})`, ChatMessage.create({
whisper: ChatMessage.getWhisperRecipients('GM') } ) content: `Tactician Bonus Dice has been added to ${this.name} (${level})`,
whisper: ChatMessage.getWhisperRecipients('GM')
})
} }
async removeTacticianEffect() { async removeTacticianEffect() {
let effect = this.items.find(item => item.name.toLowerCase().includes("tactician bonus dice")) let effect = this.items.find(item => item.name.toLowerCase().includes("tactician bonus dice"))
@ -2161,6 +2163,23 @@ addTopSpeedBonus(topspeed, bonus) {
effect.system.isspeed = speed effect.system.isspeed = speed
await this.createEmbeddedDocuments("Item", [effect]) await this.createEmbeddedDocuments("Item", [effect])
} }
/* -------------------------------------------- */
processVehicleStatEffects() {
let effects = this.items.filter(effect => effect.type == "effect" && effect.system.genre == "positive" && effect.system.statdice)
for (let statKey in this.system.statistics) {
let stat = duplicate(this.system.statistics[statKey])
let bonus = 0
for (let effect of effects) {
if (effect.system.stataffected == statKey) {
bonus += Number(effect.system.effectlevel)
}
}
if (bonus != stat.bonuseffect) {
stat.bonuseffect = bonus
this.update({ [`system.statistics.${statKey}`]: stat })
}
}
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async computeVehicleStats() { async computeVehicleStats() {
@ -2252,6 +2271,7 @@ addTopSpeedBonus(topspeed, bonus) {
ChatMessage.create({ content: `The vehicle ${this.name} has been destroyed !` }) ChatMessage.create({ content: `The vehicle ${this.name} has been destroyed !` })
} }
this.processVehicleArmorShields() this.processVehicleArmorShields()
this.processVehicleStatEffects()
} }
} }

View File

@ -14,7 +14,7 @@
</span> </span>
<select class="status-small-label color-class-common" type="text" name="system.statistics.{{key}}.level" <select class="status-small-label color-class-common" type="text" name="system.statistics.{{key}}.level"
value="{{stat.level}}" data-dtype="Number" disabled> value="{{stat.level}}" data-dtype="Number" disabled>
{{#select stat.level}} {{#select (add stat.level stat.bonuseffect)}}
{{#if (eq key "ad")}} {{#if (eq key "ad")}}
{{{@root.optionsLevel}}} {{{@root.optionsLevel}}}
{{else}} {{else}}