Amélioration de recherches

This commit is contained in:
Vincent Vandemeulebrouck 2023-01-15 15:54:40 +01:00
parent 0aba6d2f0a
commit 0d5c8e5304
8 changed files with 50 additions and 28 deletions

View File

@ -1617,7 +1617,7 @@ export class RdDActor extends RdDBaseActor {
} }
async actionNourritureboisson(item, onActionItem) { async actionNourritureboisson(item, onActionItem) {
switch (item.isComestible()) { switch (item.getUtilisationCuisine()) {
case 'brut': { case 'brut': {
let d = new Dialog({ let d = new Dialog({
title: "Nourriture brute", title: "Nourriture brute",
@ -1678,7 +1678,7 @@ export class RdDActor extends RdDBaseActor {
return; return;
} }
const item = this.getItem(itemId) const item = this.getItem(itemId)
if (!item.isComestible()) { if (!item.getUtilisationCuisine()) {
return; return;
} }
if (choix.doses > item.system.quantite) { if (choix.doses > item.system.quantite) {
@ -2502,7 +2502,7 @@ export class RdDActor extends RdDBaseActor {
} }
async preparerNourriture(item) { async preparerNourriture(item) {
if (item.isComestible() == 'brut') { if (item.getUtilisationCuisine() == 'brut') {
const nourriture = { const nourriture = {
name: 'Plat de ' + item.name, name: 'Plat de ' + item.name,
type: 'recettecuisine', type: 'recettecuisine',

View File

@ -21,9 +21,11 @@ const ITEM_ENVIRONNEMENT_TYPES = [
] ]
export class Environnement { export class Environnement {
static typesEnvironnement() { static typesEnvironnement() {
return ITEM_ENVIRONNEMENT_TYPES return ITEM_ENVIRONNEMENT_TYPES
} }
static init() { static init() {
game.settings.register(SYSTEM_RDD, SETTINGS_LISTE_MILIEUX, { game.settings.register(SYSTEM_RDD, SETTINGS_LISTE_MILIEUX, {
name: "Liste des milieux proposés", name: "Liste des milieux proposés",

View File

@ -101,7 +101,7 @@ export class RdDItemSheet extends ItemSheet {
isSoins: false, isSoins: false,
description: await TextEditor.enrichHTML(this.item.system.description, { async: true }), description: await TextEditor.enrichHTML(this.item.system.description, { async: true }),
descriptionmj: await TextEditor.enrichHTML(this.item.system.descriptionmj, { async: true }), descriptionmj: await TextEditor.enrichHTML(this.item.system.descriptionmj, { async: true }),
isComestible: this.item.isComestible() isComestible: this.item.getUtilisationCuisine()
} }
const competences = await SystemCompendiums.getCompetences(this.actor?.type); const competences = await SystemCompendiums.getCompetences(this.actor?.type);

View File

@ -258,14 +258,36 @@ export class RdDItem extends Item {
console.log(`${this.actor.name}: l'objet ${this.name} a expiré et été supprimé`); console.log(`${this.actor.name}: l'objet ${this.name} a expiré et été supprimé`);
await this.actor?.deleteEmbeddedDocuments('Item', [this.id]); await this.actor?.deleteEmbeddedDocuments('Item', [this.id]);
} }
getUtilisation() {
isComestible() {
switch (this.type) { switch (this.type) {
case 'nourritureboisson': return 'pret'; case 'nourritureboisson':
return 'cuisine';
case 'herbe': case 'herbe':
return this.system.categorie == 'Cuisine' && this.system.sust > 0 ? 'brut' : '';
case 'faune': case 'faune':
return this.system.sust > 0 ? 'brut' : ''; case 'ingredient':
case 'plante':
switch (this.system.categorie) {
case 'Cuisine': return 'cuisine';
case 'Toxique':
case 'Poison': return 'poison';
case 'Alchimie': return 'alchimie'
case 'Soin': case 'Repos': return 'soins'
}
return this.system.sust > 0 ? 'cuisine' : '';
}
return '';
}
getUtilisationCuisine() {
if (this.getUtilisation() == 'cuisine') {
switch (this.type) {
case 'nourritureboisson':
return 'pret';
case 'herbe':
case 'faune':
case 'ingredient':
case 'plante':
return 'brut';
}
} }
return ''; return '';
} }
@ -355,7 +377,7 @@ export class RdDItem extends Item {
} }
if (this.actor?.isPersonnage()) { if (this.actor?.isPersonnage()) {
const warn = options.warnIfNot; const warn = options.warnIfNot;
if (this.isComestible() == 'brut') { if (this.getUtilisationCuisine() == 'brut') {
return 'Utiliser'; return 'Utiliser';
} }
switch (this.type) { switch (this.type) {
@ -404,7 +426,7 @@ export class RdDItem extends Item {
} }
async onCreateDecoupeComestible(actor) { async onCreateDecoupeComestible(actor) {
if (actor && this.isComestible() == 'brut' && this.system.sust != 1) { if (actor && this.getUtilisationCuisine() == 'brut' && this.system.sust != 1) {
if (this.system.sust < 1) { if (this.system.sust < 1) {
await actor.updateEmbeddedDocuments('Item', [{ await actor.updateEmbeddedDocuments('Item', [{
_id: this.id, _id: this.id,
@ -425,7 +447,7 @@ export class RdDItem extends Item {
} }
async empiler(item) { async empiler(item) {
if (this.isComestible() == 'brut') { if (this.getUtilisationCuisine() == 'brut') {
const sust = this.system.sust + item.system.sust; const sust = this.system.sust + item.system.sust;
const encombrement = this.system.encombrement + item.system.encombrement; const encombrement = this.system.encombrement + item.system.encombrement;
await this.update({ await this.update({
@ -477,7 +499,7 @@ export class RdDItem extends Item {
} }
else { else {
const excludedProperties = ['quantite', 'cout', 'encTotal', 'environnement']; const excludedProperties = ['quantite', 'cout', 'encTotal', 'environnement'];
if (this.isComestible()) { if (this.getUtilisationCuisine()) {
excludedProperties.push('sust', 'encombrement'); excludedProperties.push('sust', 'encombrement');
} }
let differences = Object.entries(this.system) let differences = Object.entries(this.system)

View File

@ -16,18 +16,18 @@ const FILTER_GROUPS = [
] ]
const FILTERS = [ const FILTERS = [
{ group: 'comestible', code: 'pret', label: 'Comestible', check: item => item.isComestible() == 'pret' }, { group: 'comestible', code: 'pret', label: 'Préparé', check: item => item.getUtilisationCuisine() == 'pret' },
{ group: 'comestible', code: 'alcool', label: 'Alcool', check: item => item.isAlcool() }, { group: 'comestible', code: 'comestible', label: 'Comestible', check: item => item.getUtilisation() == 'cuisine' },
{ group: 'comestible', code: 'boisson', label: 'Boisson', check: item => item.isNourritureBoisson() && item.system.boisson }, { group: 'comestible', code: 'boisson', label: 'Boisson', check: item => item.isNourritureBoisson() && item.system.boisson },
{ group: 'comestible', code: 'brut', label: 'A préparer', check: item => item.isComestible() == 'brut' }, { group: 'comestible', code: 'alcool', label: 'Alcool', check: item => item.isAlcool() },
{ group: 'comestible', code: 'poison', label: 'Toxique', check: item => item.isComestible() == 'poison' }, { group: 'comestible', code: 'brut', label: 'A préparer', check: item => item.getUtilisationCuisine() == 'brut' },
{ group: 'comestible', code: 'non', label: 'Immangeable', check: item => !item.isComestible() || item.isComestible() == '' }, { group: 'comestible', code: 'non', label: 'Immangeable', check: item => item.isEnvironnement() && !item.getUtilisationCuisine() },
{ group: 'categorie', code: 'alchimie', label: 'Alchimique', check: item => item.isEnvironnement() && item.system.categorie == 'Alchimie' }, { group: 'categorie', code: 'alchimie', label: 'Alchimique', check: item => item.isEnvironnement() && item.getUtilisation() == 'alchimie' },
{ group: 'categorie', code: 'cuisine', label: 'Cuisine', check: item => item.isEnvironnement() && item.system.categorie == 'Cuisine' }, { group: 'categorie', code: 'cuisine', label: 'Cuisine', check: item => item.isEnvironnement() && item.getUtilisation() == 'cuisine' },
{ group: 'categorie', code: 'repos', label: 'Repos', check: item => item.isEnvironnement() && item.system.categorie == 'Repos' }, { group: 'categorie', code: 'soins', label: 'Médical', check: item => item.isEnvironnement() && item.getUtilisation() == 'soins' },
{ group: 'categorie', code: 'soins', label: 'Soins', check: item => item.isEnvironnement() && item.system.categorie == 'Soin' }, { group: 'categorie', code: 'cpoison', label: 'Toxique', check: item => item.isEnvironnement() && item.getUtilisation() == 'poison' },
{ group: 'categorie', code: 'autres', label: 'Autres', check: item => !item.isEnvironnement() || ['', 'Autre'].includes(item.system.categorie) }, { group: 'categorie', code: 'autres', label: 'Autres', check: item => !item.isEnvironnement() || item.getUtilisation() == '' },
{ group: "qualite", code: "mauvaise", label: "Mauvaise (négative)", check: item => item.isInventaire() && item.system.qualite < 0 }, { group: "qualite", code: "mauvaise", label: "Mauvaise (négative)", check: item => item.isInventaire() && item.system.qualite < 0 },
{ group: "qualite", code: "quelconque", label: "Quelconque (0)", check: item => item.isInventaire() && item.system.qualite == 0 }, { group: "qualite", code: "quelconque", label: "Quelconque (0)", check: item => item.isInventaire() && item.system.qualite == 0 },

View File

@ -3,4 +3,6 @@
<option value="Cuisine">Cuisine</option> <option value="Cuisine">Cuisine</option>
<option value="Repos">Repos</option> <option value="Repos">Repos</option>
<option value="Soin">Soin</option> <option value="Soin">Soin</option>
<option value="Poison">Poison/Vénéneux</option>
<option value="Toxique">Urticant/Venimeux</option>
<option value="Autre">Autre</option> <option value="Autre">Autre</option>

View File

@ -33,12 +33,10 @@
<label for="system.sust">Sustentation</label> <label for="system.sust">Sustentation</label>
<input class="attribute-value" type="number" name="system.sust" value="{{system.sust}}" data-dtype="Number" min="0"/> <input class="attribute-value" type="number" name="system.sust" value="{{system.sust}}" data-dtype="Number" min="0"/>
</div> </div>
{{#if (gt system.sust 0)}}
<div class="form-group"> <div class="form-group">
<label for="system.exotisme">Exotisme</label> <label for="system.exotisme">Exotisme</label>
<input class="attribute-value" type="number" name="system.exotisme" value="{{system.exotisme}}" data-dtype="Number" min="-10" max="0"/> <input class="attribute-value" type="number" name="system.exotisme" value="{{system.exotisme}}" data-dtype="Number" min="-10" max="0"/>
</div> </div>
{{/if}}
{{else}} {{else}}
<div class="form-group"> <div class="form-group">
<label>Niveau (si applicable)</label> <label>Niveau (si applicable)</label>

View File

@ -33,12 +33,10 @@
<label for="system.sust">Sustentation</label> <label for="system.sust">Sustentation</label>
<input class="attribute-value" type="number" name="system.sust" value="{{system.sust}}" data-dtype="Number" min="0"/> <input class="attribute-value" type="number" name="system.sust" value="{{system.sust}}" data-dtype="Number" min="0"/>
</div> </div>
{{#if (gt system.sust 0)}}
<div class="form-group"> <div class="form-group">
<label for="system.exotisme">Exotisme</label> <label for="system.exotisme">Exotisme</label>
<input class="attribute-value" type="number" name="system.exotisme" value="{{system.exotisme}}" data-dtype="Number" min="-10" max="0"/> <input class="attribute-value" type="number" name="system.exotisme" value="{{system.exotisme}}" data-dtype="Number" min="-10" max="0"/>
</div> </div>
{{/if}}
{{else}} {{else}}
<div class="form-group"> <div class="form-group">
<label>Niveau (si applicable)</label> <label>Niveau (si applicable)</label>