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>
This commit is contained in:
2026-06-07 20:52:46 +02:00
parent 0d4bd37f30
commit 4c33607b2b
12 changed files with 105 additions and 53 deletions
+3 -7
View File
@@ -273,11 +273,7 @@
data-attr-key="tochoose">{{skill.name}}</a></span>
<span class="predilection-text">
{{#each skill.system.predilections as |pred key|}}
{{#if (and pred.acquise (not pred.used))}}
{{pred.name}}{{#unless (eq key (subtract skill.system.predilections.length 1))}}, {{/unless}}
{{/if}}
{{/each}}
{{joinPredilections skill.system.predilections}}
</span>
</div>
@@ -336,7 +332,7 @@
<li class="item flexrow " data-item-id="{{don._id}}" data-item-type="don">
<img class="item-name-img" src="{{don.img}}" />
<span class="item-name-label competence-name">{{don.name}}</span>
<span class="item-field-label-short">{{don.system.allegeance}}</span>
<span class="item-field-label-short">{{localizeAllegiance don.system.allegeance}}</span>
<div class="item-filler">&nbsp;</div>
<div class="item-controls item-controls-fixed">
<a class="item-control" data-action="editItem" title="Edit Item"><i class="fas fa-edit"></i></a>
@@ -365,7 +361,7 @@
<li class="item flexrow " data-item-id="{{pacte._id}}" data-item-type="pacte">
<img class="item-name-img" src="{{pacte.img}}" />
<span class="item-name-label competence-name">{{pacte.name}}</span>
<span class="item-field-label-short">{{pacte.system.allegeance}}</span>
<span class="item-field-label-short">{{localizeAllegiance pacte.system.allegeance}}</span>
<div class="item-filler">&nbsp;</div>
<div class="item-controls item-controls-fixed">
<a class="item-control" data-action="editItem" title="Edit Item"><i class="fas fa-edit"></i></a>
+1 -3
View File
@@ -266,9 +266,7 @@
<a data-action="rollCompetence" data-attr-key="tochoose">{{skill.name}}</a>
</span>
<span class="predilection-text">
{{#each skill.system.predilections as |pred key|}}
{{#if (and pred.acquise (not pred.used))}}{{pred.name}}{{#unless (eq key (subtract skill.system.predilections.length 1))}}, {{/unless}}{{/if}}
{{/each}}
{{joinPredilections skill.system.predilections}}
</span>
</div>
<select class="status-small-label color-class-common edit-item-data competence-niveau"
+21
View File
@@ -0,0 +1,21 @@
<section>
{{> systems/fvtt-mournblade-cyd-2-0/templates/partial-item-header.hbs}}
{{> systems/fvtt-mournblade-cyd-2-0/templates/partial-item-nav.hbs}}
{{!-- Sheet Body --}}
<section class="sheet-body">
{{> systems/fvtt-mournblade-cyd-2-0/templates/partial-item-description.hbs}}
<div class="tab details" data-group="primary" data-tab="details">
{{! Content to be overridden by specific item templates }}
</div>
{{!-- Effects Tab --}}
<div class="tab effects" data-group="primary" data-tab="effects">
{{> systems/fvtt-mournblade-cyd-2-0/templates/partial-item-effects.hbs}}
</div>
</section>
</section>
+1 -1
View File
@@ -24,4 +24,4 @@
</div>
</section>
</section>
</section>
+5 -2
View File
@@ -16,8 +16,7 @@
</li>
<li class="flexrow item">
<label class="generic-label item-field-label-long">Prix (PA) </label>
<label class="generic-label item-field-label-long">Prix </label>
<input type="text" class="numeric-input item-field-label-short" name="system.prixpo" value="{{system.prixpo}}"
data-dtype="Number" />
@@ -30,4 +29,8 @@
<input type="text" class="numeric-input item-field-label-short" name="system.prixsc" value="{{system.prixsc}}"
data-dtype="Number" />
<label class="generic-label item-field-label-short">SC </label>
</li>
<li class="flexrow item">
<label class="generic-label item-field-label-long">Valeur totale </label>
<span class="item-field-label-long">{{calculateItemValueSC system.prixpo system.prixca system.prixsc}} SC</span>
</li>