From 0368be050b6a03f67fa6b69c899e2c1a648e2e9d Mon Sep 17 00:00:00 2001 From: LeRatierBretonnien Date: Fri, 24 Mar 2023 10:17:20 +0100 Subject: [PATCH] Update combat tab --- modules/hero6-actor-sheet.js | 8 +-- modules/hero6-actor.js | 41 +++++++++---- modules/hero6-utility.js | 57 +++++++++++++++-- styles/simple.css | 4 ++ system.json | 4 +- template.json | 21 +++---- templates/actors/actor-sheet.hbs | 75 +++++++++++++---------- templates/chat/chat-generic-result.hbs | 21 ++++++- templates/items/item-equipment-sheet.hbs | 2 +- templates/items/item-maneuver-sheet.hbs | 4 ++ templates/items/item-martialart-sheet.hbs | 23 ------- 11 files changed, 163 insertions(+), 97 deletions(-) delete mode 100644 templates/items/item-martialart-sheet.hbs diff --git a/modules/hero6-actor-sheet.js b/modules/hero6-actor-sheet.js index 80eaf65..f9ea2d2 100644 --- a/modules/hero6-actor-sheet.js +++ b/modules/hero6-actor-sheet.js @@ -44,8 +44,8 @@ export class Hero6ActorSheet extends ActorSheet { powers: await this.actor.getPowers( ), talents: this.actor.getTalents( ), complications: this.actor.getComplications( ), - martialarts: this.actor.getMartialArts( ), maneuvers: this.actor.getManeuvers( ), + nonstockmaneuvers: this.actor.getNonStockManeuvers(), weapons: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getWeapons()) ), armors: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getArmors())), shields: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getShields())), @@ -153,9 +153,9 @@ export class Hero6ActorSheet extends ActorSheet { this.actor.rollCharac(characKey); }); html.find('.roll-direct').click((event) => { - const rollFormula = $(event.currentTarget).data("roll-formula"); - let roll = new Roll(rollFormula).roll({async: false}) - roll.toMessage() + const rollFormula = $(event.currentTarget).data("roll-formula") + const rollSource = $(event.currentTarget).data("roll-source") + Hero6Utility.processDirectRoll( { actorId: this.actor.id, rollFormula: rollFormula, rollSource: rollSource, mode:"directroll"} ) }); html.find('.roll-item').click((event) => { diff --git a/modules/hero6-actor.js b/modules/hero6-actor.js index 49edd6f..055c61e 100644 --- a/modules/hero6-actor.js +++ b/modules/hero6-actor.js @@ -67,8 +67,8 @@ export class Hero6Actor extends Actor { } } computeDicesValue() { - this.system.biodata.presenceattack = Hero6Utility.getDerivatedDiceValue(this.system.characteristics.pre.value ) - this.system.characteristics.str.strdice = Hero6Utility.getDerivatedDiceValue(this.system.characteristics.str.value ) + this.system.biodata.presenceattack = Hero6Utility.getDerivatedDiceFormulas(this.system.characteristics.pre.value ) + this.system.characteristics.str.strdice = Hero6Utility.getDerivatedDiceFormulas(this.system.characteristics.str.value ) } /* -------------------------------------------- */ prepareDerivedData() { @@ -235,11 +235,6 @@ export class Hero6Actor extends Actor { Hero6Utility.sortArrayObjectsByName(comp) return comp } - getMartialArts() { - let comp = duplicate(this.items.filter(item => item.type == 'martialart') || []) - Hero6Utility.sortArrayObjectsByName(comp) - return comp - } getComplications() { let comp = duplicate(this.items.filter(item => item.type == 'complication') || []) Hero6Utility.sortArrayObjectsByName(comp) @@ -285,25 +280,45 @@ export class Hero6Actor extends Actor { offensive: this.items.filter(item => item.type == "maneuver" && item.system.maneuvertype == "offensive"), defensive: this.items.filter(item => item.type == "maneuver" && item.system.maneuvertype == "defensive") } + Hero6Utility.sortArrayObjectsByName(maneuvers.general) + Hero6Utility.sortArrayObjectsByName(maneuvers.offensive) + Hero6Utility.sortArrayObjectsByName(maneuvers.defensive) + return maneuvers + } + getNonStockManeuvers() { + let maneuvers = this.items.filter(item => item.type == "maneuver" && !item.system.isstock) + Hero6Utility.sortArrayObjectsByName(maneuvers) return maneuvers } getEquipments() { - return this.items.filter(item => item.type == "equipment" && item.system.subtype == "equipment"); + let list = this.items.filter(item => item.type == "equipment" && item.system.subtype == "equipment"); + Hero6Utility.sortArrayObjectsByName(list) + return list } getWeapons() { - return this.items.filter(item => item.type == "equipment" && item.system.subtype == "weapon"); + let list = this.items.filter(item => item.type == "equipment" && item.system.subtype == "weapon"); + Hero6Utility.sortArrayObjectsByName(list) + return list } getArmors() { - return this.items.filter(item => item.type == "equipment" && item.system.subtype == "armor"); + let list = this.items.filter(item => item.type == "equipment" && item.system.subtype == "armor"); + Hero6Utility.sortArrayObjectsByName(list) + return list } getShields() { - return this.items.filter(item => item.type == "equipment" && item.system.subtype == "shield"); + let list = this.items.filter(item => item.type == "equipment" && item.system.subtype == "shield"); + Hero6Utility.sortArrayObjectsByName(list) + return list } getEquipmentsMoneys() { - return duplicate(this.items.filter(item => item.type == "equipment" && (item.system.subtype == "equipment" || item.system.subtype == "money")) || []) + let list = duplicate(this.items.filter(item => item.type == "equipment" && (item.system.subtype == "equipment" || item.system.subtype == "money")) || []) + Hero6Utility.sortArrayObjectsByName(list) + return list } getEquipmentsOnly() { - return duplicate(this.items.filter(item => item.type == "equipment" && item.system.subtype == "equipment") || []) + let list = duplicate(this.items.filter(item => item.type == "equipment" && item.system.subtype == "equipment") || []) + Hero6Utility.sortArrayObjectsByName(list) + return list } /* ------------------------------------------- */ diff --git a/modules/hero6-utility.js b/modules/hero6-utility.js index dfd1c7d..bf2b67b 100644 --- a/modules/hero6-utility.js +++ b/modules/hero6-utility.js @@ -20,6 +20,9 @@ export class Hero6Utility { Handlebars.registerHelper('count', function (list) { return list.length; }) + Handlebars.registerHelper('exists', function (val) { + return val != null && val != undefined; + }); Handlebars.registerHelper('includes', function (array, val) { return array.includes(val); }) @@ -78,12 +81,16 @@ export class Hero6Utility { /*-------------------------------------------- */ - static getDerivatedDiceValue(value) { - let dices = Math.floor(value/5) +"d6" + static getDerivatedDiceFormulas(value) { + let rollFormula = Math.floor(value/5) +"d6" + let displayFormula = Math.floor(value/5) if ( value % 5 > 2) { - dices += "+1d3" + rollFormula += "+round(1d6/2)" + displayFormula += " 1/2d6" + } else { + displayFormula += "d6" } - return dices + return {rollFormula:rollFormula, displayFormula: displayFormula} } /*-------------------------------------------- */ static upperFirst(text) { @@ -340,15 +347,53 @@ export class Hero6Utility { } rollData.margin = target - rollData.result + this.outputRollMessage(rollData) + } + + /* -------------- ----------------------------- */ + static processDirectRoll(rollData ) { + let roll = new Roll(rollData.rollFormula).roll({async: false}) + rollData.roll = roll + + // Compute BODY + let bodyValue = 0 + for (let term of roll.terms) { + if ( term.constructor.name == "Die") { + for (let value of term.values) { + if (value > 1) { + bodyValue +=1 + } + if (value == 6) { + bodyValue +=1 + } + } + } + if ( term.constructor.name == "NumericTerm") { + if (term.total > 1) { + bodyValue +=1 + } + if (term.total == 6) { + bodyValue +=1 + } + } + } + + rollData.result = roll.total + rollData.bodyValue = bodyValue + + this.outputRollMessage(rollData) + } + + /* -------------- ----------------------------- */ + static async outputRollMessage(rollData) { let msg = await this.createChatWithRollMode(rollData.alias, { content: await renderTemplate(`systems/fvtt-hero-system-6/templates/chat/chat-generic-result.hbs`, rollData) }) msg.setFlag("world", "rolldata", rollData) console.log("Rolldata result", rollData) - } - /* -------------------------------------------- */ + /* -------------- ----------------------------- */ static sortArrayObjectsByName(myArray) { myArray.sort((a, b) => { let fa = a.name.toLowerCase(); diff --git a/styles/simple.css b/styles/simple.css index 762a766..bf0549c 100644 --- a/styles/simple.css +++ b/styles/simple.css @@ -1451,4 +1451,8 @@ Focus FOC: #ff0084 .biodata-portrait { min-height: 512px; min-width: 256px; +} +.textarea-full-height { + min-height: 100%; + height: 100%; } \ No newline at end of file diff --git a/system.json b/system.json index 86d846a..ddde425 100644 --- a/system.json +++ b/system.json @@ -91,7 +91,7 @@ "styles": [ "styles/simple.css" ], - "version": "10.0.29", + "version": "10.0.32", "compatibility": { "minimum": "10", "verified": "10", @@ -99,7 +99,7 @@ }, "title": "Hero System v6 for FoundrtVTT (Official)", "manifest": "https://www.uberwald.me/gitea/uberwald/fvtt-hero-system-6/raw/branch/main/system.json", - "download": "https://www.uberwald.me/gitea/uberwald/fvtt-hero-system-6/archive/fvtt-hero-system-6-v10.0.29.zip", + "download": "https://www.uberwald.me/gitea/uberwald/fvtt-hero-system-6/archive/fvtt-hero-system-6-v10.0.32.zip", "url": "https://www.uberwald.me/gitea/uberwald/", "background": "images/ui/hro6_welcome_page.webp", "id": "fvtt-hero-system-6" diff --git a/template.json b/template.json index 5cfd1f1..6703762 100644 --- a/template.json +++ b/template.json @@ -31,8 +31,9 @@ "xpearned": 0, "xpspent": 0, "combatskills": "", - "presenceattack": "", - "gmnotes": "" + "presenceattack": {}, + "gmnotes": "", + "combatnotes1":"" } }, "characteristics": { @@ -42,7 +43,7 @@ "value": 10, "base": 10, "category": "main", - "strdice": "", + "strdice": {}, "lift": "", "strend": 0, "hasroll": true, @@ -68,7 +69,8 @@ "hasroll": true, "category": "main", "value": 10, - "base": 10 + "base": 10, + "perceptionroll": 10 }, "ego": { "label": "Ego", @@ -314,7 +316,6 @@ "power", "advantage", "maneuver", - "martialart", "limitation", "complication", "equipment" @@ -355,6 +356,7 @@ "pha": "", "ocv": 0, "dcv" : 0, + "isstock": false, "active": false }, "advantage": { @@ -458,15 +460,6 @@ "templates": [ "common" ] - }, - "martialart": { - "maneuver_phase": 0, - "maneuver_ocv": 0, - "maneuver_dcv": 0, - "maneuver_effect": "", - "templates": [ - "common" - ] } } } \ No newline at end of file diff --git a/templates/actors/actor-sheet.hbs b/templates/actors/actor-sheet.hbs index 0d618a2..f1c01fa 100644 --- a/templates/actors/actor-sheet.hbs +++ b/templates/actors/actor-sheet.hbs @@ -98,7 +98,7 @@ Skills Perks Talents - Martial Arts + Maneuvers Powers Complications Equipment @@ -117,7 +117,7 @@ @@ -187,10 +187,10 @@ - + - + {{#each characteristics as |char key|}} @@ -214,10 +214,10 @@ - + - + {{#each characteristics as |char key|}} @@ -277,16 +277,14 @@ - - {{#each senses as |sense key|}}
  • - {{sense.label}} - {{sense.value}} + Perception Roll +
  • - {{/each}} +
    @@ -296,10 +294,10 @@ - + - + {{#each characteristics as |char key|}} @@ -457,33 +455,44 @@
    - {{!-- Martial Tab --}} -
    + {{!-- Maneuvers Tab --}} +
    • - + - + + + + + + + + + +
    • - {{#each martialarts as |martial key|}} -
    • - - {{martial.name}} - {{#if martial.system.hasroll}} - {{martial.system.roll}}- - {{else}} -   - {{/if}} -
       
      -
      - -
      -
    • + {{#each nonstockmaneuvers as |maneuver key|}} +
    • + + {{maneuver.name}} + + {{maneuver.system.pha}} + {{maneuver.system.ocv}} + {{maneuver.system.dcv}} + + {{maneuver.system.effects}} + +
       
      +
      + +
      +
    • {{/each}}
    diff --git a/templates/chat/chat-generic-result.hbs b/templates/chat/chat-generic-result.hbs index b1fcd4f..5b01605 100644 --- a/templates/chat/chat-generic-result.hbs +++ b/templates/chat/chat-generic-result.hbs @@ -18,8 +18,14 @@
      + {{#if target}}
    • Target Roll : {{target}}-
    • + {{/if}} + + {{#if rollSource}} +
    • Roll : {{rollSource}}
    • + {{/if}} {{#if charac}}
    • CHAR : {{charac.label}}
    • @@ -29,11 +35,24 @@
    • {{item.name}} ({{upperFirst item.type}})
    • {{/if}} + {{#if (exists bonusMalus)}}
    • Bonus/Penalty : {{bonusMalus}}
    • + {{/if}} -
    • Result : {{result}} ({{#if isSuccess}}Success!!{{else}}Failure!{{/if}})
    • +
    • Result : {{result}} + {{#if (exists margin)}} + ({{#if isSuccess}}Success!!{{else}}Failure!{{/if}}) + {{/if}} +
    • + + {{#if (exists bodyValue)}} +
    • BODY : {{bodyValue}} + {{/if}} + + {{#if (exists margin)}}
    • Margin : {{margin}} + {{/if}}
    diff --git a/templates/items/item-equipment-sheet.hbs b/templates/items/item-equipment-sheet.hbs index 9d0dd62..4d087fd 100644 --- a/templates/items/item-equipment-sheet.hbs +++ b/templates/items/item-equipment-sheet.hbs @@ -29,7 +29,7 @@
  • - +
  • diff --git a/templates/items/item-maneuver-sheet.hbs b/templates/items/item-maneuver-sheet.hbs index dec22de..f1e65e5 100644 --- a/templates/items/item-maneuver-sheet.hbs +++ b/templates/items/item-maneuver-sheet.hbs @@ -27,6 +27,10 @@
  • +
  • + +
  • +
  • diff --git a/templates/items/item-martialart-sheet.hbs b/templates/items/item-martialart-sheet.hbs deleted file mode 100644 index 42a6cc6..0000000 --- a/templates/items/item-martialart-sheet.hbs +++ /dev/null @@ -1,23 +0,0 @@ -
    -
    - -
    -

    -
    -
    - - {{> systems/fvtt-hero-system-6/templates/partials/partial-item-nav.hbs}} - - {{!-- Sheet Body --}} -
    - -
    - -
      - {{> systems/fvtt-hero-system-6/templates/partials/partial-item-description.hbs}} - {{> systems/fvtt-hero-system-6/templates/partials/partial-item-cost.hbs}} -
    - -
    -
    -