diff --git a/module/actor.js b/module/actor.js index b4bfe9c4..4d9a82ae 100644 --- a/module/actor.js +++ b/module/actor.js @@ -1424,6 +1424,15 @@ export class RdDActor extends Actor { } } + /* -------------------------------------------- */ + async actionRefoulement(item) { + const refoulement = item?.system.refoulement ?? 0; + if (refoulement>0){ + await this.ajouterRefoulement(refoulement); + await item.delete(); + } + } + /* -------------------------------------------- */ async ajouterRefoulement(value = 1) { let refoulement = this.system.reve.refoulement.value + value; @@ -1924,6 +1933,7 @@ export class RdDActor extends Actor { } return; } + case 'queue': case 'ombre': return await this.actionRefoulement(item); } } diff --git a/module/item.js b/module/item.js index f83cf913..7f9003d8 100644 --- a/module/item.js +++ b/module/item.js @@ -145,24 +145,28 @@ export class RdDItem extends Item { } getActionPrincipale(options = { warnIfNot: true }) { - if (!this.isConteneur() && (this.system.quantite ?? 0) <= 0) { - if (options.warnIfNot) { + const warn = options.warnIfNot; + switch (this.type) { + case 'nourritureboisson': return this._actionOrWarnQuantiteZero(this.boisson ? 'Boire' : 'Manger', warn); + case 'potion': return this._actionOrWarnQuantiteZero('Boire', warn); + case 'livre': return this._actionOrWarnQuantiteZero('Lire', warn); + case 'conteneur': return this._actionOrWarnQuantiteZero('Ouvrir', warn); + case 'herbe': return this.isHerbeAPotion() ? this._actionOrWarnQuantiteZero('Décoction', warn) : undefined; + case 'queue': case 'ombre': return this.system.refoulement>0 ? 'Refouler' : undefined; + } + return undefined; + } + + _actionOrWarnQuantiteZero(actionName, warn){ + if ((this.system.quantite ?? 0) <= 0) { + if (warn) { ui.notifications.warn(`Vous n'avez plus de ${this.name}.`); } return undefined; } - switch (this.type) { - case 'nourritureboisson': return this.boisson ? 'Boire' : 'Manger'; - case 'potion': return 'Boire'; - case 'livre': return 'Lire'; - case 'conteneur': return 'Ouvrir'; + else { + return actionName; } - if (this.isHerbeAPotion()) { return 'Décoction'; } - if (options.warnIfNot) { - ui.notifications.warn(`Impossible d'utiliser un ${this.name}, aucune action associée définie.`); - } - - return undefined; } async diminuerQuantite(nombre, options = { diminuerQuantite: true, supprimerSiZero: false }) { diff --git a/module/rdd-utility.js b/module/rdd-utility.js index 04bcb0c9..29cdb219 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -121,8 +121,10 @@ export class RdDUtility { 'systems/foundryvtt-reve-de-dragon/templates/actor-sheet-oeuvre-partial.html', 'systems/foundryvtt-reve-de-dragon/templates/actor-liste-blessures-partial.html', 'systems/foundryvtt-reve-de-dragon/templates/actor-blessure-partial.html', + 'systems/foundryvtt-reve-de-dragon/templates/actor-sheet-queues.html', // Conteneur/item in Actor sheet 'systems/foundryvtt-reve-de-dragon/templates/actor-sheet-inventaire.html', + 'systems/foundryvtt-reve-de-dragon/templates/actor-sheet-item-queue.html', 'systems/foundryvtt-reve-de-dragon/templates/actor-sheet-inventaire-item.html', "systems/foundryvtt-reve-de-dragon/templates/actor-sheet-inventaire-monnaie.html", 'systems/foundryvtt-reve-de-dragon/templates/actor-sheet-liens-animaux.html', diff --git a/templates/actor-sheet-item-queue.html b/templates/actor-sheet-item-queue.html new file mode 100644 index 00000000..bd4fdf74 --- /dev/null +++ b/templates/actor-sheet-item-queue.html @@ -0,0 +1,9 @@ +