Files
fvtt-mournblade-cyd-2-0/modules/models/base-item.mjs
T
uberwald 4c33607b2b Refactor: Eliminate code duplication for currency conversion and item pricing
- Add static calculateItemValueSC() and getItemValueSC() helpers to MournbladeCYD2Utility
  to centralize currency conversion logic (1 PO = 100 SC, 1 PA = 10 SC)
- Refactor computeRichesse() and computeValeurEquipement() in Actor to use shared helpers
- Add localizeAllegiance Handlebars helper to display allegiance values localized
  (tous->Tous, chaos->Chaos, loi->Loi, betes->Bêtes, elementaires->Élémentaires)
- Add joinPredilections helper to fix comma display after single Predilection
- Create BaseItemWithPriceDataModel base class for items with pricing fields
  (prixpo, prixca, prixsc, rarete, quantite, equipped)
- Update arme, equipement, protection, monnaie models to extend base class
- Update actor-sheet and creature-sheet templates to use new helpers
- Update partial-item-prix.hbs to display total item value in SC
- Add item-base-sheet.hbs template for future item sheet inheritance

Fixes:
- Allegiance values now display properly localized in Dons & Pactes tabs
- Predilections no longer show trailing comma with single entry
- Equipment value totals now update correctly when items are added/modified
- Currency conversion logic centralized and consistent across the system

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-06-07 20:52:46 +02:00

30 lines
958 B
JavaScript

/**
* Data model de base pour les items MournbladeCYD2
*/
export default class BaseItemDataModel extends foundry.abstract.TypeDataModel {
static defineSchema() {
const fields = foundry.data.fields;
return {
description: new fields.HTMLField({ initial: "" })
};
}
}
/**
* Data model de base pour les items avec prix MournbladeCYD2
*/
export class BaseItemWithPriceDataModel extends BaseItemDataModel {
static defineSchema() {
const fields = foundry.data.fields;
return {
...super.defineSchema(),
prixpo: new fields.NumberField({ initial: 0, integer: true }),
prixca: new fields.NumberField({ initial: 0, integer: true }),
prixsc: new fields.NumberField({ initial: 0, integer: true }),
rarete: new fields.NumberField({ initial: 0, integer: true }),
quantite: new fields.NumberField({ initial: 1, integer: true }),
equipped: new fields.BooleanField({ initial: false })
};
}
}