diff --git a/modules/hawkmoon-actor-sheet.js b/modules/hawkmoon-actor-sheet.js index 3003edd..9d73418 100644 --- a/modules/hawkmoon-actor-sheet.js +++ b/modules/hawkmoon-actor-sheet.js @@ -48,6 +48,9 @@ export class HawkmoonActorSheet extends ActorSheet { profils: duplicate(this.actor.getProfils() || {}), combat: this.actor.getCombatValues(), equipements: duplicate(this.actor.getEquipments()), + monnaies: duplicate(this.actor.getMonnaies()), + richesse: this.actor.computeRichesse(), + valeurEquipement: this.actor.computeValeurEquipement(), initiative: this.actor.getFlag("world", "last-initiative") || -1, description: await TextEditor.enrichHTML(this.object.system.biodata.description, {async: true}), habitat: await TextEditor.enrichHTML(this.object.system.biodata.habitat, {async: true}), @@ -112,15 +115,12 @@ export class HawkmoonActorSheet extends ActorSheet { let value = Number($(event.currentTarget).data("adversite-value")) this.actor.incDecAdversite(adv, value) }) - - html.find('.quantity-minus').click(event => { - const li = $(event.currentTarget).parents(".item"); - this.actor.incDecQuantity( li.data("item-id"), -1 ); - } ); - html.find('.quantity-plus').click(event => { - const li = $(event.currentTarget).parents(".item"); - this.actor.incDecQuantity( li.data("item-id"), +1 ); - } ); + + 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('.roll-initiative').click((event) => { this.actor.rollAttribut("pre", true) diff --git a/modules/hawkmoon-actor.js b/modules/hawkmoon-actor.js index 0ce7beb..72a109c 100644 --- a/modules/hawkmoon-actor.js +++ b/modules/hawkmoon-actor.js @@ -116,6 +116,10 @@ export class HawkmoonActor extends Actor { getEquipments() { return this.items.filter(item => item.type == "equipement") } + /* ----------------------- --------------------- */ + getMonnaies() { + return this.items.filter(item => item.type == "monnaie") + } /* -------------------------------------------- */ getArmors() { return this.items.filter(item => item.type == "protection") @@ -427,12 +431,36 @@ export class HawkmoonActor extends Actor { async incDecQuantity(objetId, incDec = 0) { let objetQ = this.items.get(objetId) if (objetQ) { - let newQ = objetQ.system.quantity + incDec + let newQ = objetQ.system.quantite + incDec newQ = Math.max(newQ, 0) - const updated = await this.updateEmbeddedDocuments('Item', [{ _id: objetQ.id, 'system.quantity': newQ }]); // pdates one EmbeddedEntity + const updated = await this.updateEmbeddedDocuments('Item', [{ _id: objetQ.id, 'system.quantite': newQ }]); // pdates one EmbeddedEntity } } + /* -------------------------------------------- */ + computeRichesse() { + let valueSC = 0 + for(let monnaie of this.items) { + if (monnaie.type == "monnaie") { + valueSC += Number(monnaie.system.prixsc) * Number(monnaie.system.quantite) + } + } + return HawkmoonUtility.computeMonnaieDetails( valueSC) + } + + /* -------------------------------------------- */ + computeValeurEquipement() { + let valueSC = 0 + for(let equip of this.items) { + if (equip.type == "equipement" || equip.type == "arme" || equip.type == "protection") { + valueSC += Number(equip.system.prixsc) * Number(equip.system.quantite ?? 1) + valueSC += (Number(equip.system.prixca) * Number(equip.system.quantite ?? 1)) * 20 + valueSC += (Number(equip.system.prixpo) * Number(equip.system.quantite ?? 1)) * 400 + } + } + return HawkmoonUtility.computeMonnaieDetails( valueSC) + } + /* -------------------------------------------- */ getCompetence(compId) { return this.items.get(compId) diff --git a/modules/hawkmoon-utility.js b/modules/hawkmoon-utility.js index ed6276b..f170822 100644 --- a/modules/hawkmoon-utility.js +++ b/modules/hawkmoon-utility.js @@ -305,6 +305,16 @@ export class HawkmoonUtility { } } + /* -------------------------------------------- */ + static computeMonnaieDetails(valueSC) { + let po = Math.floor(valueSC / 400) + let pa = Math.floor((valueSC - (po*400)) / 20) + let sc = valueSC - (po*400) - (pa*20) + return { + po: po, pa: pa, sc: sc, valueSC: valueSC + } + } + /* -------------------------------------------- */ static computeResult(rollData) { rollData.diceResult = rollData.roll.terms[0].results[0].result diff --git a/styles/simple.css b/styles/simple.css index e3795fb..0911d16 100644 --- a/styles/simple.css +++ b/styles/simple.css @@ -1436,4 +1436,7 @@ ul, li { } .adversite-modify { margin-top: 12px; +} +.argent-total-text { + margin-left: 4px; } \ No newline at end of file diff --git a/system.json b/system.json index d5875cd..bb57ebc 100644 --- a/system.json +++ b/system.json @@ -1,7 +1,7 @@ { "id": "fvtt-hawkmoon-cyd", "description": "Hawmoon RPG for FoundryVTT (CYD system - French)", - "version": "10.1.2", + "version": "10.1.4", "authors": [ { "name": "Uberwald/LeRatierBretonnien", @@ -35,7 +35,7 @@ "gridUnits": "m", "license": "LICENSE.txt", "manifest": "https://www.uberwald.me/gitea/public/fvtt-hawkmoon-cyd/raw/branch/master/system.json", - "download": "https://www.uberwald.me/gitea/public/fvtt-hawkmoon-cyd/archive/fvtt-hawkmoon-cyd-10.1.2.zip", + "download": "https://www.uberwald.me/gitea/public/fvtt-hawkmoon-cyd/archive/fvtt-hawkmoon-cyd-10.1.4.zip", "packs": [ { "type": "Item", diff --git a/template.json b/template.json index 1f1151a..456bc7f 100644 --- a/template.json +++ b/template.json @@ -124,6 +124,7 @@ "prixca": 0, "prixsc": 0, "rarete": 0, + "quantite": 0, "equipped": false }, "automation": { diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index 1421dac..2122ae4 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -340,6 +340,58 @@