From 22683cf688e2d78aedca7bb62dc7901b887392a1 Mon Sep 17 00:00:00 2001 From: Paul Maskelyne Date: Mon, 18 Nov 2024 11:49:22 +0000 Subject: [PATCH 1/2] closes #953 --- system/src/dice/RollSD.mjs | 45 +++++++++++++++++++++++++++++--- system/src/documents/ActorSD.mjs | 8 ++---- system/src/documents/ItemSD.mjs | 6 ++--- system/src/system/ChatSD.mjs | 11 ++++---- system/src/utils/UtilitySD.mjs | 9 ------- 5 files changed, 50 insertions(+), 29 deletions(-) diff --git a/system/src/dice/RollSD.mjs b/system/src/dice/RollSD.mjs index 27ad9fc7..8cd12e69 100644 --- a/system/src/dice/RollSD.mjs +++ b/system/src/dice/RollSD.mjs @@ -715,20 +715,57 @@ export default class RollSD extends Roll { rollsToShow.push(rolls.secondaryDamage.roll); } - // TODO Make sure we honor the whisper and/or blind settings of the roll - // + const { whisper, blind } = this.getRollModeSettings(); + // Only await on the final dice roll of the sequence as it looks nicer // if all the dice roll before the chat message appears + // const numRolls = rollsToShow.length; let currentRoll = 1; for (const roll of rollsToShow) { if (currentRoll === numRolls) { - await game.dice3d.showForRoll(roll, game.user, true); + await game.dice3d.showForRoll(roll, game.user, true, whisper, blind); } else { - game.dice3d.showForRoll(roll, game.user, true); + game.dice3d.showForRoll(roll, game.user, true, whisper, blind); } currentRoll++; } } + + + static getRollModeSettings() { + const rollMode = game.settings.get("core", "rollMode"); + + let blind = false; + let whisper = null; + + switch (rollMode) { + case "blindroll": { + blind = true; + } + case "gmroll": { + const gmList = game.users.filter(user => user.isGM); + const gmIDList = []; + gmList.forEach(gm => gmIDList.push(gm.id)); + whisper = gmIDList; + break; + } + case "roll": { + const userList = game.users.filter(user => user.active); + const userIDList = []; + userList.forEach(user => userIDList.push(user.id)); + whisper = userIDList; + break; + } + case "selfroll": { + whisper = [game.user.id]; + break; + } + default: { + break; + } + } + return { whisper, blind }; + } } diff --git a/system/src/documents/ActorSD.mjs b/system/src/documents/ActorSD.mjs index 8ff22178..08368e69 100644 --- a/system/src/documents/ActorSD.mjs +++ b/system/src/documents/ActorSD.mjs @@ -70,15 +70,13 @@ export default class ActorSD extends Actor { const title = game.i18n.localize("SHADOWDARK.chat.spell_learn.title"); - const messageStyles = shadowdark.utils.getMessageStyles(); - await ChatMessage.create({ title, content, flags: { "core.canPopout": true }, flavor: title, speaker: ChatMessage.getSpeaker({ actor: this, token: this.token }), - type: messageStyles.OTHER, + type: CONST.CHAT_MESSAGE_STYLES.OTHER, user: game.user.id, }); @@ -1489,15 +1487,13 @@ export default class ActorSD extends Actor { const content = await renderTemplate(template, cardData); - const messageStyles = shadowdark.utils.getMessageStyles(); - await ChatMessage.create({ title, content, flags: { "core.canPopout": true }, flavor: title, speaker: ChatMessage.getSpeaker({actor: this, token: this.token}), - type: messageStyles.OTHER, + type: CONST.CHAT_MESSAGE_STYLES.OTHER, user: game.user.id, }); diff --git a/system/src/documents/ItemSD.mjs b/system/src/documents/ItemSD.mjs index 16303083..d113a514 100644 --- a/system/src/documents/ItemSD.mjs +++ b/system/src/documents/ItemSD.mjs @@ -97,13 +97,11 @@ export default class ItemSD extends Item { const html = await renderTemplate(template, templateData); - const messageStyles = shadowdark.utils.getMessageStyles(); - const chatData = { user: game.user.id, - type: messageStyles.OTHER, + type: CONST.CHAT_MESSAGE_STYLES.OTHER, content: html, - flavor: this.system.chatFlavor || this.name, + flavor: this.name, speaker: ChatMessage.getSpeaker({actor: this.actor, token}), flags: { "core.canPopout": true }, }; diff --git a/system/src/system/ChatSD.mjs b/system/src/system/ChatSD.mjs index 998b044b..292280e0 100644 --- a/system/src/system/ChatSD.mjs +++ b/system/src/system/ChatSD.mjs @@ -12,16 +12,15 @@ export default class ChatSD { mode = game.settings.get("core", "rollMode"); } - const messageStyles = shadowdark.utils.getMessageStyles(); - const chatData = { - user: game.user.id, + content: html, + flags: { "core.canPopout": true }, + rollMode: mode, speaker: ChatMessage.getSpeaker({ actor: actor, }), - rollMode: mode, - content: html, - type: messageStyles.OTHER, + type: CONST.CHAT_MESSAGE_STYLES.OTHER, + user: game.user.id, }; ChatMessage.applyRollMode(chatData, mode); diff --git a/system/src/utils/UtilitySD.mjs b/system/src/utils/UtilitySD.mjs index 3361777a..93792bd9 100644 --- a/system/src/utils/UtilitySD.mjs +++ b/system/src/utils/UtilitySD.mjs @@ -179,15 +179,6 @@ export default class UtilitySD { } - static getMessageStyles() { - const messageStyles = this.foundryMinVersion(12) - ? CONST.CHAT_MESSAGE_STYLES - : CONST.CHAT_MESSAGE_TYPES; - - return messageStyles; - } - - static getNextDieInList(die, allDice) { if (die === false) return die; From dcdf8c8088e4eaf4c52f96d0e932ba3a58516eda Mon Sep 17 00:00:00 2001 From: Paul Maskelyne Date: Mon, 18 Nov 2024 11:50:14 +0000 Subject: [PATCH 2/2] update release notes --- RELEASE_NOTES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 977c1e04..3e6e96a3 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -27,6 +27,7 @@ * [#930] Class Abilities can't be used if they have no associated skill roll * [#936] Character Generator: Don't display empty alignment for Deities that don't have one * [#938] Unecessary line breaks in Farsight talent descriptions +* [#953] Dice So Nice not honouring roll modes in Shadowdark ## Chores * [#911] Replaced compendium art mapping with default Foundry method. *(Settings for compendium art mapping are now found in *Settings > Core > Compendium Art*)*