diff --git a/module/api.mjs b/module/api.mjs index 9fe62f0..a6587a0 100644 --- a/module/api.mjs +++ b/module/api.mjs @@ -4,7 +4,7 @@ import { TableCreator } from "./Apps/TableCreator.mjs"; import { TestApp } from "./Apps/TestApp.mjs"; // Utils -import { filterPrivateRows } from "./utils/filterPrivateRows.mjs"; +import { filterPrivateRows } from "./utils/privacy.mjs"; import { validateValue } from "./utils/validateValue.mjs"; const { deepFreeze } = foundry.utils; diff --git a/module/utils/filterPrivateRows.mjs b/module/utils/privacy.mjs similarity index 66% rename from module/utils/filterPrivateRows.mjs rename to module/utils/privacy.mjs index 46873a6..12aefd1 100644 --- a/module/utils/filterPrivateRows.mjs +++ b/module/utils/privacy.mjs @@ -1,3 +1,22 @@ +export const PrivacyMode = Object.freeze({ + GM: `gm`, + PRIVATE: `private`, + SELF: `self`, + PUBLIC: `public`, +}); + +export function determinePrivacyFromRollMode(rollMode) { + switch (rollMode) { + case CONST.DICE_ROLL_MODES.BLIND: + return PrivacyMode.GM; + case CONST.DICE_ROLL_MODES.PRIVATE: + return PrivacyMode.PRIVATE; + case CONST.DICE_ROLL_MODES.SELF: + return PrivacyMode.SELF; + } + return PrivacyMode.PUBLIC; +}; + /** * Filters an array of database rows based on if the current user would * be able to see them based on the privacy level.