Combat Tracker + power enhancements
This commit is contained in:
@ -85,11 +85,13 @@ export class BoLActor extends Actor {
|
||||
if (this.type == 'character') {
|
||||
let newVitality = 10 + this.system.attributes.vigor.value + this.system.resources.hp.bonus
|
||||
if (this.system.resources.hp.max != newVitality) {
|
||||
this.update({ 'system.resources.hp.max': newVitality })
|
||||
let actor = this
|
||||
setTimeout( function() { actor.update({ 'system.resources.hp.max': newVitality }) }, 800 )
|
||||
}
|
||||
let newPower = 10 + this.system.attributes.mind.value + this.system.resources.power.bonus
|
||||
if (this.system.resources.power.max != newPower) {
|
||||
this.update({ 'system.resources.power.max': newPower })
|
||||
let actor = this
|
||||
setTimeout( function() { actor.update({ 'system.resources.power.max': newPower }) }, 800 )
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -100,8 +102,10 @@ export class BoLActor extends Actor {
|
||||
|
||||
} else {
|
||||
super.prepareDerivedData()
|
||||
this.updateResourcesData()
|
||||
this.manageHealthState();
|
||||
if (this.id) {
|
||||
this.updateResourcesData()
|
||||
this.manageHealthState()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -109,11 +113,29 @@ export class BoLActor extends Actor {
|
||||
get details() {
|
||||
return this.system.details
|
||||
}
|
||||
addEffectModifiers( myList, dataPath) {
|
||||
for (let attr of myList) {
|
||||
attr.numModifier = 0
|
||||
attr.diceModifier = ""
|
||||
let effects = this.items.filter( i => i.type === "feature" && i.system.subtype === "boleffect" && i.system.properties.identifier == dataPath+attr.key)
|
||||
for (let effect of effects) {
|
||||
if ( Number(effect.system.properties.modifier)) {
|
||||
attr.numModifier += Number(effect.system.properties.modifier)
|
||||
} else {
|
||||
attr.diceModifier += "+"+effect.system.properties.modifier
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
get attributes() {
|
||||
return Object.values(this.system.attributes)
|
||||
let attrList = duplicate(Object.values(this.system.attributes))
|
||||
this.addEffectModifiers(attrList, "system.attributes.")
|
||||
return attrList
|
||||
}
|
||||
get aptitudes() {
|
||||
return Object.values(this.system.aptitudes)
|
||||
let aptList = Object.values(this.system.aptitudes)
|
||||
this.addEffectModifiers(aptList, "system.aptitudes.")
|
||||
return aptList
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -241,19 +263,18 @@ export class BoLActor extends Actor {
|
||||
/*-------------------------------------------- */
|
||||
get armorMalusValue() { // used for Fight Options
|
||||
for (let armor of this.armors) {
|
||||
if (armor.system.properties.armorQuality.includes("light")) {
|
||||
if (armor.system.properties.armorQuality?.includes("light")) {
|
||||
return 1
|
||||
}
|
||||
if (armor.system.properties.armorQuality.includes("medium")) {
|
||||
if (armor.system.properties.armorQuality?.includes("medium")) {
|
||||
return 2
|
||||
}
|
||||
if (armor.system.properties.armorQuality.includes("heavy")) {
|
||||
if (armor.system.properties.armorQuality?.includes("heavy")) {
|
||||
return 3
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
get resources() {
|
||||
return Object.values(this.system.resources)
|
||||
}
|
||||
@ -812,6 +833,33 @@ export class BoLActor extends Actor {
|
||||
}
|
||||
return game.bol.config.creatureSize["medium"].order // Medium size per default
|
||||
}
|
||||
/*-------------------------------------------- */
|
||||
checkNumeric(myObject) {
|
||||
if ( myObject) {
|
||||
for (let key in myObject) {
|
||||
if ( myObject[key].value === null ) {
|
||||
myObject[key].value = 0
|
||||
}
|
||||
if ( myObject[key].value === NaN ) {
|
||||
myObject[key].value = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------- */
|
||||
_preUpdate(data, options, userId) {
|
||||
if (data.system?.attributes) {
|
||||
this.checkNumeric(data.system.attributes)
|
||||
}
|
||||
if (data.system?.aptitudes) {
|
||||
this.checkNumeric(data.system.aptitudes)
|
||||
}
|
||||
if (data.system?.resources) {
|
||||
this.checkNumeric(data.system.resources)
|
||||
}
|
||||
super._preUpdate(data, options, userId)
|
||||
}
|
||||
|
||||
/*-------------------------------------------- */
|
||||
getInitiativeRank(rollData = undefined, isCombat = false, combatData) {
|
||||
@ -821,11 +869,12 @@ export class BoLActor extends Actor {
|
||||
let fvttInit = 4 // Pietaille par defaut
|
||||
if (this.type == 'character') {
|
||||
fvttInit = 5
|
||||
if (!rollData) {
|
||||
fvttInit = -1
|
||||
if (!rollData) {
|
||||
if (isCombat) {
|
||||
ui.notifications.info(game.i18n.localize("BOL.ui.warninitiative"))
|
||||
BoLRoll.aptitudeCheck(this, "init", undefined, combatData)
|
||||
if (game.user.isGM ) {
|
||||
game.socket.emit("system.bol", { name: "msg_request_init_roll", data: { actorId: this.id, combatData : combatData } })
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (rollData.isLegendary) {
|
||||
|
Reference in New Issue
Block a user