Normalisation des listes d'items

Utiliser le type d'Item + 's'
This commit is contained in:
Vincent Vandemeulebrouck 2025-01-15 21:52:38 +01:00
parent 14391daa0b
commit 8ebd6ec771
14 changed files with 34 additions and 69 deletions

View File

@ -240,7 +240,7 @@ export class RdDActor extends RdDBaseActorSang {
} }
async _recuperationSante(message) { async _recuperationSante(message) {
const maladiesPoisons = this.getMaladiePoisons(); const maladiesPoisons = this.getMaladiesPoisons();
const isMaladeEmpoisonne = maladiesPoisons.length > 0; const isMaladeEmpoisonne = maladiesPoisons.length > 0;
this._messageRecuperationMaladiePoisons(maladiesPoisons, message); this._messageRecuperationMaladiePoisons(maladiesPoisons, message);
@ -248,7 +248,7 @@ export class RdDActor extends RdDBaseActorSang {
await this._recupererVie(message, isMaladeEmpoisonne); await this._recupererVie(message, isMaladeEmpoisonne);
} }
getMaladiePoisons() { getMaladiesPoisons() {
return this.items.filter(item => item.type == 'maladie' || (item.type == 'poison' && item.system.active)); return this.items.filter(item => item.type == 'maladie' || (item.type == 'poison' && item.system.active));
} }

View File

@ -81,48 +81,13 @@ export class RdDBaseActorSheet extends ActorSheet {
/* -------------------------------------------- */ /* -------------------------------------------- */
static filterItemsPerTypeForSheet(formData, itemTypes) { static filterItemsPerTypeForSheet(formData, itemTypes) {
formData.blessures = Misc.arrayOrEmpty(itemTypes['blessure']); Object.values(ITEM_TYPES).forEach(t => {
formData.recettescuisine = Misc.arrayOrEmpty(itemTypes['recettecuisine']); formData[t + 's'] = Misc.arrayOrEmpty(itemTypes[t])
formData.recettesAlchimiques = Misc.arrayOrEmpty(itemTypes['recettealchimique']); })
formData.maladies = Misc.arrayOrEmpty(itemTypes['maladie']);
formData.poisons = Misc.arrayOrEmpty(itemTypes['poison']);
formData.possessions = Misc.arrayOrEmpty(itemTypes['possession']);
formData.maladiesPoisons = formData.maladies.concat(formData.poisons);
formData.competences = (itemTypes['competence'] ?? []).concat(itemTypes['competencecreature'] ?? []);
formData.sortsReserve = Misc.arrayOrEmpty(itemTypes['sortreserve']);
formData.sorts = Misc.arrayOrEmpty(itemTypes['sort']); formData.maladiesPoisons = formData.maladies.concat(formData.poisons)
formData.rencontres = Misc.arrayOrEmpty(itemTypes['rencontre']); formData.competences = formData.competences.concat(formData.competencecreatures)
formData.casestmr = Misc.arrayOrEmpty(itemTypes['casetmr']); formData.monnaies = formData.monnaies.sort(Monnaie.triValeurEntiere())
formData.signesdraconiques = Misc.arrayOrEmpty(itemTypes['signedraconique']);
formData.queues = Misc.arrayOrEmpty(itemTypes['queue']);
formData.souffles = Misc.arrayOrEmpty(itemTypes['souffle']);
formData.ombres = Misc.arrayOrEmpty(itemTypes['ombre']);
formData.tetes = Misc.arrayOrEmpty(itemTypes['tete']);
formData.taches = Misc.arrayOrEmpty(itemTypes['tache']);
formData.meditations = Misc.arrayOrEmpty(itemTypes['meditation']);
formData.chants = Misc.arrayOrEmpty(itemTypes['chant']);
formData.danses = Misc.arrayOrEmpty(itemTypes['danse']);
formData.musiques = Misc.arrayOrEmpty(itemTypes['musique']);
formData.oeuvres = Misc.arrayOrEmpty(itemTypes['oeuvre']);
formData.jeux = Misc.arrayOrEmpty(itemTypes['jeu']);
formData.services = Misc.arrayOrEmpty(itemTypes['service']);
formData.conteneurs = Misc.arrayOrEmpty(itemTypes['conteneur']);
formData.materiel = Misc.arrayOrEmpty(itemTypes['objet']);
formData.armes = Misc.arrayOrEmpty(itemTypes['arme']);
formData.armures = Misc.arrayOrEmpty(itemTypes['armure']);
formData.munitions = Misc.arrayOrEmpty(itemTypes['munition']);
formData.livres = Misc.arrayOrEmpty(itemTypes['livre']);
formData.potions = Misc.arrayOrEmpty(itemTypes['potion']);
formData.plantes = Misc.arrayOrEmpty(itemTypes['plante']);
formData.ingredients = Misc.arrayOrEmpty(itemTypes['ingredient']);
formData.faunes = Misc.arrayOrEmpty(itemTypes['faune']);
formData.herbes = Misc.arrayOrEmpty(itemTypes['herbe']);
formData.nourritureboissons = Misc.arrayOrEmpty(itemTypes['nourritureboisson']);
formData.gemmes = Misc.arrayOrEmpty(itemTypes['gemme']);
formData.monnaies = Misc.arrayOrEmpty(itemTypes['monnaie']).sort(Monnaie.triValeurEntiere());
formData.objets = Misc.arrayOrEmpty(itemTypes['objet'])
formData.inventaires = RdDItem.getItemTypesInventaire('all') formData.inventaires = RdDItem.getItemTypesInventaire('all')
.map(t => Misc.arrayOrEmpty(itemTypes[t])) .map(t => Misc.arrayOrEmpty(itemTypes[t]))

View File

@ -212,7 +212,7 @@ export class RdDTMRDialog extends Dialog {
} }
getSortsReserve(coord) { getSortsReserve(coord) {
return this.actor.itemTypes[ITEM_TYPES.sortreserve].filter(// Reserve sur une case fleuve ou normale return this.sortsReserve.filter(// Reserve sur une case fleuve ou normale
TMRUtility.getTMR(coord).type == 'fleuve' TMRUtility.getTMR(coord).type == 'fleuve'
? it => TMRUtility.getTMR(it.system.coord).type == 'fleuve' ? it => TMRUtility.getTMR(it.system.coord).type == 'fleuve'
: it => it.system.coord == coord : it => it.system.coord == coord
@ -271,8 +271,7 @@ export class RdDTMRDialog extends Dialog {
} }
_getTokensSortsReserve() { _getTokensSortsReserve() {
const sortsReserve = this.actor.itemTypes[ITEM_TYPES.sortreserve]; return Misc.concat(this.sortsReserve.map(sortReserve =>
return Misc.concat(sortsReserve.map(sortReserve =>
EffetsDraconiques.sortReserve.tokens(this.pixiTMR, sortReserve, () => sortReserve.system.coord))) EffetsDraconiques.sortReserve.tokens(this.pixiTMR, sortReserve, () => sortReserve.system.coord)))
} }
@ -908,8 +907,8 @@ export class RdDTMRDialog extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
lancerSortEnReserve(coord, sortId) { lancerSortEnReserve(coord, sortId) {
let sorts = this.getSortsReserve(coord); const sort = this.getSortsReserve(coord)
let sort = sorts.find(it => it.id == sortId); .find(it => it.id == sortId);
if (sort) { if (sort) {
this.processSortReserve(sort); this.processSortReserve(sort);
} else { } else {

View File

@ -145,7 +145,7 @@ export class RdDUtility {
'systems/foundryvtt-reve-de-dragon/templates/actor/taches.html', 'systems/foundryvtt-reve-de-dragon/templates/actor/taches.html',
'systems/foundryvtt-reve-de-dragon/templates/actor/oeuvres.html', 'systems/foundryvtt-reve-de-dragon/templates/actor/oeuvres.html',
'systems/foundryvtt-reve-de-dragon/templates/actor/oeuvre.html', 'systems/foundryvtt-reve-de-dragon/templates/actor/oeuvre.html',
'systems/foundryvtt-reve-de-dragon/templates/actor/jeux.html', 'systems/foundryvtt-reve-de-dragon/templates/actor/jeus.hbs',
'systems/foundryvtt-reve-de-dragon/templates/actor/alchimie.html', 'systems/foundryvtt-reve-de-dragon/templates/actor/alchimie.html',
'systems/foundryvtt-reve-de-dragon/templates/actor/astrologie.html', 'systems/foundryvtt-reve-de-dragon/templates/actor/astrologie.html',
'systems/foundryvtt-reve-de-dragon/templates/actor/chirurgie.html', 'systems/foundryvtt-reve-de-dragon/templates/actor/chirurgie.html',
@ -160,17 +160,17 @@ export class RdDUtility {
'systems/foundryvtt-reve-de-dragon/templates/actor/hr-sorts.html', 'systems/foundryvtt-reve-de-dragon/templates/actor/hr-sorts.html',
'systems/foundryvtt-reve-de-dragon/templates/actor/hr-sorts-reserve.html', 'systems/foundryvtt-reve-de-dragon/templates/actor/hr-sorts-reserve.html',
'systems/foundryvtt-reve-de-dragon/templates/actor/hr-meditations.html', 'systems/foundryvtt-reve-de-dragon/templates/actor/hr-meditations.html',
'systems/foundryvtt-reve-de-dragon/templates/actor/hr-casestmr.html', 'systems/foundryvtt-reve-de-dragon/templates/actor/hr-casetmrs.hbs',
'systems/foundryvtt-reve-de-dragon/templates/actor/xp-journal.html', 'systems/foundryvtt-reve-de-dragon/templates/actor/xp-journal.html',
'systems/foundryvtt-reve-de-dragon/templates/actor/editor-notes-mj.html', 'systems/foundryvtt-reve-de-dragon/templates/actor/editor-notes-mj.html',
'systems/foundryvtt-reve-de-dragon/templates/actor/inventaire.html', 'systems/foundryvtt-reve-de-dragon/templates/actor/inventaire.html',
'systems/foundryvtt-reve-de-dragon/templates/actor/inventaire-item.html', 'systems/foundryvtt-reve-de-dragon/templates/actor/inventaire-item.hbs',
"systems/foundryvtt-reve-de-dragon/templates/actor/inventaire-monnaie.html", "systems/foundryvtt-reve-de-dragon/templates/actor/inventaire-monnaie.html",
'systems/foundryvtt-reve-de-dragon/templates/actor/liens-animaux.hbs', 'systems/foundryvtt-reve-de-dragon/templates/actor/liens-animaux.hbs',
'systems/foundryvtt-reve-de-dragon/templates/actor/liens-suivants.hbs', 'systems/foundryvtt-reve-de-dragon/templates/actor/liens-suivants.hbs',
'systems/foundryvtt-reve-de-dragon/templates/actor/liens-vehicules.hbs', 'systems/foundryvtt-reve-de-dragon/templates/actor/liens-vehicules.hbs',
'systems/foundryvtt-reve-de-dragon/templates/actor/commerce-inventaire.html', 'systems/foundryvtt-reve-de-dragon/templates/actor/commerce-inventaire.html',
'systems/foundryvtt-reve-de-dragon/templates/actor/commerce-inventaire-item.html', 'systems/foundryvtt-reve-de-dragon/templates/actor/commerce-inventaire-item.hbs',
//Items //Items
'systems/foundryvtt-reve-de-dragon/templates/scripts/autocomplete-script.hbs', 'systems/foundryvtt-reve-de-dragon/templates/scripts/autocomplete-script.hbs',
'systems/foundryvtt-reve-de-dragon/templates/scripts/autocomplete.hbs', 'systems/foundryvtt-reve-de-dragon/templates/scripts/autocomplete.hbs',
@ -436,8 +436,8 @@ export class RdDUtility {
}; };
if (!optionsArbre.templateItem) { if (!optionsArbre.templateItem) {
optionsArbre.templateItem = item.parent?.type == 'commerce' optionsArbre.templateItem = item.parent?.type == 'commerce'
? "systems/foundryvtt-reve-de-dragon/templates/actor/commerce-inventaire-item.html" ? "systems/foundryvtt-reve-de-dragon/templates/actor/commerce-inventaire-item.hbs"
: "systems/foundryvtt-reve-de-dragon/templates/actor/inventaire-item.html"; : "systems/foundryvtt-reve-de-dragon/templates/actor/inventaire-item.hbs";
} }
item.niveau = optionsArbre.profondeur; item.niveau = optionsArbre.profondeur;
} }

View File

@ -122,7 +122,7 @@
{{> "systems/foundryvtt-reve-de-dragon/templates/actor/taches.html"}} {{> "systems/foundryvtt-reve-de-dragon/templates/actor/taches.html"}}
{{> "systems/foundryvtt-reve-de-dragon/templates/actor/chirurgie.html"}} {{> "systems/foundryvtt-reve-de-dragon/templates/actor/chirurgie.html"}}
{{> "systems/foundryvtt-reve-de-dragon/templates/actor/oeuvres.html"}} {{> "systems/foundryvtt-reve-de-dragon/templates/actor/oeuvres.html"}}
{{> "systems/foundryvtt-reve-de-dragon/templates/actor/jeux.html"}} {{> "systems/foundryvtt-reve-de-dragon/templates/actor/jeus.hbs"}}
{{> "systems/foundryvtt-reve-de-dragon/templates/actor/alchimie.html"}} {{> "systems/foundryvtt-reve-de-dragon/templates/actor/alchimie.html"}}
</div> </div>
{{/if}} {{/if}}

View File

@ -1,7 +1,7 @@
{{#if recettesAlchimiques.length}} {{#if recettealchimiques.length}}
<h3>Recettes Alchimiques</h3> <h3>Recettes Alchimiques</h3>
<ul class="item-list alterne-list"> <ul class="item-list alterne-list">
{{#each (trier recettesAlchimiques) as |recette id|}} {{#each (trier recettealchimiques) as |recette id|}}
<li class="item flexrow list-item" data-item-id="{{recette._id}}"><span class="competence-title recette-label item-edit"><a>{{recette.name}}</a></span> <li class="item flexrow list-item" data-item-id="{{recette._id}}"><span class="competence-title recette-label item-edit"><a>{{recette.name}}</a></span>
<div class="item-controls"> <div class="item-controls">
<a class="item-edit" data-tooltip="Modifier"><i class="fas fa-edit"></i></a> <a class="item-edit" data-tooltip="Modifier"><i class="fas fa-edit"></i></a>

View File

@ -33,4 +33,4 @@
{{> "systems/foundryvtt-reve-de-dragon/templates/actor/hr-sorts.html"}} {{> "systems/foundryvtt-reve-de-dragon/templates/actor/hr-sorts.html"}}
{{> "systems/foundryvtt-reve-de-dragon/templates/actor/hr-sorts-reserve.html"}} {{> "systems/foundryvtt-reve-de-dragon/templates/actor/hr-sorts-reserve.html"}}
{{> "systems/foundryvtt-reve-de-dragon/templates/actor/hr-meditations.html"}} {{> "systems/foundryvtt-reve-de-dragon/templates/actor/hr-meditations.html"}}
{{> "systems/foundryvtt-reve-de-dragon/templates/actor/hr-casestmr.html"}} {{> "systems/foundryvtt-reve-de-dragon/templates/actor/hr-casetmrs.hbs"}}

View File

@ -1,7 +1,7 @@
{{#if casestmr.length}} {{#if casetmrs.length}}
<h3>Effets sur les cases des TMR</h3> <h3>Effets sur les cases des TMR</h3>
<ul class="item-list alterne-list"> <ul class="item-list alterne-list">
{{#each casestmr as |casetmr key|}} {{#each casetmrs as |casetmr key|}}
<li class="item list-item flexrow" data-item-id="{{casetmr.id}}" data-attribute="{{key}}" data-tooltip="Case TMR: {{casetmr.name}}" > <li class="item list-item flexrow" data-item-id="{{casetmr.id}}" data-attribute="{{key}}" data-tooltip="Case TMR: {{casetmr.name}}" >
<img class="sheet-competence-img" src="{{casetmr.img}}"/> <img class="sheet-competence-img" src="{{casetmr.img}}"/>
<span class="item-edit"><a>{{casetmr.name}}</a></span> <span class="item-edit"><a>{{casetmr.name}}</a></span>

View File

@ -1,7 +1,7 @@
{{#if (and options.isGM signesdraconiques.length)}} {{#if (and options.isGM signedraconiques.length)}}
<h3>Signes draconiques</h3> <h3>Signes draconiques</h3>
<ul class="item-list alterne-list"> <ul class="item-list alterne-list">
{{#each signesdraconiques as |signe key|}} {{#each signedraconiques as |signe key|}}
<li class="item list-item flexrow" data-item-id="{{signe._id}}" data-attribute="{{key}}" data-tooltip="Signe: {{signe.name}}"> <li class="item list-item flexrow" data-item-id="{{signe._id}}" data-attribute="{{key}}" data-tooltip="Signe: {{signe.name}}">
<img class="sheet-competence-img" src="{{signe.img}}"/> <img class="sheet-competence-img" src="{{signe.img}}"/>
<span class="item-edit flex-grow"><a>{{signe.name}}</a></span> <span class="item-edit flex-grow"><a>{{signe.name}}</a></span>

View File

@ -1,10 +1,10 @@
{{#if sortsReserve.length}} {{#if sortreserves.length}}
<h3>Sorts en Réserve{{#if options.isGM}} <a class="sortreserve-add"> <h3>Sorts en Réserve{{#if options.isGM}} <a class="sortreserve-add">
<i class="fa-solid fa-sparkles"></i> <i class="fa-solid fa-sparkles"></i>
</a>{{/if}} </a>{{/if}}
</h3> </h3>
<ul class="item-list alterne-list"> <ul class="item-list alterne-list">
{{#each (trier sortsReserve) as |sort key|}} {{#each (trier sortreserves) as |sort key|}}
<li class="item list-item flexrow" data-item-id="{{sort._id}}" data-attribute="{{key}}" <li class="item list-item flexrow" data-item-id="{{sort._id}}" data-attribute="{{key}}"
data-tooltip="Sort en réserve: {{sort.system.coord}} - {{sort.name}} r{{sort.system.ptreve}}"> data-tooltip="Sort en réserve: {{sort.system.coord}} - {{sort.name}} r{{sort.system.ptreve}}">
<img class="sheet-competence-img" src="{{sort.img}}"/> <img class="sheet-competence-img" src="{{sort.img}}"/>

View File

@ -30,7 +30,8 @@
{{/if}} {{/if}}
</span> </span>
<span class="equipement-detail">{{numberFormat item.system.encTotal decimals=2}}</span> <span class="equipement-detail">{{numberFormat item.system.encTotal decimals=2}}</span>
<span class="equipement-actions item-controls"> {{>'systems/foundryvtt-reve-de-dragon/templates/actor/item-action-controls.hbs' item=item options=options}}
{{!-- <span class="equipement-actions item-controls">
{{#if options.isOwner}} {{#if options.isOwner}}
{{#unless item.estContenu}} {{#unless item.estContenu}}
{{#if item.equipable}} {{#if item.equipable}}
@ -50,7 +51,7 @@
<a class="item-action">{{item.system.actionPrincipale}}</a> <a class="item-action">{{item.system.actionPrincipale}}</a>
{{/if}} {{/if}}
{{/if}} {{/if}}
</span> </span> --}}
</li> </li>
{{/if}} {{/if}}
{{/unless}} {{/unless}}

View File

@ -1,7 +1,7 @@
{{#if jeux.length}} {{#if jeus.length}}
<h3>Jeux :</h3> <h3>Jeux :</h3>
<ul class="item-list alterne-list"> <ul class="item-list alterne-list">
{{#each jeux as |jeu id|}} {{#each jeus as |jeu id|}}
<li class="item flexrow list-item" data-item-id="{{jeu._id}}"> <li class="item flexrow list-item" data-item-id="{{jeu._id}}">
<span class="competence-title jeu-label"><a>{{jeu.name}} (base {{jeu.system.base}})</a></span> <span class="competence-title jeu-label"><a>{{jeu.name}} (base {{jeu.system.base}})</a></span>
<div class="item-controls"> <div class="item-controls">

View File

@ -12,7 +12,7 @@
{{#each (trier oeuvres) as |oeuvre id|}} {{#each (trier oeuvres) as |oeuvre id|}}
{{> "systems/foundryvtt-reve-de-dragon/templates/actor/oeuvre.html" oeuvre=oeuvre typeOeuvre=oeuvre.system.competence classOeuvre="oeuvre-label"}} {{> "systems/foundryvtt-reve-de-dragon/templates/actor/oeuvre.html" oeuvre=oeuvre typeOeuvre=oeuvre.system.competence classOeuvre="oeuvre-label"}}
{{/each}} {{/each}}
{{#each (trier recettescuisine) as |recette id|}} {{#each (trier recettecuisines) as |recette id|}}
{{> "systems/foundryvtt-reve-de-dragon/templates/actor/oeuvre.html" oeuvre=recette typeOeuvre="Recette de cuisine" classOeuvre="recettecuisine-label"}} {{> "systems/foundryvtt-reve-de-dragon/templates/actor/oeuvre.html" oeuvre=recette typeOeuvre="Recette de cuisine" classOeuvre="recettecuisine-label"}}
{{/each}} {{/each}}
</ul> </ul>