60 lines
1.8 KiB
JavaScript
60 lines
1.8 KiB
JavaScript
import { Misc } from "./misc.js";
|
|
|
|
const monnaiesData = [
|
|
{
|
|
name: "Etain (1 denier)", type: 'monnaie',
|
|
img: "systems/foundryvtt-reve-de-dragon/icons/objets/piece_etain_poisson.webp",
|
|
data: { quantite: 0, valeur_deniers: 1, encombrement: 0.001, description: "" }
|
|
},
|
|
{
|
|
name: "Bronze (10 deniers)", type: 'monnaie',
|
|
img: "systems/foundryvtt-reve-de-dragon/icons/objets/piece_bronze_epees.webp",
|
|
data: { quantite: 0, valeur_deniers: 10, encombrement: 0.002, description: "" }
|
|
},
|
|
{
|
|
name: "Argent (1 sol)", type: 'monnaie',
|
|
img: "systems/foundryvtt-reve-de-dragon/icons/objets/piece_argent_sol.webp",
|
|
data: { quantite: 0, valeur_deniers: 100, encombrement: 0.003, description: "" }
|
|
},
|
|
{
|
|
name: "Or (10 sols)", type: 'monnaie',
|
|
img: "systems/foundryvtt-reve-de-dragon/icons/objets/piece_or_sol.webp",
|
|
data: { quantite: 0, valeur_deniers: 1000, encombrement: 0.004, description: "" }
|
|
}
|
|
]
|
|
|
|
export class Monnaie {
|
|
|
|
static isSystemMonnaie(item) {
|
|
let present = monnaiesData.find(monnaie => monnaie.system.valeur_deniers == item?.system?.valeur_deniers);
|
|
return present;
|
|
}
|
|
|
|
static monnaiesData() {
|
|
return monnaiesData;
|
|
}
|
|
|
|
static filtrerMonnaies(items) {
|
|
return items.filter(it => it.type == 'monnaie');
|
|
}
|
|
|
|
static monnaiesManquantes(items) {
|
|
const valeurs = Monnaie.filtrerMonnaies(items)
|
|
.map(it => it.system.valeur_deniers);
|
|
const manquantes = monnaiesData.filter(monnaie => !valeurs.find(v => v != monnaie.system?.valeur_deniers))
|
|
return []; //manquantes;
|
|
}
|
|
|
|
static deValeur(monnaie, v) {
|
|
return v != monnaie.system.valeur_deniers
|
|
}
|
|
|
|
static arrondiDeniers(sols) {
|
|
return sols.toFixed(2);
|
|
}
|
|
|
|
static triValeurDenier() {
|
|
return Misc.ascending(item => item.system.valeur_deniers)
|
|
}
|
|
}
|