Various fixes

This commit is contained in:
sladecraven 2022-05-23 18:38:51 +02:00
parent 82c902099f
commit 3e50a9135f
4 changed files with 30 additions and 14 deletions

View File

@ -212,6 +212,9 @@ export class BoLActor extends Actor {
get fightoptions() { get fightoptions() {
return this.itemData.filter(i => i.type === "feature" && i.data.subtype === "fightoption") return this.itemData.filter(i => i.type === "feature" && i.data.subtype === "fightoption")
} }
get godsfaith() {
return this.itemData.filter(i => i.type === "feature" && i.data.subtype === "godsfaith")
}
get features() { get features() {
return this.itemData.filter(i => i.type === "feature") return this.itemData.filter(i => i.type === "feature")
} }
@ -440,6 +443,11 @@ export class BoLActor extends Actor {
"label": "BOL.featureCategory.fightoptions", "label": "BOL.featureCategory.fightoptions",
"ranked": false, "ranked": false,
"items": this.fightoptions "items": this.fightoptions
},
"godsfaith": {
"label": "BOL.featureSubtypes.gods",
"ranked": false,
"items": this.godsfaith
} }
} }
} }
@ -535,7 +543,7 @@ export class BoLActor extends Actor {
/*-------------------------------------------- */ /*-------------------------------------------- */
buildListeActions() { buildListeActions() {
return this.melee.concat(this.ranged) return this.melee.concat(this.ranged).concat(this.natural)
} }
/*-------------------------------------------- */ /*-------------------------------------------- */
@ -573,8 +581,8 @@ export class BoLActor extends Actor {
/*-------------------------------------------- */ /*-------------------------------------------- */
async sufferDamage(damage) { async sufferDamage(damage) {
let newHP = this.data.data.resources.hp.value - damage; let newHP = this.data.data.resources.hp.value - damage
await this.update({ 'data.resources.hp.value': newHP }); await this.update({ 'data.resources.hp.value': newHP })
} }
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@ -314,12 +314,12 @@ export class BoLRoll {
}) })
html.find('#boon').change((event) => { html.find('#boon').change((event) => {
let boons = $('#boon').val() let boons = $('#boon').val()
this.rollData.nbBoons = (!boons || boons.length == 0) ? 0 : Math.max(...boons.map(i => parseInt(i))) this.rollData.nbBoons = (!boons || boons.length == 0) ? 0 : boons.length
this.updateTotalDice() this.updateTotalDice()
}) })
html.find('#flaw').change((event) => { html.find('#flaw').change((event) => {
let flaws = $('#flaw').val() let flaws = $('#flaw').val()
this.rollData.nbFlaws = (!flaws || flaws.length == 0) ? 0 : Math.max(...flaws.map(i => parseInt(i))) this.rollData.nbFlaws = (!flaws || flaws.length == 0) ? 0 : flaws.length
this.updateTotalDice() this.updateTotalDice()
}) })
html.find('.bdice').click((event) => { html.find('.bdice').click((event) => {
@ -335,15 +335,15 @@ export class BoLRoll {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static preProcessWeapon(rollData) { static preProcessWeapon(rollData, defender) {
if (rollData.mode == "weapon") { if (rollData.mode == "weapon") {
rollData.weaponModifier = rollData.weapon.data.data.properties.attackModifiers ?? 0; rollData.weaponModifier = rollData.weapon.data.data.properties.attackModifiers ?? 0;
rollData.attackBonusDice = rollData.weapon.data.data.properties.attackBonusDice rollData.attackBonusDice = rollData.weapon.data.data.properties.attackBonusDice
if (rollData.defender) { // If target is selected if (defender) { // If target is selected
rollData.defence = rollData.defender.defenseValue rollData.defence = defender.defenseValue
rollData.armorMalus = rollData.defender.armorMalusValue rollData.armorMalus = defender.armorMalusValue
rollData.shieldBlock = 'none' rollData.shieldBlock = 'none'
let shields = rollData.defender.shields let shields = defender.shields
for (let shield of shields) { for (let shield of shields) {
rollData.shieldBlock = (shield.data.properties.blocking.blockingAll) ? 'blockall' : 'blockone'; rollData.shieldBlock = (shield.data.properties.blocking.blockingAll) ? 'blockall' : 'blockone';
rollData.shieldAttackMalus = (shield.data.properties.blocking.malus) ? shield.data.properties.blocking.malus : 1; rollData.shieldAttackMalus = (shield.data.properties.blocking.malus) ? shield.data.properties.blocking.malus : 1;
@ -361,6 +361,12 @@ export class BoLRoll {
const rollOptionTpl = `systems/bol/templates/dialogs/${rollData.mode}-roll-dialog.hbs` const rollOptionTpl = `systems/bol/templates/dialogs/${rollData.mode}-roll-dialog.hbs`
let actor = game.actors.get( rollData.actorId ) let actor = game.actors.get( rollData.actorId )
let defender
if ( rollData.targetId) {
let token = game.scenes.current.tokens.get(rollData.targetId)
defender = token.actor
}
rollData.careers = actor.careers rollData.careers = actor.careers
rollData.boons = actor.bonusBoons rollData.boons = actor.bonusBoons
rollData.flaws = actor.malusFlaws rollData.flaws = actor.malusFlaws
@ -386,7 +392,7 @@ export class BoLRoll {
rollData.attackBonusDice = false rollData.attackBonusDice = false
rollData.armorMalus = 0 rollData.armorMalus = 0
// Specific stuff // Specific stuff
this.preProcessWeapon(rollData) this.preProcessWeapon(rollData, defender)
this.preProcessFightOption(rollData) this.preProcessFightOption(rollData)
this.updateArmorMalus(rollData) this.updateArmorMalus(rollData)
this.updatePPCost(rollData) this.updatePPCost(rollData)

View File

@ -256,8 +256,9 @@ export class BoLUtility {
return return
} // ?? Why ??? } // ?? Why ???
attackDef.defenseDone = true attackDef.defenseDone = true
attackDef.defenseMode = defenseMode; attackDef.defenseMode = defenseMode
let defender = game.actors.get(attackDef.defenderId) let token = game.scenes.current.tokens.get(attackDef.targetId)
let defender = token.actor
if (defenseMode == 'damage-with-armor') { if (defenseMode == 'damage-with-armor') {
let armorFormula = defender.getArmorFormula() let armorFormula = defender.getArmorFormula()
@ -300,6 +301,7 @@ export class BoLUtility {
rollHero: attackDef.rollHero, rollHero: attackDef.rollHero,
weaponHero: attackDef.weaponHero, weaponHero: attackDef.weaponHero,
armorProtect: attackDef.armorProtect, armorProtect: attackDef.armorProtect,
name: defender.name,
defender: defender, defender: defender,
defenseMode: attackDef.defenseMode, defenseMode: attackDef.defenseMode,
finalDamage: attackDef.finalDamage finalDamage: attackDef.finalDamage

View File

@ -14,7 +14,7 @@
"url": "https://github.com/ZigmundKreud/bol", "url": "https://github.com/ZigmundKreud/bol",
"license": "LICENSE.txt", "license": "LICENSE.txt",
"flags": {}, "flags": {},
"version": "1.3.19", "version": "1.3.20",
"templateVersion": 10, "templateVersion": 10,
"minimumCoreVersion": "0.8.6", "minimumCoreVersion": "0.8.6",
"compatibleCoreVersion": "9", "compatibleCoreVersion": "9",