Rangertheman / motw-for-pbta

Monster of the Week Playbooks and Moves for Asacolips' PbtA system
MIT License
1 stars 5 forks source link

Users without Modify Settings permission cannot open character sheets #3

Closed tigator closed 1 year ago

tigator commented 1 year ago

If a user without the Modify Settings permission (i.e. Player, Trusted Player) tries to open a charsheet, it won't open, and in the console there will be an error like: "TypeError: An error occurred while rendering PbtaActorSheet 96. game.pbta.sheetConfig.actorTypes is undefined"

This issue occurs only inconsistently - my players had access to their sheets last night, for example, and then nothing changed and they suddenly don't have access to the sheets today. But when it does occur, giving my players the Modify Settings permission (obviously quite undesirable!) is the only fix I can find.

I've tested this with no other modules enabled but Compendium Folders and libWrapper, and also without both of those enabled, and it still occurs.

From inspecting motw-for-pbta.mjs and config-sheet.mjs it kind of seems like adding a permissions check in the Hooks.once blocks might help? It seems like it's tripping on the game.settings.set line (the player/trusted player wouldn't have permission to modify the indicated setting, presumably) and never getting to run configSheet() which is what sets game.pbta.sheetConfig.actorTypes. Of course, if the user needs Modify Settings to set game.pbta.sheetConfig also, then it seems like the code would need to temporarily elevate permissions to do that, if that's even possible. (I'm not a Foundry modder, just an occasional module tweaker.)

Or maybe there's a way game.pbta.sheetConfig can be set server-side instead?

Rangertheman commented 1 year ago

Thank you very much for your report! I will look into it and try to find a solution.

Rangertheman commented 1 year ago

This issue should be resolved with version 0.7.1 of the PbtA system. I will update the module as well after testing it.