Les conteneurs ouverts sont mis à jour
This commit is contained in:
1
assets/actions/ouvrir.svg
Normal file
1
assets/actions/ouvrir.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" style="height: 256px; width: 256px;"><defs><radialGradient id="skoll-open-chest-gradient-2"><stop offset="0%" stop-color="#b8e986" stop-opacity="1"></stop><stop offset="100%" stop-color="#ffe0af" stop-opacity="1"></stop></radialGradient><linearGradient x1="0" x2="0" y1="0" y2="1" id="skoll-open-chest-gradient-5"><stop offset="0%" stop-color="#417505" stop-opacity="1"></stop><stop offset="100%" stop-color="#8b572a" stop-opacity="1"></stop></linearGradient></defs><g class="" transform="translate(1,0)" style=""><path d="M457.03 213.037 416.514 100.24C425 77.232 433.27 68.075 437.527 64.633c3.162-2.563 5.922-3.534 8.185-2.904 4.134 1.168 8.775 7.7 12.278 17.456 11.266 31.347 10.377 87.094-.96 133.85zm-324.287-17.9 312.804 34.84-43.82-122.1L145.558 79.34c2.593 36.102-1.913 79.913-12.817 115.796zM128.98 77.5l-45.06-5.02 37.03 103.123c7.773-32.06 10.625-68.357 8.03-98.102zm-27.52-50.31c-3.793 3.1-10.77 10.666-18.25 28.566L402.23 91.3c5.333-13.695 11.37-24.702 17.88-32.495L108.796 24.13c-2.573-.29-5.415 1.51-7.338 3.06zm280.63 283.338.61 169.352 66.352-53.63-.61-169.35zM366.163 487.9 46.62 452.306 46 278.396l319.553 35.594zM216.726 337.648a9.777 9.777 0 0 0 5.168-9.405c-.248-6.367-5.364-12.092-11.43-12.857h-.125c-6.14-.693-10.904 3.927-10.646 10.335a13.973 13.973 0 0 0 5.767 10.543l-2.17 25.073 17.57 2.005zm219.28-91.983-307.46-34.25v59.54l242.712 27.037zM58.31 263.13l54.34 6.058v-49.98z" fill="#fff" fill-opacity="1" transform="translate(25.6, 25.6) scale(0.9, 0.9) rotate(0, 256, 256) skewX(0) skewY(0)"></path></g></svg>
|
||||
|
After Width: | Height: | Size: 1.6 KiB |
@@ -3,6 +3,7 @@
|
||||
## 13.0.27 - Les lunettes d'Illysis
|
||||
|
||||
- Les heures ne sont plus affichées en doublon sur les messages
|
||||
- Les conteneurs ouverts sont mis à jour si leur contenu change
|
||||
|
||||
## 13.0.26 - La ménagerie d'Illysis
|
||||
|
||||
|
||||
@@ -255,9 +255,9 @@ export class RdDBaseActorSang extends RdDBaseActorReve {
|
||||
await super.onCreateItem(item, options, id)
|
||||
}
|
||||
|
||||
async onUpdateItem(item, options, id) {
|
||||
async onUpdateItem(item, updates, options, id) {
|
||||
await this.changeItemEffects(item);
|
||||
await super.onUpdateItem(item, options, id)
|
||||
await super.onUpdateItem(item, updates, options, id)
|
||||
}
|
||||
|
||||
async onDeleteItem(item, options, id) {
|
||||
|
||||
@@ -50,7 +50,7 @@ export class RdDBaseActor extends Actor {
|
||||
Handlebars.registerHelper('actor-isFeminin', actor => actor.isFeminin())
|
||||
Hooks.on("preUpdateItem", (item, change, options, id) => Misc.documentIfResponsible(item.parent)?.onPreUpdateItem(item, change, options, id))
|
||||
Hooks.on("createItem", (item, options, id) => Misc.documentIfResponsible(item.parent)?.onCreateItem(item, options, id))
|
||||
Hooks.on("updateItem", (item, options, id) => Misc.documentIfResponsible(item.parent)?.onUpdateItem(item, options, id))
|
||||
Hooks.on("updateItem", (item, updates, options, id) => Misc.documentIfResponsible(item.parent)?.onUpdateItem(item, updates, options, id))
|
||||
Hooks.on("deleteItem", (item, options, id) => Misc.documentIfResponsible(item.parent)?.onDeleteItem(item, options, id))
|
||||
Hooks.on("updateActor", (actor, change, options, actorId) => Misc.documentIfResponsible(actor)?.onUpdateActor(change, options, actorId))
|
||||
}
|
||||
@@ -330,7 +330,9 @@ export class RdDBaseActor extends Actor {
|
||||
async onCreateItem(item, options, id) {
|
||||
}
|
||||
|
||||
async onUpdateItem(item, options, id) {
|
||||
async onUpdateItem(item, updates, options, id) {
|
||||
const conteneur = item.findConteneur()
|
||||
conteneur?.render(options.render)
|
||||
}
|
||||
|
||||
async onDeleteItem(item, options, id) {
|
||||
@@ -339,9 +341,8 @@ export class RdDBaseActor extends Actor {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async _removeItemFromConteneur(item) {
|
||||
const updates = this.items.filter(it => it.isConteneur() && it.system.contenu.includes(item.id))
|
||||
const updates = this.findConteneur(item)
|
||||
.map(conteneur => {
|
||||
const nouveauContenu = conteneur.system.contenu.filter(id => id != item.id)
|
||||
return { _id: conteneur.id, 'system.contenu': nouveauContenu }
|
||||
@@ -371,7 +372,7 @@ export class RdDBaseActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
async cleanupConteneurs() {
|
||||
if (Misc.isOwnerPlayer(this)) {
|
||||
let updates = this.itemTypes['conteneur']
|
||||
let updates = this.itemTypes[ITEM_TYPES.conteneur]
|
||||
.filter(c => c.system.contenu.filter(id => this.getItem(id) == undefined).length > 0)
|
||||
.map(c => { return { _id: c._id, 'system.contenu': c.system.contenu.filter(id => this.getItem(id) != undefined) } });
|
||||
if (updates.length > 0) {
|
||||
@@ -382,7 +383,7 @@ export class RdDBaseActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getFortune() {
|
||||
return Monnaie.getFortune(this.itemTypes['monnaie']);
|
||||
return Monnaie.getFortune(this.itemTypes[ITEM_TYPES.monnaie]);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@@ -663,7 +664,7 @@ export class RdDBaseActor extends Actor {
|
||||
if (srcId != destId && itemId != destId) { // déplacement de l'objet
|
||||
const src = this.getItem(srcId);
|
||||
const dest = this.getItem(destId);
|
||||
const cible = this.getContenantOrParent(dest);
|
||||
const cible = this.findConteneurOrParent(dest);
|
||||
const [empilable, message] = item.isInventaireEmpilable(dest);
|
||||
if (empilable) {
|
||||
await dest.empiler(item)
|
||||
@@ -685,15 +686,15 @@ export class RdDBaseActor extends Actor {
|
||||
return result;
|
||||
}
|
||||
|
||||
getContenantOrParent(dest) {
|
||||
findConteneurOrParent(dest) {
|
||||
if (!dest || dest.isConteneur()) {
|
||||
return dest;
|
||||
}
|
||||
return this.getContenant(dest);
|
||||
return this.findConteneur(dest)
|
||||
}
|
||||
|
||||
getContenant(item) {
|
||||
return this.itemTypes['conteneur'].find(it => it.system.contenu.includes(item.id));
|
||||
findConteneur(item) {
|
||||
return this.itemTypes[ITEM_TYPES.conteneur].find(it => it.system.contenu.includes(item.id));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ export const defaultItemImg = {
|
||||
souffle: "systems/foundryvtt-reve-de-dragon/icons/souffle_dragon.webp",
|
||||
tarot: "systems/foundryvtt-reve-de-dragon/icons/tarots/dos-tarot.webp",
|
||||
tete: "systems/foundryvtt-reve-de-dragon/icons/tete_dragon.webp",
|
||||
monnaie:"systems/foundryvtt-reve-de-dragon/icons/objets/piece_etain_poisson.webp",
|
||||
monnaie: "systems/foundryvtt-reve-de-dragon/icons/objets/piece_etain_poisson.webp",
|
||||
munition: "systems/foundryvtt-reve-de-dragon/icons/objets/fleche.webp"
|
||||
}
|
||||
|
||||
@@ -185,6 +185,13 @@ export class RdDItem extends Item {
|
||||
isCompetencePersonnage() { return this.type == ITEM_TYPES.competence }
|
||||
isCompetenceCreature() { return this.type == ITEM_TYPES.competencecreature }
|
||||
isConteneur() { return this.type == ITEM_TYPES.conteneur }
|
||||
findConteneur() {
|
||||
if (this.isInventaire('all') && this.parent) {
|
||||
return this.parent.findConteneur(this)
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
isMonnaie() { return this.type == ITEM_TYPES.monnaie }
|
||||
isNourritureBoisson() { return this.type == ITEM_TYPES.nourritureboisson; }
|
||||
isService() { return this.type == ITEM_TYPES.service }
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -93,7 +93,7 @@ export class RdDSheetUtility {
|
||||
static async renderItemBranch(actor, item) {
|
||||
while (item) {
|
||||
await item.sheet?.render()
|
||||
item = actor.getContenant(item)
|
||||
item = actor.findConteneur(item)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -348,6 +348,7 @@ export class RdDUtility {
|
||||
// Items
|
||||
Handlebars.registerHelper('rarete-getChamp', (rarete, field) => RdDRaretes.getChamp(rarete, field));
|
||||
Handlebars.registerHelper('item-action-applies', (action, item, options) => ItemAction.applies(action, item, options))
|
||||
Handlebars.registerHelper('item-action-label', (action, item) => new Handlebars.SafeString(ItemAction.label(action, item)))
|
||||
Handlebars.registerHelper('item-action-img', (action, item) => new Handlebars.SafeString(ItemAction.img(action, item)))
|
||||
Handlebars.registerHelper('item-name', (item) => item.nameDisplay)
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{{#each item.actions as |action|}}
|
||||
{{#if action.placeholder}}
|
||||
{{else if (item-action-applies action ../item ../options)}}
|
||||
<a class="actionItem" data-tooltip="{{action.label}}" data-code="{{action.code}}">
|
||||
<a class="actionItem" data-tooltip="{{item-action-label action ../item}}" data-code="{{action.code}}">
|
||||
{{item-action-img action ../item}}
|
||||
</a>
|
||||
{{/if}}
|
||||
|
||||
Reference in New Issue
Block a user