Skip to content

Commit

Permalink
Show Entity & Compendium items properly on roll table requests. Hide …
Browse files Browse the repository at this point in the history
…blind gm rolls for roll tables. (#78)

* hide blind roll table message, format roll tables to use entities

* rather show the lmrtfy roll table result, but hide the result behind a double ?

* rather use variable already set

Co-authored-by: Werner <werner.dohse@britehouse.co.za>
  • Loading branch information
vtt-lair and Werner authored Apr 18, 2021
1 parent bec20b6 commit c8c31fc
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
13 changes: 13 additions & 0 deletions src/lmrtfy.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,21 @@ class LMRTFY {
});
}
}

static async hideBlind(app, html, msg) {
if (msg.message.flags && msg.message.flags.lmrtfy) {
if (msg.message.flags.lmrtfy.blind && !game.user.isGM) {
msg.content = '<p>??</p>';

let idx = html[0].innerHTML.indexOf('<div class="message-content">');
html[0].innerHTML = html[0].innerHTML.substring(0, idx);
html[0].innerHTML += `<div class="message-content">${msg.content}</div>`;
}
}
}
}

Hooks.once('init', LMRTFY.init);
Hooks.on('ready', LMRTFY.ready);
Hooks.on('getSceneControlButtons', LMRTFY.getSceneControlButtons);
Hooks.on('renderChatMessage', LMRTFY.hideBlind);
26 changes: 24 additions & 2 deletions src/roller.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,16 @@ class LMRTFYRoller extends Application {
}

_drawTable(event, table) {
const icons = {
Actor: 'fas fa-user',
Item: 'fas fa-suitcase',
Scene: 'fas fa-map',
JournalEntry: 'fas fa-book-open',
Macro: 'fas fa-terminal',
Playlist: '',
Compendium: 'fas fa-atlas',
}

let chatMessages = [];
let count = 0;
const rollTable = game.tables.getName(table);
Expand All @@ -217,7 +227,18 @@ class LMRTFYRoller extends Application {
const nr = rollResult.length > 1 ? `${rollResult.length} results` : "a result";
let content = "";
for (const result of rollResult) {
content += `<p>${result.text}</p>`
if (!result.collection) {
content += `<p>${result.text}</p>`;
} else if (['Actor', 'Item', 'Scene', 'JournalEntry', 'Macro'].includes(result.collection)) {
content += `<p><a class="entity-link" draggable="true" data-entity="${result.collection}" data-id="${result.resultId}">
<i class="${icons[result.collection]}"></i> ${result.text}</a></p>`;
} else if (result.collection === 'Playlist') {
content += `<p>@${result.collection}[${result.resultId}]{${result.text}}</p>`;
} else if (result.collection) { // if not specific collection, then is compendium
content += `<p><a class="entity-link" draggable="true" data-pack="${result.collection}" data-id="${result.resultId}">
<i class="${icons[result.collection]}"></i> ${result.text}</a></p>`;
}

}
let chatData = {
user: game.user._id,
Expand All @@ -233,7 +254,8 @@ class LMRTFYRoller extends Application {
if ( this.mode === "selfroll" ) chatData.whisper = [game.user._id];
if ( this.mode === "blindroll" ) chatData.blind = true;

setProperty(chatData, "flags.lmrtfy", {"message": this.data.message, "data": this.data.attach});
setProperty(chatData, "flags.lmrtfy", {"message": this.data.message, "data": this.data.attach, "blind": chatData.blind});

chatMessages.push(chatData);

if (count === this.actors.length) {
Expand Down

0 comments on commit c8c31fc

Please sign in to comment.