Skip to content
This repository has been archived by the owner on Apr 16, 2022. It is now read-only.

Commit

Permalink
Only convert in-character messages to out-of-character, when "Disable…
Browse files Browse the repository at this point in the history
… GM speaking as PC tokens in enabled".
  • Loading branch information
Alan Davies committed Jun 27, 2021
1 parent 82727eb commit c45f01b
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions module/scripts/chat-resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,26 @@ export class ChatResolver {
libWrapper.register('CautiousGamemastersPack', "ChatLog.prototype.processMessage", _ChatLog_prototype_processMessage, 'MIXED');
}

static _convertToOoc(messageData) {
static _convertToGmSpeaker(messageData) {
// For all types of messages, change the speaker to the GM.
// Convert in-character message to out-of-character, and remove the actor and token.
const newType = (CONST.CHAT_MESSAGE_TYPES.IC === messageData.type ? CONST.CHAT_MESSAGE_TYPES.OOC : messageData.type);
const newActor = (CONST.CHAT_MESSAGE_TYPES.IC === messageData.type ? null : messageData.speaker.actor);
const newToken = (CONST.CHAT_MESSAGE_TYPES.IC === messageData.type ? null : messageData.speaker.token);
if (ChatResolver.isV0_8()) {
messageData.update({
type: CONST.CHAT_MESSAGE_TYPES.OOC,
type: newType,
speaker: {
actor: null,
actor: newActor,
alias: game.users.get(messageData.user).name,
token: null
token: newToken
}
});
} else {
messageData.type = CONST.CHAT_MESSAGE_TYPES.OOC;
messageData.speaker.actor = null;
messageData.type = newType;
messageData.speaker.actor = newActor;
messageData.speaker.alias = game.users.get(messageData.user).name;
messageData.speaker.token = null;
messageData.speaker.token = newToken;
}
}

Expand All @@ -109,7 +114,7 @@ export class ChatResolver {
{
// Convert in-character messages to out-of-character.
// We're assuming that the GM wanted to type something to the chat but forgot to deselect a token.
this._convertToOoc(messageData);
this._convertToGmSpeaker(messageData);
}
}
}
Expand All @@ -122,7 +127,7 @@ export class ChatResolver {
if (!speaker) return;
const token = canvas.tokens.get(speaker.token);
if (!messageData.roll && token?.actor?.hasPlayerOwner) {
this._convertToOoc(messageData);
this._convertToGmSpeaker(messageData);
}
}

Expand Down

0 comments on commit c45f01b

Please sign in to comment.