Amélioration de recherches
This commit is contained in:
@ -258,14 +258,36 @@ export class RdDItem extends Item {
|
||||
console.log(`${this.actor.name}: l'objet ${this.name} a expiré et été supprimé`);
|
||||
await this.actor?.deleteEmbeddedDocuments('Item', [this.id]);
|
||||
}
|
||||
|
||||
isComestible() {
|
||||
getUtilisation() {
|
||||
switch (this.type) {
|
||||
case 'nourritureboisson': return 'pret';
|
||||
case 'nourritureboisson':
|
||||
return 'cuisine';
|
||||
case 'herbe':
|
||||
return this.system.categorie == 'Cuisine' && this.system.sust > 0 ? 'brut' : '';
|
||||
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 '';
|
||||
}
|
||||
@ -355,7 +377,7 @@ export class RdDItem extends Item {
|
||||
}
|
||||
if (this.actor?.isPersonnage()) {
|
||||
const warn = options.warnIfNot;
|
||||
if (this.isComestible() == 'brut') {
|
||||
if (this.getUtilisationCuisine() == 'brut') {
|
||||
return 'Utiliser';
|
||||
}
|
||||
switch (this.type) {
|
||||
@ -404,7 +426,7 @@ export class RdDItem extends Item {
|
||||
}
|
||||
|
||||
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) {
|
||||
await actor.updateEmbeddedDocuments('Item', [{
|
||||
_id: this.id,
|
||||
@ -425,7 +447,7 @@ export class RdDItem extends Item {
|
||||
}
|
||||
|
||||
async empiler(item) {
|
||||
if (this.isComestible() == 'brut') {
|
||||
if (this.getUtilisationCuisine() == 'brut') {
|
||||
const sust = this.system.sust + item.system.sust;
|
||||
const encombrement = this.system.encombrement + item.system.encombrement;
|
||||
await this.update({
|
||||
@ -477,7 +499,7 @@ export class RdDItem extends Item {
|
||||
}
|
||||
else {
|
||||
const excludedProperties = ['quantite', 'cout', 'encTotal', 'environnement'];
|
||||
if (this.isComestible()) {
|
||||
if (this.getUtilisationCuisine()) {
|
||||
excludedProperties.push('sust', 'encombrement');
|
||||
}
|
||||
let differences = Object.entries(this.system)
|
||||
|
Reference in New Issue
Block a user