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) {
const maladiesPoisons = this.getMaladiePoisons();
const maladiesPoisons = this.getMaladiesPoisons();
const isMaladeEmpoisonne = maladiesPoisons.length > 0;
this._messageRecuperationMaladiePoisons(maladiesPoisons, message);
@ -248,7 +248,7 @@ export class RdDActor extends RdDBaseActorSang {
await this._recupererVie(message, isMaladeEmpoisonne);
}
getMaladiePoisons() {
getMaladiesPoisons() {
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) {
formData.blessures = Misc.arrayOrEmpty(itemTypes['blessure']);
formData.recettescuisine = Misc.arrayOrEmpty(itemTypes['recettecuisine']);
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']);
Object.values(ITEM_TYPES).forEach(t => {
formData[t + 's'] = Misc.arrayOrEmpty(itemTypes[t])
})
formData.sorts = Misc.arrayOrEmpty(itemTypes['sort']);
formData.rencontres = Misc.arrayOrEmpty(itemTypes['rencontre']);
formData.casestmr = Misc.arrayOrEmpty(itemTypes['casetmr']);
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.maladiesPoisons = formData.maladies.concat(formData.poisons)
formData.competences = formData.competences.concat(formData.competencecreatures)
formData.monnaies = formData.monnaies.sort(Monnaie.triValeurEntiere())
formData.inventaires = RdDItem.getItemTypesInventaire('all')
.map(t => Misc.arrayOrEmpty(itemTypes[t]))

View File

@ -212,7 +212,7 @@ export class RdDTMRDialog extends Dialog {
}
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'
? it => TMRUtility.getTMR(it.system.coord).type == 'fleuve'
: it => it.system.coord == coord
@ -271,8 +271,7 @@ export class RdDTMRDialog extends Dialog {
}
_getTokensSortsReserve() {
const sortsReserve = this.actor.itemTypes[ITEM_TYPES.sortreserve];
return Misc.concat(sortsReserve.map(sortReserve =>
return Misc.concat(this.sortsReserve.map(sortReserve =>
EffetsDraconiques.sortReserve.tokens(this.pixiTMR, sortReserve, () => sortReserve.system.coord)))
}
@ -908,8 +907,8 @@ export class RdDTMRDialog extends Dialog {
/* -------------------------------------------- */
lancerSortEnReserve(coord, sortId) {
let sorts = this.getSortsReserve(coord);
let sort = sorts.find(it => it.id == sortId);
const sort = this.getSortsReserve(coord)
.find(it => it.id == sortId);
if (sort) {
this.processSortReserve(sort);
} 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/oeuvres.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/astrologie.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-reserve.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/editor-notes-mj.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/liens-animaux.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/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
'systems/foundryvtt-reve-de-dragon/templates/scripts/autocomplete-script.hbs',
'systems/foundryvtt-reve-de-dragon/templates/scripts/autocomplete.hbs',
@ -436,8 +436,8 @@ export class RdDUtility {
};
if (!optionsArbre.templateItem) {
optionsArbre.templateItem = item.parent?.type == 'commerce'
? "systems/foundryvtt-reve-de-dragon/templates/actor/commerce-inventaire-item.html"
: "systems/foundryvtt-reve-de-dragon/templates/actor/inventaire-item.html";
? "systems/foundryvtt-reve-de-dragon/templates/actor/commerce-inventaire-item.hbs"
: "systems/foundryvtt-reve-de-dragon/templates/actor/inventaire-item.hbs";
}
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/chirurgie.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"}}
</div>
{{/if}}

View File

@ -1,7 +1,7 @@
{{#if recettesAlchimiques.length}}
{{#if recettealchimiques.length}}
<h3>Recettes Alchimiques</h3>
<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>
<div class="item-controls">
<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-reserve.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>
<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}}" >
<img class="sheet-competence-img" src="{{casetmr.img}}"/>
<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>
<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}}">
<img class="sheet-competence-img" src="{{signe.img}}"/>
<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">
<i class="fa-solid fa-sparkles"></i>
</a>{{/if}}
</h3>
<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}}"
data-tooltip="Sort en réserve: {{sort.system.coord}} - {{sort.name}} r{{sort.system.ptreve}}">
<img class="sheet-competence-img" src="{{sort.img}}"/>

View File

@ -30,7 +30,8 @@
{{/if}}
</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}}
{{#unless item.estContenu}}
{{#if item.equipable}}
@ -50,7 +51,7 @@
<a class="item-action">{{item.system.actionPrincipale}}</a>
{{/if}}
{{/if}}
</span>
</span> --}}
</li>
{{/if}}
{{/unless}}

View File

@ -1,7 +1,7 @@
{{#if jeux.length}}
{{#if jeus.length}}
<h3>Jeux :</h3>
<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}}">
<span class="competence-title jeu-label"><a>{{jeu.name}} (base {{jeu.system.base}})</a></span>
<div class="item-controls">

View File

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