forked from public/bol
Display effects in main sheet (left) and manage it for defense and damages
This commit is contained in:
@ -28,6 +28,7 @@ export class BoLActor extends Actor {
|
||||
}
|
||||
return this.system.chartype
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getVillainy() {
|
||||
if (this.type === 'character') {
|
||||
@ -52,7 +53,7 @@ export class BoLActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
prepareDerivedData() {
|
||||
if ( this.type == "vehicle") {
|
||||
if (this.type == "vehicle") {
|
||||
|
||||
} else {
|
||||
super.prepareDerivedData()
|
||||
@ -102,6 +103,13 @@ export class BoLActor extends Actor {
|
||||
if (fo && fo.system.properties.fightoptiontype == "attack") {
|
||||
defMod += -1
|
||||
}
|
||||
// Apply defense effects
|
||||
for (let i of this.items) {
|
||||
if (i.type === "feature" && i.system.subtype === "boleffect" && i.system.properties.identifier.includes("aptitudes.def") ) {
|
||||
defMod += Number(i.system.properties.modifier)
|
||||
}
|
||||
}
|
||||
console.log("Defense : ", defMod)
|
||||
return this.system.aptitudes.def.value + defMod
|
||||
}
|
||||
|
||||
@ -216,7 +224,7 @@ export class BoLActor extends Actor {
|
||||
return duplicate(this.items.filter(i => i.type === "feature" && i.system.subtype === "flaw") || []);
|
||||
}
|
||||
get careers() {
|
||||
return duplicate( this.items.filter(i => i.type === "feature" && i.system.subtype === "career") || [])
|
||||
return duplicate(this.items.filter(i => i.type === "feature" && i.system.subtype === "career") || [])
|
||||
}
|
||||
get origins() {
|
||||
return this.items.filter(i => i.type === "feature" && i.system.subtype === "origin");
|
||||
@ -240,7 +248,7 @@ export class BoLActor extends Actor {
|
||||
return this.items.filter(i => i.type === "item")
|
||||
}
|
||||
get equipmentCreature() {
|
||||
return this.items.filter(i => i.type === "item" && i.system.category === "equipment" && (( i.system.subtype === "weapon" && i.system.properties.natural === true) || (i.system.subtype === "armor")) )
|
||||
return this.items.filter(i => i.type === "item" && i.system.category === "equipment" && ((i.system.subtype === "weapon" && i.system.properties.natural === true) || (i.system.subtype === "armor")))
|
||||
}
|
||||
get armors() {
|
||||
return this.items.filter(i => i.type === "item" && i.system.category === "equipment" && i.system.subtype === "armor");
|
||||
@ -252,7 +260,7 @@ export class BoLActor extends Actor {
|
||||
return this.items.filter(i => i.type === "item" && i.system.category === "equipment" && i.system.subtype === "shield");
|
||||
}
|
||||
get vehicleWeapons() {
|
||||
return this.items.filter(i => i.type === "item" && i.system.category === "vehicleweapon" )
|
||||
return this.items.filter(i => i.type === "item" && i.system.category === "vehicleweapon")
|
||||
}
|
||||
get weapons() {
|
||||
return this.items.filter(i => i.type === "item" && i.system.category === "equipment" && i.system.subtype === "weapon")
|
||||
@ -298,10 +306,10 @@ export class BoLActor extends Actor {
|
||||
|
||||
get bonusBoons() {
|
||||
let boons = this.items.filter(i => i.type === "feature" && i.system.subtype === "boon" && i.system.properties.isbonusdice)
|
||||
return duplicate( boons || [])
|
||||
return duplicate(boons || [])
|
||||
}
|
||||
get malusFlaws() {
|
||||
return duplicate( this.items.filter(i => i.type === "feature" && i.system.subtype === "flaw" && i.system.properties.ismalusdice) || []);
|
||||
return duplicate(this.items.filter(i => i.type === "feature" && i.system.subtype === "flaw" && i.system.properties.ismalusdice) || []);
|
||||
}
|
||||
|
||||
isSorcerer() {
|
||||
@ -332,6 +340,23 @@ export class BoLActor extends Actor {
|
||||
return ppCostArmor
|
||||
}
|
||||
/*-------------------------------------------- */
|
||||
getDamageAttributeValue(attrDamage) {
|
||||
let attrDamageValue = 0
|
||||
if (attrDamage.includes("vigor")) {
|
||||
attrDamageValue = actor.system.attributes.vigor.value
|
||||
if (attrDamage.includes("half")) {
|
||||
attrDamageValue = Math.floor(attrDamageValue / 2)
|
||||
}
|
||||
// Apply vigor effects
|
||||
for (let i of this.items) {
|
||||
if (i.type === "feature" && i.system.subtype === "boleffect" && i.system.properties.identifier.includes("vigor") ) {
|
||||
attrDamageValue += Number(i.system.properties.modifier)
|
||||
}
|
||||
}
|
||||
}
|
||||
return attrDamageValue
|
||||
}
|
||||
/*-------------------------------------------- */
|
||||
getArmorAgiMalus() {
|
||||
let malusAgi = 0
|
||||
for (let armor of this.protections) {
|
||||
@ -568,7 +593,7 @@ export class BoLActor extends Actor {
|
||||
async manageHealthState() {
|
||||
let hpID = "lastHP" + this.id
|
||||
let lastHP = await this.getFlag("world", hpID)
|
||||
if (lastHP != this.system.resources.hp.value && game.user.isGM ) { // Only GM sends this
|
||||
if (lastHP != this.system.resources.hp.value && game.user.isGM) { // Only GM sends this
|
||||
await this.setFlag("world", hpID, this.system.resources.hp.value)
|
||||
if (this.system.resources.hp.value <= 0) {
|
||||
ChatMessage.create({
|
||||
@ -600,7 +625,7 @@ export class BoLActor extends Actor {
|
||||
/*-------------------------------------------- */
|
||||
async sufferDamage(damage) {
|
||||
let newHP = this.system.resources.hp.value - damage
|
||||
await this.update({ 'system.resources.hp.value': newHP })
|
||||
await this.update({ 'system.resources.hp.value': newHP })
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -615,7 +640,7 @@ export class BoLActor extends Actor {
|
||||
if (!protect.system.properties.soak.formula || protect.system.properties.soak.formula == "") {
|
||||
ui.notifications.warn(`L'armure ${protect.name} n'a pas de formule pour la protection !`)
|
||||
} else {
|
||||
formula += "+" + " max(" + protect.system.properties.soak.formula +",0)"
|
||||
formula += "+" + " max(" + protect.system.properties.soak.formula + ",0)"
|
||||
}
|
||||
} else {
|
||||
if (protect.system.properties.soak.value == undefined) {
|
||||
@ -634,7 +659,7 @@ export class BoLActor extends Actor {
|
||||
rollProtection(itemId) {
|
||||
let armor = duplicate(this.items.get(itemId))
|
||||
if (armor) {
|
||||
let armorFormula = "max("+armor.system.properties.soak.formula + ", 0)"
|
||||
let armorFormula = "max(" + armor.system.properties.soak.formula + ", 0)"
|
||||
let rollArmor = new Roll(armorFormula)
|
||||
rollArmor.roll({ async: false }).toMessage()
|
||||
}
|
||||
|
Reference in New Issue
Block a user