diff --git a/module/actor/base-actor-sheet.js b/module/actor/base-actor-sheet.js
index a734f4c7..1af09f3f 100644
--- a/module/actor/base-actor-sheet.js
+++ b/module/actor/base-actor-sheet.js
@@ -31,29 +31,18 @@ export class RdDBaseActorSheet extends ActorSheet {
Monnaie.validerMonnaies(this.actor.itemTypes['monnaie']);
this.actor.recompute();
- const userRightLevel = game.user.isGM ? CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER : this.actor.getUserLevel(game.user)
- const options = duplicate(this.options);
- mergeObject(options, {
- isGM: game.user.isGM,
- editable: this.isEditable,
- cssClass: this.isEditable ? "editable" : "locked",
- isLimited: userRightLevel >= CONST.DOCUMENT_OWNERSHIP_LEVELS.LIMITED,
- isObserver: userRightLevel >= CONST.DOCUMENT_OWNERSHIP_LEVELS.OBSERVER,
- isOwner: userRightLevel >= CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER,
- owner: this.actor.isOwner,
- });
-
let formData = {
title: this.title,
id: this.actor.id,
type: this.actor.type,
img: this.actor.img,
name: this.actor.name,
- system: foundry.utils.deepClone(this.actor.system),
+ system: this.actor.system,
description: await TextEditor.enrichHTML(this.actor.system.description, { async: true }),
notesmj: await TextEditor.enrichHTML(this.actor.system.notesmj, { async: true }),
- options: options,
+ options: RdDSheetUtility.mergeDocumentRights(this.options, this.actor, this.isEditable)
}
+
RdDBaseActorSheet.filterItemsPerTypeForSheet(formData, this.actor.itemTypes);
formData.calc = {
fortune: this.toSolsDeniers(this.actor.getFortune()),
@@ -64,7 +53,6 @@ export class RdDBaseActorSheet extends ActorSheet {
this.objetVersConteneur = RdDUtility.buildArbreDeConteneurs(formData.conteneurs, formData.objets);
formData.conteneurs = RdDUtility.conteneursRacine(formData.conteneurs);
-
return formData;
}
diff --git a/module/item-sheet.js b/module/item-sheet.js
index af48e451..8747e0a3 100644
--- a/module/item-sheet.js
+++ b/module/item-sheet.js
@@ -86,22 +86,17 @@ export class RdDItemSheet extends ItemSheet {
/* -------------------------------------------- */
async getData() {
let formData = {
- id: this.item.id,
title: this.item.name,
+ id: this.item.id,
type: this.item.type,
img: this.item.img,
name: this.item.name,
system: this.item.system,
- isGM: game.user.isGM,
actorId: this.actor?.id,
- isOwned: this.actor ? true : false,
- owner: this.item.isOwner,
- editable: this.isEditable,
- cssClass: this.isEditable ? "editable" : "locked",
- isSoins: false,
description: await TextEditor.enrichHTML(this.item.system.description, { async: true }),
descriptionmj: await TextEditor.enrichHTML(this.item.system.descriptionmj, { async: true }),
- isComestible: this.item.getUtilisationCuisine()
+ isComestible: this.item.getUtilisationCuisine(),
+ options: RdDSheetUtility.mergeDocumentRights(this.options, this.item, this.isEditable)
}
const competences = await SystemCompendiums.getCompetences(this.actor?.type);
@@ -138,12 +133,12 @@ export class RdDItemSheet extends ItemSheet {
if (this.item.type == 'potion') {
await RdDHerbes.addPotionFormData(formData);
}
- if (formData.isOwned && this.item.type == 'herbe' && (formData.system.categorie == 'Soin' || formData.system.categorie == 'Repos')) {
+ if (formData.options.isOwned && this.item.type == 'herbe' && (formData.system.categorie == 'Soin' || formData.system.categorie == 'Repos')) {
formData.isIngredientPotionBase = true;
}
if (this.item.type == 'sortreserve') {
const sortId = this.item.system.sortid;
- formData.sort = formData.isOwned ? this.item.actor.items.get(sortId) : game.items.get(sortId);
+ formData.sort = formData.options.isOwned ? this.item.actor.items.get(sortId) : game.items.get(sortId);
}
formData.bonusCaseList = RdDItemSort.getBonusCaseList(formData, true);
@@ -156,7 +151,9 @@ export class RdDItemSheet extends ItemSheet {
super.activateListeners(html);
this.html = html;
- HtmlUtility.showControlWhen(this.html.find(".item-cout"), ReglesOptionelles.isUsing('afficher-prix-joueurs') || game.user.isGM || !this.item.isOwned);
+ HtmlUtility.showControlWhen(this.html.find(".item-cout"), ReglesOptionelles.isUsing('afficher-prix-joueurs')
+ || game.user.isGM
+ || !this.item.isOwned);
HtmlUtility.showControlWhen(this.html.find(".item-magique"), this.item.isMagique());
// Everything below here is only needed if the sheet is editable
diff --git a/module/item/sheet-service.js b/module/item/sheet-service.js
index a819247d..b9b00146 100644
--- a/module/item/sheet-service.js
+++ b/module/item/sheet-service.js
@@ -6,7 +6,7 @@ export class RdDServiceItemSheet extends RdDItemSheet {
async getData() {
const formData = await super.getData();
- formData.disabled = formData.isGM || formData.isOwned ? '' : 'disabled';
+ formData.disabled = formData.options.isGM || formData.options.isOwned ? '' : 'disabled';
return formData;
}
diff --git a/module/rdd-alchimie.js b/module/rdd-alchimie.js
index add4bd7c..64605ab4 100644
--- a/module/rdd-alchimie.js
+++ b/module/rdd-alchimie.js
@@ -8,13 +8,11 @@ export class RdDAlchimie {
/* -------------------------------------------- */
static processManipulation(recette, actorId = undefined) {
- //console.log("CALLED", recette, recette.isOwned, actorId );
let manip = recette.system.manipulation;
let matchArray = manip.match(matchOperations);
if (matchArray) {
for (let matchStr of matchArray) {
let result = matchStr.match(matchOperationTerms);
- //console.log("RESULT ", result);
if (result[1] && result[2]) {
let commande = Misc.upperFirst(result[1]);
let replacement = this[`_alchimie${commande}`](recette, result[2], actorId);
diff --git a/module/rdd-sheet-utility.js b/module/rdd-sheet-utility.js
index e1090a04..da9732cb 100644
--- a/module/rdd-sheet-utility.js
+++ b/module/rdd-sheet-utility.js
@@ -1,9 +1,24 @@
import { DialogSplitItem } from "./dialog-split-item.js";
import { RdDItem } from "./item.js";
-import { SystemCompendiums } from "./settings/system-compendiums.js";
export class RdDSheetUtility {
+ static mergeDocumentRights(options, document, editable) {
+ const userRightLevel = game.user.isGM
+ ? CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER
+ : document.getUserLevel(game.user);
+ mergeObject(options, {
+ isGM: game.user.isGM,
+ isOwned: document.parent,
+ editable: editable,
+ cssClass: editable ? "editable" : "locked",
+ isLimited: userRightLevel >= CONST.DOCUMENT_OWNERSHIP_LEVELS.LIMITED,
+ isObserver: userRightLevel >= CONST.DOCUMENT_OWNERSHIP_LEVELS.OBSERVER,
+ isOwner: userRightLevel >= CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER
+ });
+ return options;
+ }
+
static getItem(event, actor) {
return actor.items.get(RdDSheetUtility.getItemId(event))
}
@@ -23,7 +38,7 @@ export class RdDSheetUtility {
static async prepareItemDropParameters(destItemId, actor, dragData, objetVersConteneur) {
let item = fromUuidSync(dragData.uuid);
- if (item.pack && !item.system){
+ if (item.pack && !item.system) {
item = await RdDItem.getCorrespondingItem(item);
}
if (actor.canReceive(item)) {
diff --git a/templates/actor-creature-sheet.html b/templates/actor-creature-sheet.html
index 0e93a954..6995640c 100644
--- a/templates/actor-creature-sheet.html
+++ b/templates/actor-creature-sheet.html
@@ -67,7 +67,7 @@
{{!-- Description Tab --}}
- {{editor description target="system.description" button=true owner=owner editable=editable engine="prosemirror"}}
+ {{editor description target="system.description" button=true owner=options.isOwner editable=options.editable engine="prosemirror"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/actor/editor-notes-mj.html"}}
diff --git a/templates/actor-entite-sheet.html b/templates/actor-entite-sheet.html
index 61cee9d6..5706efde 100644
--- a/templates/actor-entite-sheet.html
+++ b/templates/actor-entite-sheet.html
@@ -44,7 +44,7 @@
- {{editor description target="system.description" button=true owner=owner editable=editable engine="prosemirror"}}
+ {{editor description target="system.description" button=true owner=options.isOwner editable=options.editable engine="prosemirror"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/actor/editor-notes-mj.html"}}
diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html
index 9a877b60..de44d86f 100644
--- a/templates/actor-sheet.html
+++ b/templates/actor-sheet.html
@@ -190,11 +190,11 @@
Biographie :
- {{editor biographie target="system.biographie" button=true owner=options.owner editable=true engine="prosemirror"}}
+ {{editor biographie target="system.biographie" button=true owner=options.isOwner editable=options.editable engine="prosemirror"}}
Notes :
- {{editor notes target="system.notes" button=true owner=owner editable=true engine="prosemirror"}}
+ {{editor notes target="system.notes" button=true owner=options.isOwner editable=options.editable engine="prosemirror"}}
{{> "systems/foundryvtt-reve-de-dragon/templates/actor/xp-journal.html"}}
{{> "systems/foundryvtt-reve-de-dragon/templates/actor/editor-notes-mj.html"}}
diff --git a/templates/actor-vehicule-sheet.html b/templates/actor-vehicule-sheet.html
index fe9dcf88..ea6527f4 100644
--- a/templates/actor-vehicule-sheet.html
+++ b/templates/actor-vehicule-sheet.html
@@ -84,7 +84,7 @@
- {{editor description target="system.description" button=true owner=owner editable=true engine="prosemirror"}}
+ {{editor description target="system.description" button=true owner=options.isOwner editable=options.editable engine="prosemirror"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/actor/editor-notes-mj.html"}}
diff --git a/templates/actor/commerce-actor-sheet.html b/templates/actor/commerce-actor-sheet.html
index 9bff7277..ae98e7bc 100644
--- a/templates/actor/commerce-actor-sheet.html
+++ b/templates/actor/commerce-actor-sheet.html
@@ -36,7 +36,7 @@
{{!-- Sheet Body --}}
- {{editor description target="system.description" button=true owner=options.owner editable=options.isOwner engine="prosemirror"}}
+ {{editor description target="system.description" button=true owner=options.isOwner editable=options.isOwner engine="prosemirror"}}
{{> "systems/foundryvtt-reve-de-dragon/templates/actor/commerce-inventaire.html"}}
diff --git a/templates/actor/editor-notes-mj.html b/templates/actor/editor-notes-mj.html
index c34e91b8..32c17a6e 100644
--- a/templates/actor/editor-notes-mj.html
+++ b/templates/actor/editor-notes-mj.html
@@ -1,6 +1,6 @@
{{#if options.isGM}}
Notes du MJ :
- {{editor notesmj target="system.notesmj" button=true owner=owner editable=true engine="prosemirror"}}
+ {{editor notesmj target="system.notesmj" button=true owner=options.isOwner editable=options.editable engine="prosemirror"}}
{{/if}}
diff --git a/templates/actor/inventaire-item.html b/templates/actor/inventaire-item.html
index 25e5984b..a89f0716 100644
--- a/templates/actor/inventaire-item.html
+++ b/templates/actor/inventaire-item.html
@@ -22,23 +22,23 @@
{{numberFormat item.system.encTotal decimals=2}}
{{#if options.isOwner}}
- {{#unless item.estContenu}}
- {{#if (or (eq item.type 'arme') (eq item.type 'armure') )}}
- {{#if item.system.equipe}}{{else}}{{/if}}
- {{/if}}
- {{/unless}}
-
-
-
- {{#if (ne item.system.quantite 0)}}
-
- {{/if}}
+ {{#unless item.estContenu}}
+ {{#if (or (eq item.type 'arme') (eq item.type 'armure') )}}
+ {{#if item.system.equipe}}{{else}}{{/if}}
+ {{/if}}
+ {{/unless}}
+
+
+
+ {{#if (ne item.system.quantite 0)}}
+
+ {{/if}}
{{/if}}
{{#if options.isOwner}}
- {{#if item.system.actionPrincipale}}
- {{item.system.actionPrincipale}}
- {{/if}}
+ {{#if item.system.actionPrincipale}}
+ {{item.system.actionPrincipale}}
+ {{/if}}
{{/if}}
diff --git a/templates/dialog-item-vente.html b/templates/dialog-item-vente.html
index 1307b33a..0a2b4313 100644
--- a/templates/dialog-item-vente.html
+++ b/templates/dialog-item-vente.html
@@ -13,7 +13,7 @@
- {{#unless isOwned}}
+ {{#unless options.isOwned}}
diff --git a/templates/item-competence-sheet.html b/templates/item-competence-sheet.html
index 78a7a780..d0287462 100644
--- a/templates/item-competence-sheet.html
+++ b/templates/item-competence-sheet.html
@@ -3,7 +3,7 @@
- {{#if isGM}}
+ {{#if options.isGM}}
{{>"systems/foundryvtt-reve-de-dragon/templates/item/partial-inventaire.html"}}
- {{#if isOwned}}
+ {{#if options.isOwned}}
- {{log 'contenu conteneur-sheet' this}}
- {{buildInventaireConteneur actorId id @root.options}}
+ {{buildInventaireConteneur actorId id options}}
{{/if}}
diff --git a/templates/item-extraitpoetique-sheet.html b/templates/item-extraitpoetique-sheet.html
index a02127c0..5c0414b5 100644
--- a/templates/item-extraitpoetique-sheet.html
+++ b/templates/item-extraitpoetique-sheet.html
@@ -12,13 +12,13 @@
- {{editor extrait target="system.extrait" button=true owner=owner editable=true engine="prosemirror"}}
+ {{editor extrait target="system.extrait" button=true owner=options.isOwner editable=options.editable engine="prosemirror"}}
- {{editor texte target="system.texte" button=true owner=owner editable=true engine="prosemirror"}}
+ {{editor texte target="system.texte" button=true owner=options.isOwner editable=options.editable engine="prosemirror"}}
diff --git a/templates/item-faune-sheet.html b/templates/item-faune-sheet.html
index cde0c58c..2970fc02 100644
--- a/templates/item-faune-sheet.html
+++ b/templates/item-faune-sheet.html
@@ -29,7 +29,7 @@
{{#if system.actor.id}}
- {{#if isGM}}
+ {{#if options.isGM}}