This commit is contained in:
@@ -383,7 +383,7 @@ export class CelestopolRoll extends Roll {
|
||||
puiserRessources: effectivePuiser,
|
||||
nbDice: (!isResistance && useFortune) ? 1 : nbDice,
|
||||
formula,
|
||||
rollMode: rollContext.visibility ?? "publicroll",
|
||||
rollMode: rollContext.visibility ?? "public",
|
||||
rollMoonDie: effectiveMoon,
|
||||
moonDieResult,
|
||||
moonFace,
|
||||
@@ -634,11 +634,20 @@ export class CelestopolRoll extends Roll {
|
||||
|
||||
/** @override */
|
||||
async toMessage(messageData = {}, { messageMode, rollMode, create = true } = {}) {
|
||||
if (rollMode) {
|
||||
messageMode = Roll._mapLegacyRollMode(rollMode)
|
||||
const modernToLegacyRollMode = {
|
||||
public: CONST.DICE_ROLL_MODES.PUBLIC,
|
||||
gm: CONST.DICE_ROLL_MODES.PRIVATE,
|
||||
blind: CONST.DICE_ROLL_MODES.BLIND,
|
||||
self: CONST.DICE_ROLL_MODES.SELF,
|
||||
ic: CONST.DICE_ROLL_MODES.PUBLIC,
|
||||
}
|
||||
messageMode ||= game.settings.get("core", "messageMode")
|
||||
if (!this._evaluated) await this.evaluate({ allowInteractive: messageMode !== "blind" })
|
||||
let effectiveRollMode = rollMode ?? messageMode ?? game.settings.get("core", "rollMode") ?? CONST.DICE_ROLL_MODES.PUBLIC
|
||||
effectiveRollMode = modernToLegacyRollMode[effectiveRollMode] ?? effectiveRollMode
|
||||
if (!Object.values(CONST.DICE_ROLL_MODES).includes(effectiveRollMode)) {
|
||||
effectiveRollMode = game.settings.get("core", "rollMode") ?? CONST.DICE_ROLL_MODES.PUBLIC
|
||||
}
|
||||
|
||||
if (!this._evaluated) await this.evaluate({ allowInteractive: effectiveRollMode !== CONST.DICE_ROLL_MODES.BLIND })
|
||||
|
||||
const skillLocalized = this.skillLabel ? game.i18n.localize(this.skillLabel) : ""
|
||||
const statLocalized = this.options.statLabel
|
||||
@@ -650,7 +659,7 @@ export class CelestopolRoll extends Roll {
|
||||
actorUuid: this.options.actorUuid ?? null,
|
||||
actorId: this.options.actorId ?? null,
|
||||
})
|
||||
const content = await this.render({ isPrivate: messageMode !== "public" })
|
||||
const content = await this.render({ isPrivate: effectiveRollMode !== CONST.DICE_ROLL_MODES.PUBLIC })
|
||||
const chatData = foundry.utils.mergeObject({
|
||||
author: game.user.id,
|
||||
content,
|
||||
@@ -660,13 +669,9 @@ export class CelestopolRoll extends Roll {
|
||||
speaker: speakerActor ? ChatMessage.getSpeaker({ actor: speakerActor }) : undefined,
|
||||
style: CONST.CHAT_MESSAGE_STYLES.OTHER,
|
||||
}, messageData)
|
||||
|
||||
const cls = foundry.utils.getDocumentClass("ChatMessage")
|
||||
const msg = new cls(chatData)
|
||||
msg.applyMode(messageMode)
|
||||
|
||||
if (create) return cls.create(msg)
|
||||
return msg.toObject()
|
||||
ChatMessage.applyRollMode(chatData, effectiveRollMode)
|
||||
if (create) return ChatMessage.create(chatData)
|
||||
return chatData
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user