Fix: Actions dans un conteneur

Les actions dans un conteneur (ouvrir un des sous conteneurs par
exemple) n'étaient pas disponibles.
Ceci était lié à la structure des données contenant les droits
différente pour les items et les acteurs.

La gestion des droits était mélangées et faite de façons différentes.
Maintenant, les "options" dans les données du formulaire contiennent
les informations de droits d'accès et sont utilisées.
This commit is contained in:
2023-01-28 16:34:09 +01:00
parent 4d5651c2d3
commit 53a7230f1d
35 changed files with 122 additions and 125 deletions

View File

@ -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;
}

View File

@ -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

View File

@ -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;
}

View File

@ -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);

View File

@ -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)) {