Gestion des quantites et de l'argent
This commit is contained in:
parent
5ab6b99ef6
commit
5dde9ac72f
@ -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}),
|
||||
@ -113,14 +116,11 @@ export class HawkmoonActorSheet extends ActorSheet {
|
||||
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)
|
||||
|
@ -117,6 +117,10 @@ export class HawkmoonActor extends Actor {
|
||||
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)
|
||||
|
@ -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
|
||||
|
@ -1437,3 +1437,6 @@ ul, li {
|
||||
.adversite-modify {
|
||||
margin-top: 12px;
|
||||
}
|
||||
.argent-total-text {
|
||||
margin-left: 4px;
|
||||
}
|
@ -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",
|
||||
|
@ -124,6 +124,7 @@
|
||||
"prixca": 0,
|
||||
"prixsc": 0,
|
||||
"rarete": 0,
|
||||
"quantite": 0,
|
||||
"equipped": false
|
||||
},
|
||||
"automation": {
|
||||
|
@ -341,12 +341,69 @@
|
||||
|
||||
<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"> </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"> </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">
|
||||
<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">Equipements</label></h3>
|
||||
</span>
|
||||
|
||||
<span class="item-field-label-short">
|
||||
<label class="short-label">Quantité</label>
|
||||
</span>
|
||||
|
||||
<div class="item-filler"> </div>
|
||||
<div class="item-controls item-controls-fixed">
|
||||
<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">
|
||||
<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 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"> </div>
|
||||
<div class="item-controls item-controls-fixed">
|
||||
<a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
|
||||
|
@ -13,7 +13,18 @@
|
||||
|
||||
<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>
|
||||
|
||||
|
@ -9,6 +9,12 @@
|
||||
<input type="checkbox" name="system.equipped" {{checked system.equipped}} />
|
||||
</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">
|
||||
|
||||
<label class="generic-label item-field-label-long">Prix (PA) </label>
|
||||
|
Loading…
Reference in New Issue
Block a user