Les conteneurs ouverts sont mis à jour
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { ACTOR_TYPES } from "../constants.js"
|
||||
import { ACTOR_TYPES, ITEM_TYPES } from "../constants.js"
|
||||
import { Misc } from "../misc.js"
|
||||
import { RdDSheetUtility } from "../rdd-sheet-utility.js"
|
||||
import { RdDUtility } from "../rdd-utility.js"
|
||||
@@ -11,33 +11,35 @@ import { RdDUtility } from "../rdd-utility.js"
|
||||
const _SPACEHOLDER = { placeholder: true }
|
||||
|
||||
const _VENDRE = {
|
||||
code: 'item-vendre', label: 'Vendre ou donner', icon: it => 'fa-solid fa-comments-dollar',
|
||||
code: 'item-vendre', label: 'Vendre ou donner', icon: 'fa-solid fa-comments-dollar',
|
||||
filter: it => Misc.toInt(it.system.quantite) > 0 || it.parent?.type == ACTOR_TYPES.commerce,
|
||||
action: (item, actor) => item.proposerVente()
|
||||
}
|
||||
const _ACHETER = {
|
||||
code: 'item-acheter', label: 'Acheter', icon: it => 'fa-regular fa-coins',
|
||||
code: 'item-acheter', label: 'Acheter', icon: 'fa-regular fa-coins',
|
||||
filter: it => it.parent?.type == ACTOR_TYPES.commerce,
|
||||
allowLimited: true,
|
||||
action: (item, actor) => actor.vente(item)
|
||||
}
|
||||
const _MONTRER = {
|
||||
code: 'item-montrer', label: 'Montrer', icon: it => 'fa-solid fa-comment',
|
||||
code: 'item-montrer', label: 'Montrer', icon: 'fa-solid fa-comment',
|
||||
allowLimited: true,
|
||||
action: (item, actor) => item.postItemToChat()
|
||||
}
|
||||
const _SPLIT = {
|
||||
code: 'item-split', label: 'Séparer le goupe', icon: it => 'fa-solid fa-unlink',
|
||||
code: 'item-split', label: 'Séparer le goupe', icon: 'fa-solid fa-unlink',
|
||||
filter: it => Misc.toInt(it.system.quantite) > 1 && it.parent?.type != ACTOR_TYPES.commerce,
|
||||
action: (item, actor) => RdDSheetUtility.splitItem(item, actor)
|
||||
}
|
||||
|
||||
const _EDIT = {
|
||||
code: 'item-edit', label: 'Editer', icon: it => 'fa-solid fa-edit',
|
||||
code: 'item-edit', label: it => it.type == ITEM_TYPES.conteneur ? 'Ouvrir' : 'Editer',
|
||||
icon: 'fa-solid fa-edit',
|
||||
action: (item, actor) => item.sheet.render(true)
|
||||
}
|
||||
|
||||
const _DELETE = {
|
||||
code: 'item-delete', label: 'Supprimer', icon: it => 'fa-solid fa-trash',
|
||||
code: 'item-delete', label: 'Supprimer', icon: 'fa-solid fa-trash',
|
||||
optionsFilter: options => options.isOwner,
|
||||
action: (item, actor) => RdDUtility.confirmActorItemDelete(item, actor)
|
||||
}
|
||||
@@ -49,48 +51,48 @@ const _EQUIPER = {
|
||||
|
||||
const _CUISINER = {
|
||||
code: 'item-cuisiner', label: 'Cuisiner',
|
||||
img: it => 'systems/foundryvtt-reve-de-dragon/assets/actions/cuisine.svg',
|
||||
// icon: it => 'fa-solid fa-spoon',
|
||||
img: 'systems/foundryvtt-reve-de-dragon/assets/actions/cuisine.svg',
|
||||
filter: it => it.getUtilisation() == 'cuisine' && it.system.sust > 0,
|
||||
action: (item, actor) => actor.preparerNourriture(item)
|
||||
}
|
||||
const _MANGER_CRU = {
|
||||
code: 'item-manger-cru', label: 'Manger cru', icon: it => 'fa-solid fa-drumstick-bite',
|
||||
code: 'item-manger-cru', label: 'Manger cru', icon: 'fa-solid fa-drumstick-bite',
|
||||
filter: it => it.getUtilisation() == 'cuisine' && it.system.sust > 0,
|
||||
action: (item, actor) => actor.mangerNourriture(item)
|
||||
}
|
||||
const _MANGER = {
|
||||
code: 'item-manger', label: 'Manger', icon: it => 'fa-solid fa-utensils',
|
||||
code: 'item-manger', label: 'Manger', icon: 'fa-solid fa-utensils',
|
||||
filter: it => !(it.system.boisson),
|
||||
action: (item, actor) => actor.mangerNourriture(item)
|
||||
}
|
||||
const _BOIRE = {
|
||||
code: 'item-boire', label: 'Boire', icon: it => 'fa-solid fa-glass-water',
|
||||
code: 'item-boire', label: 'Boire', icon: 'fa-solid fa-glass-water',
|
||||
filter: it => it.system.boisson,
|
||||
action: (item, actor) => actor.mangerNourriture(item)
|
||||
}
|
||||
const _DECOCTION = {
|
||||
code: 'item-decoction', label: 'Décoction', icon: it => 'fa-solid fa-flask-vial',
|
||||
code: 'item-decoction', label: 'Décoction', icon: 'fa-solid fa-flask-vial',
|
||||
action: (item, actor) => actor.fabriquerDecoctionHerbe(item)
|
||||
}
|
||||
|
||||
const _OUVRIR = {
|
||||
code: 'item-edit', label: 'Ouvrir', icon: it => 'fa-solid fa-eye',
|
||||
code: 'item-edit', label: 'Ouvrir',
|
||||
img: 'systems/foundryvtt-reve-de-dragon/assets/actions/ouvrir.svg',
|
||||
action: (item, actor) => item.sheet.render(true)
|
||||
}
|
||||
|
||||
const _LIRE = {
|
||||
code: 'item-lire', label: 'Lire', icon: it => 'fa-solid fa-book-open',
|
||||
code: 'item-lire', label: 'Lire', icon: 'fa-solid fa-book-open',
|
||||
action: (item, actor) => actor.actionLire(item)
|
||||
}
|
||||
|
||||
const _REFOULER = {
|
||||
code: 'item-refouler', label: 'Refouler', icon: it => 'fa-solid fa-burst',
|
||||
code: 'item-refouler', label: 'Refouler', icon: 'fa-solid fa-burst',
|
||||
filter: it => it.system.refoulement > 0,
|
||||
action: (item, actor) => actor.actionRefoulement(item)
|
||||
}
|
||||
|
||||
const _SORT_RESERVE = {
|
||||
code: 'item-sortreserve-add', label: 'Ajouter en réserve', icon: it => 'fa-solid fa-sparkles',
|
||||
code: 'item-sortreserve-add', label: 'Ajouter en réserve', icon: 'fa-solid fa-sparkles',
|
||||
filter: it => game.user.isGM && !it.system.isrituel,
|
||||
action: (item, actor) => actor.addSortReserve(item)
|
||||
}
|
||||
@@ -121,20 +123,33 @@ export class ItemAction {
|
||||
&& (!action.optionsFilter || action.optionsFilter(options))
|
||||
}
|
||||
|
||||
|
||||
static img(action, item) {
|
||||
if (action.placeholder){
|
||||
static label(action, item) {
|
||||
if (action.placeholder) {
|
||||
return ""
|
||||
}
|
||||
if (action?.img) {
|
||||
return `<img src="${action.img(item)}" />`
|
||||
return ItemAction.getParam(action.label, item)
|
||||
}
|
||||
|
||||
static img(action, item) {
|
||||
if (action.placeholder) {
|
||||
return ""
|
||||
}
|
||||
if (action?.icon) {
|
||||
return `<i class="${action.icon(item)}"></i>`
|
||||
|
||||
const img = ItemAction.getParam(action.img, item)
|
||||
if (img) {
|
||||
return `<img src="${img}" />`
|
||||
}
|
||||
const icon = ItemAction.getParam(action.icon, item)
|
||||
if (icon) {
|
||||
return `<i class="${icon}"></i>`
|
||||
}
|
||||
return action.label
|
||||
}
|
||||
|
||||
static getParam(p, item) {
|
||||
return typeof (p) == 'function' ? p(item) : p
|
||||
}
|
||||
|
||||
static async onActionItem(event, actor, options) {
|
||||
const code = $(event.currentTarget).data('code')
|
||||
const item = RdDSheetUtility.getItem(event, actor)
|
||||
|
||||
Reference in New Issue
Block a user