Display effects in main sheet (left) and manage it for defense and damages

This commit is contained in:
sladecraven 2022-11-25 08:49:37 +01:00
parent add6893864
commit 5e7dc3ad9d
6 changed files with 59 additions and 24 deletions

View File

@ -171,6 +171,7 @@
"BOL.ui.effectbonusmalus": "Bonus ou Malus à appliquer",
"BOL.ui.boleffects": "Effets (automatiques)",
"BOL.ui.modifier": "Modificateur",
"BOL.ui.effects": "Effets en cours",
"BOL.featureCategory.origins": "Origines",
"BOL.featureCategory.races": "Races",

View File

@ -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({
@ -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()
}

View File

@ -645,16 +645,8 @@ export class BoLDefaultRoll {
/* -------------------------------------------- */
getDamageAttributeValue(attrDamage, actorId = undefined) {
let attrDamageValue = 0
let actor = game.actors.get( (actorId) ? actorId: this.rollData.actorId)
if (attrDamage.includes("vigor")) {
attrDamageValue = actor.system.attributes.vigor.value
if (attrDamage.includes("half")) {
attrDamageValue = Math.floor(attrDamageValue / 2)
}
}
return attrDamageValue
return actor.getDamageAttributeValue( attrDamage )
}
/* -------------------------------------------- */

View File

@ -14,7 +14,7 @@
],
"url": "https://www.uberwald.me/gitea/public/bol",
"license": "LICENSE.txt",
"version": "10.4.0",
"version": "10.4.1",
"compatibility": {
"minimum": "10",
"verified": "10",
@ -203,7 +203,7 @@
],
"socket": true,
"manifest": "https://www.uberwald.me/gitea/public/bol/raw/v10/system.json",
"download": "https://www.uberwald.me/gitea/public/bol/archive/bol-v10.4.0.zip",
"download": "https://www.uberwald.me/gitea/public/bol/archive/bol-v10.4.1.zip",
"background": "systems/images/map_lemurie.webp",
"gridDistance": 1.5,
"gridUnits": "m",

View File

@ -102,10 +102,10 @@
"hp": {
"key": "hp",
"label": "BOL.resources.hp",
"base": 0,
"value": 0,
"base": 1,
"value": 1,
"bonus": 0,
"max": 0
"max": 1
},
"hero": {
"key": "hero",

View File

@ -7,6 +7,23 @@
<div class="sidebar flex0 bol-actor-sidebar">
<img class="profile-img" src="{{actor.img}}" data-edit="img" title="{{actor.name}}" height="100" width="100"
style="border:1px outset lightgray; box-shadow: 5px 5px 5px gray" />
<div></div>
{{#if (count boleffects)}}
<ol class="items-list">
<li class="item flexrow item-header">
<div class="item-name flex2">{{localize "BOL.ui.effects"}}</div>
</li>
{{#each boleffects as |effect keyEffect|}}
<li class="item flexrow" data-item-id="{{effect.id}}">
<div class="item-image roll-weapon"><img src="{{effect.img}}" title="{{effect.name}}"/></div>
<h4 class="item-name flex2"><a class="item-edit">{{effect.name}}</a></h4>
</li>
{{/each}}
</ol>
{{/if}}
</div>
<div class="main flex1">