From f26cd7670cc0825addf837191d08121b58fcbd30 Mon Sep 17 00:00:00 2001 From: LeRatierBretonnien Date: Sat, 11 Mar 2023 12:11:27 +0100 Subject: [PATCH] Various fixes --- modules/heritiers-actor-sheet.js | 11 +++++-- modules/heritiers-actor.js | 20 +++++++++--- modules/heritiers-config.js | 12 +++---- modules/heritiers-utility.js | 32 +++++++------------ styles/simple.css | 3 ++ system.json | 4 +-- template.json | 4 +++ templates/actor-sheet.html | 49 +++++++++-------------------- templates/chat-generic-result.html | 4 +++ templates/partial-utile-skills.html | 36 +++++++++++++++++++++ templates/roll-dialog-generic.html | 7 +++++ 11 files changed, 111 insertions(+), 71 deletions(-) create mode 100644 templates/partial-utile-skills.html diff --git a/modules/heritiers-actor-sheet.js b/modules/heritiers-actor-sheet.js index aa95de3..03582a1 100644 --- a/modules/heritiers-actor-sheet.js +++ b/modules/heritiers-actor-sheet.js @@ -14,8 +14,8 @@ export class HeritiersActorSheet extends ActorSheet { return mergeObject(super.defaultOptions, { classes: ["fvtt-les-heritiers", "sheet", "actor"], template: "systems/fvtt-les-heritiers/templates/actor-sheet.html", - width: 640, - height: 720, + width: 780, + height: 840, tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "stats" }], dragDrop: [{ dragSelector: ".item-list .item", dropSelector: null }], editScore: false @@ -38,7 +38,8 @@ export class HeritiersActorSheet extends ActorSheet { effects: this.object.effects.map(e => foundry.utils.deepClone(e.data)), limited: this.object.limited, skills: this.actor.getSkills(), - utileSkills :this.actor.organizeUtileSkills(), + utileSkillsMental :this.actor.organizeUtileSkills("mental"), + utileSkillsPhysical :this.actor.organizeUtileSkills("physical"), futileSkills :this.actor.organizeFutileSkills(), contacts: this.actor.organizeContacts(), armes: duplicate(this.actor.getWeapons()), @@ -136,6 +137,10 @@ export class HeritiersActorSheet extends ActorSheet { const key = $(event.currentTarget).data("key") this.actor.rollCarac(key, false) }) + html.find('.roll-rang').click((event) => { + const key = $(event.currentTarget).data("rang-key") + this.actor.rollRang(key, false) + }) html.find('.roll-competence').click((event) => { const li = $(event.currentTarget).parents(".item") let compId = li.data("item-id") diff --git a/modules/heritiers-actor.js b/modules/heritiers-actor.js index 41ece00..e2d463e 100644 --- a/modules/heritiers-actor.js +++ b/modules/heritiers-actor.js @@ -141,7 +141,7 @@ export class HeritiersActor extends Actor { return this.getItemSorted( ["capacitenaturelle"]) } getFee() { - return this.items.filter(item => item.type =="fee") + return this.items.find(item => item.type =="fee") } getProfils() { return this.getItemSorted( ["profil"]) @@ -174,23 +174,25 @@ export class HeritiersActor extends Actor { } /* -------------------------------------------- */ - organizeUtileSkills() { + organizeUtileSkills(kind = "mental") { let comp = {} for (let key in game.system.lesheritiers.config.competenceProfil) { + if ( game.system.lesheritiers.config.competenceProfil[key].kind == kind) comp[key] = [] } for (let item of this.items) { if (item.type == "competence") { - if (item.system.categorie == "utile") { + if (item.system.categorie == "utile" && comp[item.system.profil]) { this.prepareUtileSkill(item) comp[item.system.profil].push(item) } } } + for (let key in comp) { HeritiersUtility.sortArrayObjectsByName(comp[key]) } - return comp + return Object.fromEntries(Object.entries(comp).sort()) } /* -------------------------------------------- */ organizeContacts() { @@ -553,6 +555,16 @@ export class HeritiersActor extends Actor { rollDialog.render(true) } + /* -------------------------------------------- */ + async rollRang(key, isInit = false) { + let rollData = this.getCommonRollData() + rollData.mode = "rang" + rollData.rang = this.system.rang[key] + rollData.rangKey = key + let rollDialog = await HeritiersRollDialog.create(this, rollData) + rollDialog.render(true) + } + /* -------------------------------------------- */ async rollCompetence(compId) { let rollData = this.getCommonRollData(compId) diff --git a/modules/heritiers-config.js b/modules/heritiers-config.js index cd1ccf6..1df094d 100644 --- a/modules/heritiers-config.js +++ b/modules/heritiers-config.js @@ -25,12 +25,12 @@ export const HERITIERS_CONFIG = { }, competenceProfil : { - "aventurier": "Aventurier", - "roublard": "Roublard", - "combattant": "Combattant", - "erudit": "Erudit", - "savant": "Savant", - "gentleman": "Gentleman" + "aventurier": {kind: "physical", name: "Aventurier"}, + "roublard": {kind: "physical",name: "Roublard"}, + "combattant": {kind: "physical",name:"Combattant"}, + "erudit": {kind: "mental",name:"Erudit"}, + "savant": {kind: "mental",name:"Savant"}, + "gentleman": {kind: "mental",name:"Gentleman"} }, baseTestPouvoir: { "feerie": "Féerie", diff --git a/modules/heritiers-utility.js b/modules/heritiers-utility.js index 666ef4a..4cd5be5 100644 --- a/modules/heritiers-utility.js +++ b/modules/heritiers-utility.js @@ -44,30 +44,14 @@ export class HeritiersUtility { /* -------------------------------------------- */ static sortByName(table) { return table.sort(function (a, b) { - let fa = a.name.toLowerCase(), - fb = b.name.toLowerCase(); - if (fa < fb) { - return -1; - } - if (fa > fb) { - return 1; - } - return 0; + return a.name.localeCompare(b.name); }) } /* -------------------------------------------- */ static sortArrayObjectsByName(myArray) { myArray.sort((a, b) => { - let fa = a.name.toLowerCase(); - let fb = b.name.toLowerCase(); - if (fa < fb) { - return -1; - } - if (fa > fb) { - return 1; - } - return 0; + return a.name.localeCompare(b.name); }) } @@ -130,6 +114,7 @@ export class HeritiersUtility { 'systems/fvtt-les-heritiers/templates/partial-item-header.html', 'systems/fvtt-les-heritiers/templates/partial-item-description.html', 'systems/fvtt-les-heritiers/templates/partial-item-nav.html', + 'systems/fvtt-les-heritiers/templates/partial-utile-skills.html', 'systems/fvtt-les-heritiers/templates/partial-list-niveau.html' ] return loadTemplates(templatePaths); @@ -358,14 +343,19 @@ export class HeritiersUtility { rollData.nbDice = (rollData.useTricherie || rollData.useHeritage) ? 3 : 1 rollData.diceFormula = rollData.nbDice + rollData.mainDice + "kh1" //console.log("BEFORE COMP", rollData) + + let rangValue = 0 + if (rollData.rang) { + rangValue = rollData.rang.value + } if (rollData.competence) { let compmod = (rollData.competence.system.niveau == 0) ? -3 : 0 let specBonus = (rollData.useSpecialite) ? 1 : 0 - rollData.diceFormula += `+${rollData.carac.value}+${rollData.competence.system.niveau}+${specBonus}+${rollData.bonusMalusContext}+${compmod}` + rollData.diceFormula += `+${rollData.carac.value}+${rangValue}+${rollData.competence.system.niveau}+${specBonus}+${rollData.bonusMalusContext}+${compmod}` } else if (rollData.pouvoirBase) { - rollData.diceFormula += `+${rollData.pouvoirBase.value}+${rollData.bonusMalusContext}` + rollData.diceFormula += `+${rollData.pouvoirBase.value}+${rangValue}+${rollData.bonusMalusContext}` } else { - rollData.diceFormula += `+${rollData.carac.value}+${rollData.bonusMalusContext}` + rollData.diceFormula += `+${rollData.carac.value}+${rangValue}+${rollData.bonusMalusContext}` } rollData.diceFormula += `+${rollData.pvMalus}` diff --git a/styles/simple.css b/styles/simple.css index 25fcfc2..354cd0a 100644 --- a/styles/simple.css +++ b/styles/simple.css @@ -653,6 +653,9 @@ ul, li { padding-left: 0.25rem; margin-right: 0.25rem; } +.specialisarion-margin { + margin-left: 1.5rem; +} .short-label { flex-grow: 1; } diff --git a/system.json b/system.json index 07697e3..3bfc688 100644 --- a/system.json +++ b/system.json @@ -1,7 +1,7 @@ { "id": "fvtt-les-heritiers", "description": "Les Héritiers pour FoundryVTT", - "version": "10.0.25", + "version": "10.0.26", "authors": [ { "name": "Uberwald/LeRatierBretonnien", @@ -19,7 +19,7 @@ "gridUnits": "m", "license": "LICENSE.txt", "manifest": "https://www.uberwald.me/gitea/public/fvtt-les-heritiers/raw/branch/master/system.json", - "download": "https://www.uberwald.me/gitea/public/fvtt-les-heritiers/archive/fvtt-les-heritiers-10.0.25.zip", + "download": "https://www.uberwald.me/gitea/public/fvtt-les-heritiers/archive/fvtt-les-heritiers-10.0.26.zip", "languages": [ { "lang": "fr", diff --git a/template.json b/template.json index aa38e63..10dedcd 100644 --- a/template.json +++ b/template.json @@ -117,18 +117,22 @@ }, "rang": { "tricherie": { + "label": "Tricherie", "value": 0, "max": 0 }, "feerie": { + "label": "Féerie", "value": 0, "max": 0 }, "masque": { + "label": "Masque", "value": 0, "max": 0 }, "heritage": { + "label": "Héritage", "value": 0, "max": 0, "scenarios": 0 diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index 8c30d6c..eac5206 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -78,42 +78,21 @@
- {{#each utileSkills as |skillList keyProfil|}} -
-
    -
  • - -

    -
    - - - -
     
    -
  • - {{#each skillList as |skill key|}} -
  • - {{skill.name}} - +
    - - - {{skill.specList}} - -
    - - -
    -
  • +
    + {{#each utileSkillsPhysical as |skillList keyProfil|}} + {{> systems/fvtt-les-heritiers/templates/partial-utile-skills.html skillList=skillList keyProfil=keyProfil}} {{/each}} -
+
+ +
+ {{#each utileSkillsMental as |skillList keyProfil|}} + {{> systems/fvtt-les-heritiers/templates/partial-utile-skills.html skillList=skillList keyProfil=keyProfil}} + {{/each}} +
+
- {{/each}}