Fix #90 MR management with vehicles

This commit is contained in:
sladecraven 2022-10-05 09:58:07 +02:00
parent 5a062cc94e
commit c2831e4ccd
3 changed files with 27 additions and 8 deletions

View File

@ -1868,6 +1868,28 @@ export class PegasusActor extends Actor {
}
}
if ( statKey == "mr" ) {
if ( this.type == "character") {
rollData.mrVehicle = PegasusUtility.checkIsVehicleCrew(this.id)
if (rollData.mrVehicle) {
rollData.effectsList.push({
label: `Vehicle ${rollData.mrVehicle.name} MR Bonus`,
type: "effect", applied: false, isdynamic: true, value: rollData.mrVehicle.system.statistics.mr.currentlevel
})
}
}
if ( this.type == "vehicle") {
for(let member of this.system.crew) {
let actor = game.actors.get( member.id )
let specList = actor.getRelevantSpec("mr")
rollData.effectsList.push({
label: `Crew ${actor.name} MR Bonus`,
type: "effect", applied: false, isdynamic: true, value: actor.system.mr.value + actor.system.mr.bonuseffect, specList: specList
})
}
}
}
this.processSizeBonus(rollData)
this.addEffects(rollData, isInit, isPower, subKey == "power-dmg")
this.addArmorsShields(rollData, statKey, useShield, subKey)
@ -2025,13 +2047,6 @@ export class PegasusActor extends Actor {
console.log("MR ROLL", rollData)
if (isInit) {
rollData.title = "MR / Initiative"
rollData.mrVehicle = PegasusUtility.checkIsVehicleCrew(this.id)
if (rollData.mrVehicle) {
rollData.effectsList.push({
label: `Vehicle ${rollData.mrVehicle.name} MR Bonus`,
type: "effect", applied: false, isdynamic: true, value: rollData.mrVehicle.system.mr.currentlevel
})
}
}
this.startRoll(rollData);
} else {

View File

@ -90,6 +90,9 @@ export class PegasusRollDialog extends Dialog {
PegasusUtility.updateDamageDicePool(this.rollData)
PegasusUtility.updateEffectsBonusDice(this.rollData)
PegasusUtility.updateHindranceBonusDice(this.rollData)
if ( effect.specList) {
this.rollData.specList = duplicate(effect.specList)
}
}
/* -------------------------------------------- */

View File

@ -1074,8 +1074,9 @@ export class PegasusUtility {
/* -------------------------------------------- */
static checkIsVehicleCrew(actorId) {
let vehicles = game.actors.filter( actor=> actor.type =="vehicle") || []
let vehicles = game.actors.filter( actor=> actor.type == "vehicle") || []
for(let vehicle of vehicles) {
console.log("Checking", vehicle.name)
if ( vehicle.inCrew(actorId) ) {
return vehicle
}