Monnaie pour gérer la fortune

This commit is contained in:
Vincent Vandemeulebrouck 2023-01-28 16:35:45 +01:00
parent 53a7230f1d
commit d381191692
2 changed files with 8 additions and 8 deletions

View File

@ -45,7 +45,7 @@ export class RdDBaseActorSheet extends ActorSheet {
RdDBaseActorSheet.filterItemsPerTypeForSheet(formData, this.actor.itemTypes); RdDBaseActorSheet.filterItemsPerTypeForSheet(formData, this.actor.itemTypes);
formData.calc = { formData.calc = {
fortune: this.toSolsDeniers(this.actor.getFortune()), fortune: Monnaie.toSolsDeniers(this.actor.getFortune()),
prixTotalEquipement: this.actor.computePrixTotalEquipement(), prixTotalEquipement: this.actor.computePrixTotalEquipement(),
encTotal: await this.actor.computeEncTotal(), encTotal: await this.actor.computeEncTotal(),
} }
@ -56,13 +56,6 @@ export class RdDBaseActorSheet extends ActorSheet {
return formData; return formData;
} }
toSolsDeniers(fortune) {
return {
sols: Math.floor(fortune),
deniers: Math.round(100 * (fortune - Math.floor(fortune)))
};
}
/* -------------------------------------------- */ /* -------------------------------------------- */
static filterItemsPerTypeForSheet(formData, itemTypes) { static filterItemsPerTypeForSheet(formData, itemTypes) {
formData.recettescuisine = Misc.arrayOrEmpty(itemTypes['recettecuisine']); formData.recettescuisine = Misc.arrayOrEmpty(itemTypes['recettecuisine']);

View File

@ -62,6 +62,13 @@ export class Monnaie {
return deniers; return deniers;
} }
static toSolsDeniers(fortune) {
return {
sols: Math.floor(fortune),
deniers: Math.round(100 * (fortune - Math.floor(fortune)))
};
}
static getFortune(monnaies) { static getFortune(monnaies) {
return (monnaies??[]) return (monnaies??[])
.map(m => Number(m.system.cout) * Number(m.system.quantite)) .map(m => Number(m.system.cout) * Number(m.system.quantite))