Merge pull request 'Fix commerces' (#767) from VincentVk/foundryvtt-reve-de-dragon:v13 into v13
All checks were successful
Release Creation / build (release) Successful in 5m16s
All checks were successful
Release Creation / build (release) Successful in 5m16s
Reviewed-on: #767
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
- Les soins sont de nouveau disponibles depuis les tokens
|
- Les soins sont de nouveau disponibles depuis les tokens
|
||||||
- Correction des boutons de la feuille simplifiée
|
- Correction des boutons de la feuille simplifiée
|
||||||
|
- On peut de nouveau acheter dans les commerces
|
||||||
|
|
||||||
## 13.0.5
|
## 13.0.5
|
||||||
|
|
||||||
|
@@ -213,6 +213,7 @@ export class RdDBaseActor extends Actor {
|
|||||||
isCreatureEntite() { return this.isCreature() || this.isEntite() }
|
isCreatureEntite() { return this.isCreature() || this.isEntite() }
|
||||||
isCreature() { return false }
|
isCreature() { return false }
|
||||||
isEntite(typeentite = []) { return false }
|
isEntite(typeentite = []) { return false }
|
||||||
|
isHautRevant() { return false }
|
||||||
isVehicule() { return false }
|
isVehicule() { return false }
|
||||||
isPersonnage() { return false }
|
isPersonnage() { return false }
|
||||||
getItem(id, type = undefined) {
|
getItem(id, type = undefined) {
|
||||||
|
@@ -4,8 +4,7 @@ import { Misc } from "../misc.js"
|
|||||||
|
|
||||||
export const ACTION_ITEM_ENCHANTER = {
|
export const ACTION_ITEM_ENCHANTER = {
|
||||||
code: 'item-enchanter', label: 'Enchanter', icon: it => 'fa-solid fa-sparkles',
|
code: 'item-enchanter', label: 'Enchanter', icon: it => 'fa-solid fa-sparkles',
|
||||||
filter: it => game.user.isGM || DialogEnchanter.isEnchantable(it),
|
filter: it => game.user.isGM || DialogEnchanter.isEnchantable(it) && it.parent?.type != ACTOR_TYPES.commerce,
|
||||||
optionsFilter: options => options.editable,
|
|
||||||
action: (item, actor) => DialogEnchanter.enchanter(item)
|
action: (item, actor) => DialogEnchanter.enchanter(item)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -15,21 +15,21 @@ const _SPACEHOLDER = { placeholder: true }
|
|||||||
const _VENDRE = {
|
const _VENDRE = {
|
||||||
code: 'item-vendre', label: 'Vendre ou donner', icon: it => 'fa-solid fa-comments-dollar',
|
code: 'item-vendre', label: 'Vendre ou donner', icon: it => 'fa-solid fa-comments-dollar',
|
||||||
filter: it => Misc.toInt(it.system.quantite) > 0,
|
filter: it => Misc.toInt(it.system.quantite) > 0,
|
||||||
optionsFilter: options => options.editable,
|
|
||||||
action: (item, actor) => item.proposerVente()
|
action: (item, actor) => item.proposerVente()
|
||||||
}
|
}
|
||||||
const _ACHAT_SERVICE = {
|
const _ACHETER = {
|
||||||
code: 'item-service-acheter', label: 'Acheter', icon: it => 'fa-regular fa-coins',
|
code: 'item-acheter', label: 'Acheter', icon: it => 'fa-regular fa-coins',
|
||||||
filter: it => Misc.toInt(it.system.quantite) > 0 && it.parent?.type == ACTOR_TYPES.commerce,
|
filter: it => Misc.toInt(it.system.quantite) > 0 && it.parent?.type == ACTOR_TYPES.commerce,
|
||||||
action: (item, actor) => actor.vente(item)
|
action: (item, actor) => actor.vente(item)
|
||||||
}
|
}
|
||||||
const _MONTRER = {
|
const _MONTRER = {
|
||||||
code: 'item-montrer', label: 'Montrer', icon: it => 'fa-solid fa-comment',
|
code: 'item-montrer', label: 'Montrer', icon: it => 'fa-solid fa-comment',
|
||||||
|
allowLimited: true,
|
||||||
action: (item, actor) => item.postItemToChat()
|
action: (item, actor) => item.postItemToChat()
|
||||||
}
|
}
|
||||||
const _SPLIT = {
|
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: it => 'fa-solid fa-unlink',
|
||||||
filter: it => Misc.toInt(it.system.quantite) > 1,
|
filter: it => Misc.toInt(it.system.quantite) > 1 && it.parent?.type != ACTOR_TYPES.commerce,
|
||||||
action: (item, actor) => RdDSheetUtility.splitItem(item, actor)
|
action: (item, actor) => RdDSheetUtility.splitItem(item, actor)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ const _EDIT = {
|
|||||||
}
|
}
|
||||||
const _DELETE = {
|
const _DELETE = {
|
||||||
code: 'item-delete', label: 'Supprimer', icon: it => 'fa-solid fa-trash',
|
code: 'item-delete', label: 'Supprimer', icon: it => 'fa-solid fa-trash',
|
||||||
optionsFilter: options => options.editable && options.isOwner,
|
optionsFilter: options => options.isOwner,
|
||||||
action: (item, actor) => RdDUtility.confirmActorItemDelete(item, actor)
|
action: (item, actor) => RdDUtility.confirmActorItemDelete(item, actor)
|
||||||
}
|
}
|
||||||
const _EQUIPER = {
|
const _EQUIPER = {
|
||||||
@@ -51,30 +51,25 @@ const _EQUIPER = {
|
|||||||
const _CUISINER = {
|
const _CUISINER = {
|
||||||
code: 'item-cuisiner', label: 'Cuisiner', icon: it => 'fa-solid fa-utensils',
|
code: 'item-cuisiner', label: 'Cuisiner', icon: it => 'fa-solid fa-utensils',
|
||||||
filter: it => it.getUtilisation() == 'cuisine' && it.system.sust > 0,
|
filter: it => it.getUtilisation() == 'cuisine' && it.system.sust > 0,
|
||||||
optionsFilter: options => options.editable,
|
|
||||||
action: (item, actor) => actor.preparerNourriture(item)
|
action: (item, actor) => actor.preparerNourriture(item)
|
||||||
}
|
}
|
||||||
const _MANGER_CRU = {
|
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: it => 'fa-solid fa-drumstick-bite',
|
||||||
filter: it => it.getUtilisation() == 'cuisine' && it.system.sust > 0,
|
filter: it => it.getUtilisation() == 'cuisine' && it.system.sust > 0,
|
||||||
optionsFilter: options => options.editable,
|
|
||||||
action: (item, actor) => actor.mangerNourriture(item)
|
action: (item, actor) => actor.mangerNourriture(item)
|
||||||
}
|
}
|
||||||
const _MANGER = {
|
const _MANGER = {
|
||||||
code: 'item-manger', label: 'Manger', icon: it => 'fa-solid fa-utensils',
|
code: 'item-manger', label: 'Manger', icon: it => 'fa-solid fa-utensils',
|
||||||
filter: it => !(it.system.boisson),
|
filter: it => !(it.system.boisson),
|
||||||
optionsFilter: options => options.editable,
|
|
||||||
action: (item, actor) => actor.mangerNourriture(item)
|
action: (item, actor) => actor.mangerNourriture(item)
|
||||||
}
|
}
|
||||||
const _BOIRE = {
|
const _BOIRE = {
|
||||||
code: 'item-boire', label: 'Boire', icon: it => 'fa-solid fa-glass-water',
|
code: 'item-boire', label: 'Boire', icon: it => 'fa-solid fa-glass-water',
|
||||||
filter: it => it.system.boisson,
|
filter: it => it.system.boisson,
|
||||||
optionsFilter: options => options.editable,
|
|
||||||
action: (item, actor) => actor.mangerNourriture(item)
|
action: (item, actor) => actor.mangerNourriture(item)
|
||||||
}
|
}
|
||||||
const _DECOCTION = {
|
const _DECOCTION = {
|
||||||
code: 'item-decoction', label: 'Décoction', icon: it => 'fa-solid fa-flask-vial',
|
code: 'item-decoction', label: 'Décoction', icon: it => 'fa-solid fa-flask-vial',
|
||||||
optionsFilter: options => options.editable,
|
|
||||||
action: (item, actor) => actor.fabriquerDecoctionHerbe(item)
|
action: (item, actor) => actor.fabriquerDecoctionHerbe(item)
|
||||||
}
|
}
|
||||||
const _OUVRIR = {
|
const _OUVRIR = {
|
||||||
@@ -84,14 +79,12 @@ const _OUVRIR = {
|
|||||||
|
|
||||||
const _LIRE = {
|
const _LIRE = {
|
||||||
code: 'item-lire', label: 'Lire', icon: it => 'fa-solid fa-book-open',
|
code: 'item-lire', label: 'Lire', icon: it => 'fa-solid fa-book-open',
|
||||||
optionsFilter: options => options.editable,
|
|
||||||
action: (item, actor) => actor.actionLire(item)
|
action: (item, actor) => actor.actionLire(item)
|
||||||
}
|
}
|
||||||
|
|
||||||
const _REFOULER = {
|
const _REFOULER = {
|
||||||
code: 'item-refouler', label: 'Refouler', icon: it => 'fa-solid fa-burst',
|
code: 'item-refouler', label: 'Refouler', icon: it => 'fa-solid fa-burst',
|
||||||
filter: it => it.system.refoulement > 0,
|
filter: it => it.system.refoulement > 0,
|
||||||
optionsFilter: options => options.editable,
|
|
||||||
action: (item, actor) => actor.actionRefoulement(item)
|
action: (item, actor) => actor.actionRefoulement(item)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,7 +95,7 @@ const _SORT_RESERVE = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const COMMON_ACTIONS = [_EQUIPER]
|
export const COMMON_ACTIONS = [_EQUIPER]
|
||||||
export const DEFAULT_ACTIONS = [_SPACEHOLDER, _SPLIT, _VENDRE, _MONTRER, _EDIT, _DELETE]
|
export const DEFAULT_ACTIONS = [_ACHETER, _SPACEHOLDER, _SPLIT, _VENDRE, _MONTRER, _EDIT, _DELETE]
|
||||||
|
|
||||||
export const ITEM_ACTIONS = {
|
export const ITEM_ACTIONS = {
|
||||||
faune: [_CUISINER, _MANGER_CRU],
|
faune: [_CUISINER, _MANGER_CRU],
|
||||||
@@ -114,17 +107,16 @@ export const ITEM_ACTIONS = {
|
|||||||
ombre: [_REFOULER],
|
ombre: [_REFOULER],
|
||||||
plante: [_CUISINER, _MANGER_CRU],
|
plante: [_CUISINER, _MANGER_CRU],
|
||||||
queue: [_REFOULER],
|
queue: [_REFOULER],
|
||||||
sort: [_SORT_RESERVE],
|
sort: [_SORT_RESERVE]
|
||||||
service: [_ACHAT_SERVICE]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export class ItemAction {
|
export class ItemAction {
|
||||||
|
|
||||||
static applies(action, item, options) {
|
static applies(action, item, options) {
|
||||||
return action && item
|
return action && item
|
||||||
&& item.isActionAllowed(action.code)
|
&& item.isActionAllowed(action.code)
|
||||||
&& (!action.filter || action.filter(item))
|
&& (!action.filter || action.filter(item))
|
||||||
|
&& (action.allowLimited || options.editable)
|
||||||
&& (!action.optionsFilter || action.optionsFilter(options))
|
&& (!action.optionsFilter || action.optionsFilter(options))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,10 +128,10 @@ export class ItemAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async onActionItem(event, actor, options) {
|
static async onActionItem(event, actor, options) {
|
||||||
const item = RdDSheetUtility.getItem(event, actor)
|
|
||||||
const code = $(event.currentTarget).data('code')
|
const code = $(event.currentTarget).data('code')
|
||||||
|
const item = RdDSheetUtility.getItem(event, actor)
|
||||||
const action = item?.itemActions().find(it => it.code == code)
|
const action = item?.itemActions().find(it => it.code == code)
|
||||||
if (action && (!action.optionsFilter || action.optionsFilter(options))) {
|
if (action && ItemAction.applies(action, item, options)) {
|
||||||
await action.action(item, actor)
|
await action.action(item, actor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user