From 45e239b8e94954101ddb6ea5c75b9baaf390f904 Mon Sep 17 00:00:00 2001 From: sladecraven Date: Sun, 10 Apr 2022 16:38:09 +0200 Subject: [PATCH] Ajout creatures --- module/actor/actor-sheet.js | 2 ++ module/actor/actor.js | 29 +++++++++++++++++++++++++++++ module/controllers/bol-rolls.js | 13 ++++++++++--- module/system/templates.js | 4 ++-- 4 files changed, 43 insertions(+), 5 deletions(-) diff --git a/module/actor/actor-sheet.js b/module/actor/actor-sheet.js index 3b91093..0b03b11 100644 --- a/module/actor/actor-sheet.js +++ b/module/actor/actor-sheet.js @@ -120,6 +120,7 @@ export class BoLActorSheet extends ActorSheet { formData.aptitudes = this.actor.aptitudes formData.resources = this.actor.getResourcesFromType() formData.equipment = this.actor.equipment + formData.equipmentCreature = this.actor.equipmentCreature formData.weapons = this.actor.weapons formData.protections = this.actor.protections formData.spells = this.actor.spells @@ -132,6 +133,7 @@ export class BoLActorSheet extends ActorSheet { formData.ammos = this.actor.ammos formData.misc = this.actor.misc formData.combat = this.actor.buildCombat() + formData.combatCreature = this.actor.buildCombatCreature() formData.features = this.actor.buildFeatures() formData.isGM = game.user.isGM formData.options = this.options diff --git a/module/actor/actor.js b/module/actor/actor.js index 7b369be..1e5c549 100644 --- a/module/actor/actor.js +++ b/module/actor/actor.js @@ -218,6 +218,9 @@ export class BoLActor extends Actor { get equipment() { return this.itemData.filter(i => i.type === "item") } + get equipmentCreature() { + return this.itemData.filter(i => i.type === "item" && i.data.category === "equipment" && (( i.data.subtype === "weapon" && i.data.properties.natural === true) || (i.data.subtype === "armor")) ) + } get armors() { return this.itemData.filter(i => i.type === "item" && i.data.category === "equipment" && i.data.subtype === "armor"); } @@ -243,6 +246,9 @@ export class BoLActor extends Actor { get melee() { return this.weapons.filter(i => i.data.properties.melee === true); } + get natural() { + return this.weapons.filter(i => i.data.properties.natural === true); + } get ranged() { return this.weapons.filter(i => i.data.properties.ranged === true); } @@ -488,6 +494,29 @@ export class BoLActor extends Actor { } } + buildCombatCreature() { + return { + "natural": { + "label": "BOL.combatCategory.natural", + "weapon": true, + "protection": false, + "blocking": false, + "ranged": false, + "options": false, + "items": this.natural + }, + "protections": { + "label": "BOL.combatCategory.protections", + "weapon": false, + "protection": true, + "blocking": false, + "ranged": false, + "options": false, + "items": this.protections + }, + } + } + /*-------------------------------------------- */ buildRollList() { let rolls = [] diff --git a/module/controllers/bol-rolls.js b/module/controllers/bol-rolls.js index 9827183..15a41ed 100644 --- a/module/controllers/bol-rolls.js +++ b/module/controllers/bol-rolls.js @@ -201,8 +201,11 @@ export class BoLRoll { let letter = (this.rollData.bmDice > 0) ? "B" : "M" $('#roll-nbdice').val("2 + " + String(Math.abs(this.rollData.bmDice)) + letter) } - - $('#roll-modifier').val(this.rollData.attrValue + "+" + this.rollData.aptValue + "+" + this.rollData.careerBonus + "+" + this.rollData.mod + "+" + + let rollbase = this.rollData.attrValue + "+" + this.rollData.aptValue + if ( this.rollData.weapon && this.rollData.weapon.data.data.properties.onlymodifier ) { + rollbase = "" + } + $('#roll-modifier').val(rollbase + "+" + this.rollData.careerBonus + "+" + this.rollData.mod + "+" + this.rollData.modRanged + "+" + this.rollData.weaponModifier + "-" + this.rollData.defence + "-" + this.rollData.modArmorMalus + "-" + this.rollData.shieldMalus + "+" + this.rollData.attackModifier + "+" + this.rollData.appliedArmorMalus) } @@ -414,7 +417,11 @@ export class BoLRoll { const isMalus = rollData.mDice > 0 rollData.nbDice += (rollData.attackBonusDice) ? 1 : 0 - const modifiers = rollData.attrValue + rollData.aptValue + rollData.careerBonus + rollData.mod + rollData.weaponModifier - rollData.defence - rollData.modArmorMalus + rollData.shieldMalus + rollData.attackModifier + rollData.appliedArmorMalus + let rollbase = rollData.attrValue + rollData.aptValue + if ( rollData.weapon && rollData.weapon.data.data.properties.onlymodifier ) { + rollbase = 0 + } + const modifiers = rollbase + rollData.careerBonus + rollData.mod + rollData.weaponModifier - rollData.defence - rollData.modArmorMalus + rollData.shieldMalus + rollData.attackModifier + rollData.appliedArmorMalus const formula = (isMalus) ? rollData.nbDice + "d6kl2 + " + modifiers : rollData.nbDice + "d6kh2 + " + modifiers rollData.formula = formula rollData.modifiers = modifiers diff --git a/module/system/templates.js b/module/system/templates.js index f3619a7..7de8fe0 100644 --- a/module/system/templates.js +++ b/module/system/templates.js @@ -16,6 +16,8 @@ export const preloadHandlebarsTemplates = async function () { "systems/bol/templates/actor/parts/tabs/actor-equipment.hbs", "systems/bol/templates/actor/parts/tabs/actor-spellalchemy.hbs", "systems/bol/templates/actor/parts/tabs/actor-biodata.hbs", + "systems/bol/templates/actor/parts/tabs/creature-stats.hbs", + "systems/bol/templates/actor/parts/tabs/creature-actions.hbs", // ITEMS "systems/bol/templates/item/parts/item-header.hbs", "systems/bol/templates/item/parts/properties/feature-properties.hbs", @@ -39,8 +41,6 @@ export const preloadHandlebarsTemplates = async function () { "systems/bol/templates/chat/rolls/attack-damage-card.hbs", "systems/bol/templates/chat/rolls/spell-roll-card.hbs", "systems/bol/templates/chat/rolls/alchemy-roll-card.hbs", - "systems/bol/templates/roll/parts/roll-dialog-modifiers.hbs", - "systems/bol/templates/roll/parts/roll-dialog-attribute.hbs", "systems/bol/templates/dialogs/aptitude-roll-part.hbs", "systems/bol/templates/dialogs/attribute-roll-part.hbs", "systems/bol/templates/dialogs/mod-roll-part.hbs",