Gestion des quantites et de l'argent

This commit is contained in:
LeRatierBretonnien 2022-12-03 23:57:30 +01:00
parent 5ab6b99ef6
commit 5dde9ac72f
9 changed files with 134 additions and 14 deletions

View File

@ -48,6 +48,9 @@ export class HawkmoonActorSheet extends ActorSheet {
profils: duplicate(this.actor.getProfils() || {}), profils: duplicate(this.actor.getProfils() || {}),
combat: this.actor.getCombatValues(), combat: this.actor.getCombatValues(),
equipements: duplicate(this.actor.getEquipments()), 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, initiative: this.actor.getFlag("world", "last-initiative") || -1,
description: await TextEditor.enrichHTML(this.object.system.biodata.description, {async: true}), description: await TextEditor.enrichHTML(this.object.system.biodata.description, {async: true}),
habitat: await TextEditor.enrichHTML(this.object.system.biodata.habitat, {async: true}), habitat: await TextEditor.enrichHTML(this.object.system.biodata.habitat, {async: true}),
@ -113,14 +116,11 @@ export class HawkmoonActorSheet extends ActorSheet {
this.actor.incDecAdversite(adv, value) this.actor.incDecAdversite(adv, value)
}) })
html.find('.quantity-minus').click(event => { html.find('.quantity-modify').click(event => {
const li = $(event.currentTarget).parents(".item"); const li = $(event.currentTarget).parents(".item")
this.actor.incDecQuantity( li.data("item-id"), -1 ); const value = Number($(event.currentTarget).data("quantite-value"))
} ); this.actor.incDecQuantity( li.data("item-id"), value );
html.find('.quantity-plus').click(event => { })
const li = $(event.currentTarget).parents(".item");
this.actor.incDecQuantity( li.data("item-id"), +1 );
} );
html.find('.roll-initiative').click((event) => { html.find('.roll-initiative').click((event) => {
this.actor.rollAttribut("pre", true) this.actor.rollAttribut("pre", true)

View File

@ -117,6 +117,10 @@ export class HawkmoonActor extends Actor {
return this.items.filter(item => item.type == "equipement") return this.items.filter(item => item.type == "equipement")
} }
/* ----------------------- --------------------- */ /* ----------------------- --------------------- */
getMonnaies() {
return this.items.filter(item => item.type == "monnaie")
}
/* -------------------------------------------- */
getArmors() { getArmors() {
return this.items.filter(item => item.type == "protection") return this.items.filter(item => item.type == "protection")
} }
@ -427,12 +431,36 @@ export class HawkmoonActor extends Actor {
async incDecQuantity(objetId, incDec = 0) { async incDecQuantity(objetId, incDec = 0) {
let objetQ = this.items.get(objetId) let objetQ = this.items.get(objetId)
if (objetQ) { if (objetQ) {
let newQ = objetQ.system.quantity + incDec let newQ = objetQ.system.quantite + incDec
newQ = Math.max(newQ, 0) 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) { getCompetence(compId) {
return this.items.get(compId) return this.items.get(compId)

View File

@ -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) { static computeResult(rollData) {
rollData.diceResult = rollData.roll.terms[0].results[0].result rollData.diceResult = rollData.roll.terms[0].results[0].result

View File

@ -1437,3 +1437,6 @@ ul, li {
.adversite-modify { .adversite-modify {
margin-top: 12px; margin-top: 12px;
} }
.argent-total-text {
margin-left: 4px;
}

View File

@ -1,7 +1,7 @@
{ {
"id": "fvtt-hawkmoon-cyd", "id": "fvtt-hawkmoon-cyd",
"description": "Hawmoon RPG for FoundryVTT (CYD system - French)", "description": "Hawmoon RPG for FoundryVTT (CYD system - French)",
"version": "10.1.2", "version": "10.1.4",
"authors": [ "authors": [
{ {
"name": "Uberwald/LeRatierBretonnien", "name": "Uberwald/LeRatierBretonnien",
@ -35,7 +35,7 @@
"gridUnits": "m", "gridUnits": "m",
"license": "LICENSE.txt", "license": "LICENSE.txt",
"manifest": "https://www.uberwald.me/gitea/public/fvtt-hawkmoon-cyd/raw/branch/master/system.json", "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": [ "packs": [
{ {
"type": "Item", "type": "Item",

View File

@ -124,6 +124,7 @@
"prixca": 0, "prixca": 0,
"prixsc": 0, "prixsc": 0,
"rarete": 0, "rarete": 0,
"quantite": 0,
"equipped": false "equipped": false
}, },
"automation": { "automation": {

View File

@ -341,12 +341,69 @@
<div class="flexcol"> <div class="flexcol">
<hr>
<div class="sheet-box color-bg-archetype">
<h4>
<label class="argent-total-text">
Argent Total : {{richesse.po}} PO - {{richesse.pa}} PA - {{richesse.sc}} SC (total {{richesse.valueSC}} SC)
</label>
</h4>
</div>
<div class="sheet-box color-bg-archetype">
<ul class="item-list alternate-list">
<li class="item flexrow list-item items-title-bg">
<span class="item-name-label-header">
<h3><label class="items-title-text">Richesses et Argent</label></h3>
</span>
<span class="item-field-label-short">
<label class="short-label">Quantité</label>
</span>
<div class="item-filler">&nbsp;</div>
<div class="item-controls item-controls-fixed">
<a class="item-control item-add" data-type="arme" title="Ajouter une arme"><i
class="fas fa-plus"></i></a>
</div>
</li>
{{#each monnaies as |monnaie key|}}
<li class="item flexrow " data-item-id="{{monnaie._id}}" data-item-type="monnaie">
<img class="item-name-img" src="{{monnaie.img}}" />
<span class="item-name-label competence-name">{{monnaie.name}}</span>
<span class="item-name-label competence-name item-field-label-medium">{{monnaie.system.quantite}}
<a class="quantity-modify plus-minus-button" data-quantite-value="-1">-</a>
<a class="quantity-modify plus-minus-button" data-quantite-value="+1">+</a>
</span>
<div class="item-filler">&nbsp;</div>
<div class="item-controls item-controls-fixed">
<a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
</div>
</li>
{{/each}}
</ul>
</div>
<hr>
<div class="sheet-box color-bg-archetype">
<h4>
<label class="argent-total-text">
Valeur Total Equipement : {{valeurEquipement.po}} PO - {{valeurEquipement.pa}} PA - {{valeurEquipement.sc}} SC (total {{valeurEquipement.valueSC}} SC)
</label>
</h4>
</div>
<div class="sheet-box color-bg-archetype"> <div class="sheet-box color-bg-archetype">
<ul class="item-list alternate-list"> <ul class="item-list alternate-list">
<li class="item flexrow list-item items-title-bg"> <li class="item flexrow list-item items-title-bg">
<span class="item-name-label-header"> <span class="item-name-label-header">
<h3><label class="items-title-text">Equipements</label></h3> <h3><label class="items-title-text">Equipements</label></h3>
</span> </span>
<span class="item-field-label-short">
<label class="short-label">Quantité</label>
</span>
<div class="item-filler">&nbsp;</div> <div class="item-filler">&nbsp;</div>
<div class="item-controls item-controls-fixed"> <div class="item-controls item-controls-fixed">
<a class="item-control item-add" data-type="arme" title="Ajouter une arme"><i <a class="item-control item-add" data-type="arme" title="Ajouter une arme"><i
@ -357,6 +414,10 @@
<li class="item flexrow " data-item-id="{{equipement._id}}" data-item-type="equipement"> <li class="item flexrow " data-item-id="{{equipement._id}}" data-item-type="equipement">
<img class="item-name-img" src="{{equipement.img}}" /> <img class="item-name-img" src="{{equipement.img}}" />
<span class="item-name-label competence-name">{{equipement.name}}</span> <span class="item-name-label competence-name">{{equipement.name}}</span>
<span class="item-name-label competence-name item-field-label-medium">{{equipement.system.quantite}}
<a class="quantity-modify plus-minus-button" data-quantite-value="-1">-</a>
<a class="quantity-modify plus-minus-button" data-quantite-value="+1">+</a>
</span>
<div class="item-filler">&nbsp;</div> <div class="item-filler">&nbsp;</div>
<div class="item-controls item-controls-fixed"> <div class="item-controls item-controls-fixed">
<a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a> <a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>

View File

@ -13,7 +13,18 @@
<ul class="item-list alternate-list"> <ul class="item-list alternate-list">
{{> systems/fvtt-hawkmoon-cyd/templates/partial-item-prix.html}} <li class="flexrow item">
<label class="generic-label item-field-label-long">Quantite </label>
<input type="text" class="padd-right numeric-input item-field-label-short" name="system.quantite"
value="{{system.quantite}}" data-dtype="Number" />
</li>
<li class="flexrow item">
<label class="generic-label item-field-label-long">Valeur en Sous de Cuivre (SC)</label>
<input type="text" class="numeric-input item-field-label-short" name="system.prixsc" value="{{system.prixsc}}"
data-dtype="Number" />
</li>
</ul> </ul>

View File

@ -9,6 +9,12 @@
<input type="checkbox" name="system.equipped" {{checked system.equipped}} /> <input type="checkbox" name="system.equipped" {{checked system.equipped}} />
</li> </li>
<li class="flexrow item">
<label class="generic-label item-field-label-long">Quantite </label>
<input type="text" class="padd-right numeric-input item-field-label-short" name="system.quantite"
value="{{system.quantite}}" data-dtype="Number" />
</li>
<li class="flexrow item"> <li class="flexrow item">
<label class="generic-label item-field-label-long">Prix (PA) </label> <label class="generic-label item-field-label-long">Prix (PA) </label>