Fixes for RnK visibility

This commit is contained in:
Vlyan
2021-08-12 10:29:13 +02:00
parent 45af487a4b
commit 0d7ddddaee
5 changed files with 38 additions and 7 deletions

View File

@@ -88,7 +88,7 @@ export class CombatL5r5e extends Combat {
if (messageOptions.rnkRoll instanceof game.l5r5e.RollL5r5e && ids.length === 1) {
// Specific RnK
roll = messageOptions.rnkRoll;
rnkMessage = await roll.toMessage({ flavor });
rnkMessage = await roll.toMessage({ flavor }, { rollMode: messageOptions.rollMode || null });
} else {
// Regular
roll = new game.l5r5e.RollL5r5e(formula);

View File

@@ -512,7 +512,13 @@ export class RollnKeepDialog extends FormApplication {
// Show DsN dice for the new roll
if (game.dice3d !== undefined) {
game.dice3d.showForRoll(roll, game.user, true);
game.dice3d.showForRoll(
roll,
game.user,
true,
this._message.data.whisper.length === 0 ? null : this._message.data.whisper,
this._message.data.blind
);
}
roll.terms.forEach((term) => {
@@ -617,6 +623,7 @@ export class RollnKeepDialog extends FormApplication {
if (this.roll.l5r5e.isInitiativeRoll) {
let msgOptions = {
rnkRoll: this.roll,
rollMode: game.l5r5e.HelpersL5r5e.getRollMode(this._message.data),
};
await this.roll.l5r5e.actor.rollInitiative({
@@ -630,7 +637,10 @@ export class RollnKeepDialog extends FormApplication {
delete msgOptions.rnkMessage;
} else {
// Send it to chat, switch to new message
this.message = await this.roll.toMessage();
this.message = await this.roll.toMessage(
{},
{ rollMode: game.l5r5e.HelpersL5r5e.getRollMode(this._message.data) }
);
}
// Refresh viewers

View File

@@ -302,8 +302,8 @@ export class RollL5r5e extends Roll {
// RollMode
const rMode = rollMode || messageData.rollMode || game.settings.get("core", "rollMode");
if (rollMode) {
ChatMessage.applyRollMode(messageData, rMode);
if (rMode) {
messageData = ChatMessage.applyRollMode(messageData, rMode);
}
// Prepare chat data
@@ -336,8 +336,8 @@ export class RollL5r5e extends Roll {
static fromData(data) {
const roll = super.fromData(data);
roll.data = duplicate(data.data);
roll.l5r5e = duplicate(data.l5r5e);
roll.data = foundry.utils.duplicate(data.data);
roll.l5r5e = foundry.utils.duplicate(data.l5r5e);
// get real Actor object
if (data.l5r5e.actor) {

View File

@@ -511,4 +511,22 @@ export class HelpersL5r5e {
content: `<div class="l5r5e-chat-item">${tpl}${link ? `<hr>` + link : ""}</div>`,
});
}
/**
* Return the RollMode for this ChatData
* @param {object} chatData
* @return {string}
*/
static getRollMode(chatData) {
if (chatData.whisper.length === 1 && chatData.whisper[0] === game.user.id) {
return "selfroll";
}
if (chatData.blind) {
return "blindroll";
}
if (chatData.whisper.length > 1) {
return "gmroll";
}
return "roll";
}
}