From fef42b70930157e16f599c8f095228b123450583 Mon Sep 17 00:00:00 2001 From: LeRatierBretonnien Date: Tue, 14 Mar 2023 09:14:28 +0100 Subject: [PATCH] Various fixes --- modules/mournblade-actor-sheet.js | 14 ++++++++-- modules/mournblade-actor.js | 42 +++++++++++++---------------- modules/mournblade-main.js | 3 ++- modules/mournblade-utility.js | 7 +++++ system.json | 7 +++-- template.json | 2 ++ templates/actor-sheet.html | 45 ++++++++++++++++++++++++++++--- templates/item-monnaie-sheet.html | 14 ++++++++-- 8 files changed, 98 insertions(+), 36 deletions(-) diff --git a/modules/mournblade-actor-sheet.js b/modules/mournblade-actor-sheet.js index 11666c4..aa8f3b8 100644 --- a/modules/mournblade-actor-sheet.js +++ b/modules/mournblade-actor-sheet.js @@ -53,6 +53,7 @@ export class MournbladeActorSheet extends ActorSheet { metier: duplicate(this.actor.getMetier() || {}), combat: this.actor.getCombatValues(), equipements: duplicate(this.actor.getEquipments()), + monnaies: duplicate(this.actor.getMonnaies()), description: await TextEditor.enrichHTML(this.object.system.biodata.description, {async: true}), options: this.options, owner: this.document.isOwner, @@ -95,7 +96,7 @@ export class MournbladeActorSheet extends ActorSheet { let value = ev.currentTarget.value this.actor.editItemField(itemId, itemType, itemField, dataType, value) }) - + html.find('.quantity-minus').click(event => { const li = $(event.currentTarget).parents(".item"); this.actor.incDecQuantity( li.data("item-id"), -1 ); @@ -131,7 +132,16 @@ export class MournbladeActorSheet extends ActorSheet { let armeId = li.data("item-id") this.actor.rollArmeDegats(armeId) }) - + html.find('.quantity-modify').click(event => { + const li = $(event.currentTarget).parents(".item") + const value = Number($(event.currentTarget).data("quantite-value")) + this.actor.incDecQuantity( li.data("item-id"), value ); + }) + html.find('.item-add').click((event) => { + const itemType = $(event.currentTarget).data("type") + this.actor.createEmbeddedDocuments('Item', [{ name: `Nouveau ${itemType}`, type: itemType }], { renderSheet: true }) + }) + html.find('.lock-unlock-sheet').click((event) => { this.options.editScore = !this.options.editScore; diff --git a/modules/mournblade-actor.js b/modules/mournblade-actor.js index de43528..b6e9728 100644 --- a/modules/mournblade-actor.js +++ b/modules/mournblade-actor.js @@ -96,27 +96,33 @@ export class MournbladeActor extends Actor { armes.push(this.prepareBouclier(arme)) } } + MournbladeUtility.sortArrayObjectsByName(armes) return armes } /* -------------------------------------------- */ - getDons() { - return this.items.filter(item => item.type == "don") + getItemSorted( types) { + let items = this.items.filter(item => types.includes(item.type )) || [] + MournbladeUtility.sortArrayObjectsByName(items) + return items + } + getDons() { + return this.getItemSorted(["don"]) } - /* -------------------------------------------- */ getTendances() { - return this.items.filter(item => item.type == "tendance") + return this.getItemSorted(["tendance"]) } getRunes() { - return this.items.filter(item => item.type == "rune") + return this.getItemSorted(["rune"]) } - /* -------------------------------------------- */ getEquipments() { - return this.items.filter(item => item.type == "equipement") + return this.getItemSorted(["monnaie"]) + } + getMonnaies() { + return this.getItemSorted(["monnaie"]) } - /* -------------------------------------------- */ getArmors() { - return this.items.filter(item => item.type == "protection") + return this.getItemSorted(["protection"]) } getOrigine() { return this.items.find(item => item.type == "origine") @@ -147,17 +153,8 @@ export class MournbladeActor extends Actor { comp.push(item) } } - return comp.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; - }) + MournbladeUtility.sortArrayObjectsByName(comp) + return comp } /* -------------------------------------------- */ @@ -359,11 +356,10 @@ export class MournbladeActor extends Actor { async incDecQuantity(objetId, incDec = 0) { let objetQ = this.items.get(objetId) if (objetQ) { - let newQ = objetQ.system.quantity + incDec; - const updated = await this.updateEmbeddedDocuments('Item', [{ _id: objetQ.id, 'system.quantity': newQ }]); // pdates one EmbeddedEntity + let newQ = objetQ.system.quantite + incDec; + const updated = await this.updateEmbeddedDocuments('Item', [{ _id: objetQ.id, 'system.quantite': newQ }]); // pdates one EmbeddedEntity } } - /* -------------------------------------------- */ getCompetence(compId) { return this.items.get(compId) diff --git a/modules/mournblade-main.js b/modules/mournblade-main.js index 690823f..e25935b 100644 --- a/modules/mournblade-main.js +++ b/modules/mournblade-main.js @@ -68,7 +68,8 @@ function welcomeMessage() { content: `
Bienvenue dans les Jeunes Royaumes de Mournblade !

Les livres de Mournblade sont nécessaires pour jouer : https://www.titam-france.fr

-

Mournblade est jeude rôle publié par Titam France/Sombres projets, tout les droits leur appartiennent.

+

Mournblade est jeu de rôle publié par Titam France/Sombres projets, tout les droits leur appartiennent.

+

Système développé par LeRatierBretonnien, support sur le Discord FR de Foundry.

` }); } diff --git a/modules/mournblade-utility.js b/modules/mournblade-utility.js index 5480e32..2399ec3 100644 --- a/modules/mournblade-utility.js +++ b/modules/mournblade-utility.js @@ -67,6 +67,13 @@ export class MournbladeUtility { return opt.concat("\n") } + /* -------------------------------------------- */ + static sortArrayObjectsByName(myArray) { + myArray.sort((a, b) => { + return a.name.localeCompare(b.name); + }) + } + /* -------------------------------------------- */ static getPointAmeOptions() { let opt = [] diff --git a/system.json b/system.json index 40678e9..860bd8e 100644 --- a/system.json +++ b/system.json @@ -1,7 +1,7 @@ { "id": "fvtt-mournblade", "description": "Mournblade RPG for FoundryVTT", - "version": "10.0.12", + "version": "10.0.13", "authors": [ { "name": "Uberwald/LeRatierBretonnien", @@ -15,7 +15,7 @@ "gridUnits": "m", "license": "LICENSE.txt", "manifest": "https://www.uberwald.me/gitea/public/fvtt-mournblade/raw/branch/v10/system.json", - "download": "https://www.uberwald.me/gitea/public/fvtt-mournblade/archive/fvtt-mournblade-10.0.12.zip", + "download": "https://www.uberwald.me/gitea/public/fvtt-mournblade/archive/fvtt-mournblade-10.0.13.zip", "packs": [ { "type": "Item", @@ -137,7 +137,6 @@ "background": "systems/fvtt-mournblade/assets/ui/fond_mournblade.webp", "compatibility": { "minimum": "10", - "verified": "10.286", - "maximum": "10" + "verified": "10.288" } } \ No newline at end of file diff --git a/template.json b/template.json index 53fe431..cdb5241 100644 --- a/template.json +++ b/template.json @@ -233,6 +233,8 @@ ] }, "monnaie": { + "quantite": 0, + "unite": "", "templates": [ "base" ] diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index 5913c80..c1233c2 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -277,7 +277,7 @@

- + @@ -291,7 +291,7 @@
  • {{rune.name}} - {{rune.system.formule}} + {{rune.system.formule}} {{rune.system.seuil}}
     
    @@ -342,6 +342,43 @@
    +
    +
      +
    • + +

      +
      + + + + + + +
       
      +
      + +
      +
    • + {{#each monnaies as |monnaie key|}} +
    • + + {{monnaie.name}} + {{monnaie.system.quantite}} + - + + + + {{monnaie.system.unite}} +
       
      +
      + + +
      +
    • + {{/each}} +
    +
    +
    • @@ -413,7 +450,7 @@
       
      -
    • @@ -442,7 +479,7 @@
       
      -
      diff --git a/templates/item-monnaie-sheet.html b/templates/item-monnaie-sheet.html index 2f61605..69e8f54 100644 --- a/templates/item-monnaie-sheet.html +++ b/templates/item-monnaie-sheet.html @@ -10,8 +10,18 @@
      - - {{> systems/fvtt-mournblade/templates/partial-item-description.html}} + +
      + + + + + + + + + + {{> systems/fvtt-mournblade/templates/partial-item-description.html}}