Skip to content

Commit abc647f

Browse files
authored
Merge pull request #131 from vtt-lair/v9
fix(v9): fix requester for v9. fix custom roll. fix macro execute
2 parents ce33eb3 + cb0beae commit abc647f

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

module.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"name": "lmrtfy",
44
"title": "Let Me Roll That For You!",
55
"description": "Ask your players to make rolls for you.",
6-
"version": "1.21",
7-
"author": "KaKaRoTo, iotech, Limping Ninja, Rughalt, Calego",
6+
"version": "1.22",
7+
"author": "KaKaRoTo, iotech, Limping Ninja, Rughalt, Calego, VTT Lair",
88
"scripts": [
99
"./src/lmrtfy.js",
1010
"./src/requestor.js",
@@ -88,10 +88,10 @@
8888
"socket": true,
8989
"url": "https://github.com/League-of-Foundry-Developers/fvtt-module-lmrtfy",
9090
"manifest": "https://github.com/League-of-Foundry-Developers/fvtt-module-lmrtfy/releases/latest/download/module.json",
91-
"download": "https://github.com/League-of-Foundry-Developers/fvtt-module-lmrtfy/releases/download/v1.21/module.zip",
91+
"download": "https://github.com/League-of-Foundry-Developers/fvtt-module-lmrtfy/releases/download/v1.22/module.zip",
9292
"changelog": "https://github.com/League-of-Foundry-Developers/fvtt-module-lmrtfy/releases",
9393
"bugs": "https://github.com/League-of-Foundry-Developers/fvtt-module-lmrtfy/issues",
9494
"minimumCoreVersion": "0.8.6",
95-
"compatibleCoreVersion": "0.8.9",
95+
"compatibleCoreVersion": "9",
9696
"allowBugReporter": true
9797
}

src/requestor.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ class LMRTFYRequestor extends FormApplication {
4040

4141
async getData() {
4242
// Return data to the template
43-
const actors = game.actors.entities;
44-
const users = game.users.entities;
43+
const actors = game.actors.entities || game.actors.contents;
44+
const users = game.users.entities || game.users.contents;
4545
// Note: Maybe these work better at a global level, but keeping things simple
4646
const abilities = LMRTFY.abilities;
4747
const saves = LMRTFY.saves;
@@ -117,7 +117,8 @@ class LMRTFYRequestor extends FormApplication {
117117
const actorId = div.dataset.id;
118118
const actor = game.actors.get(actorId);
119119
if (!actor) return;
120-
const user = userId === "character" ? game.users.entities.find(u => u.character && u.character._id === actor._id) : null;
120+
const gameUsers = game.users.entities || game.users.contents;
121+
const user = userId === "character" ? gameUsers.find(u => u.character && u.character._id === actor._id) : null;
121122
const tooltip = document.createElement("SPAN");
122123
tooltip.classList.add("tooltip");
123124
tooltip.textContent = `${actor.name}${user ? ` (${user.name})` : ''}`;
@@ -128,21 +129,24 @@ class LMRTFYRequestor extends FormApplication {
128129
_getUserActorIds(userId) {
129130
let actors = [];
130131
if (userId === "character") {
131-
actors = game.users.entities.map(u => u.character && u.character.id).filter(a => a)
132+
const gameUsers = game.users.entities || game.users.contents;
133+
actors = gameUsers.map(u => u.character?.id).filter(a => a)
132134
} else if (userId === "tokens") {
133135
actors = Array.from(new Set(canvas.tokens.placeables.map(t => t.data.actorId))).filter(a => a);
134136
} else {
135137
const user = game.users.get(userId);
136-
if (user)
137-
actors = game.actors.entities.filter(a => a.hasPerm(user, "OWNER")).map(a => a.id)
138+
if (user) {
139+
const gameActors = game.actors.contents || game.actors.entities;
140+
actors = gameActors.filter(a => a.testUserPermission(user, "OWNER")).map(a => a.id)
141+
}
138142
}
139143
return actors;
140144
}
145+
141146
_onUserChange() {
142147
const userId = this.element.find("select[name=user]").val();
143148
const actors = this._getUserActorIds(userId)
144149
this.element.find(".lmrtfy-actor").hide().filter((i, e) => actors.includes(e.dataset.id)).show();
145-
146150
}
147151

148152
diceLeftClick(event) {

src/roller.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,10 @@ class LMRTFYRoller extends Application {
179179
try {
180180
const rollData = actor.getRollData();
181181
const roll = new Roll(formula, rollData);
182-
const messageData = await roll.toMessage({"flags.lmrtfy": messageFlag}, {rollMode: this.mode, create: false});
182+
const rollMessageData = await roll.toMessage({"flags.lmrtfy": messageFlag}, {rollMode: this.mode, create: false});
183183

184184
const speaker = ChatMessage.getSpeaker({actor: actor});
185-
messageData.update({
185+
const messageData = mergeObject(rollMessageData, {
186186
speaker: {
187187
alias: speaker.alias,
188188
scene: speaker.scene,

0 commit comments

Comments
 (0)