feat: use the selected token as speaker when performing a roll

This commit is contained in:
Johannes Loher 2021-09-19 20:12:01 +02:00
parent 3b2a7857e1
commit 0fa9d838e2
13 changed files with 57 additions and 61 deletions

View file

@ -6,7 +6,7 @@ import { Check } from "../actor/actor-data-properties";
import { DS4 } from "../config";
import { getGame } from "../helpers";
import notifications from "../ui/notifications";
import { getActiveActor } from "./helpers";
import { getActiveActorAndToken } from "./helpers";
/**
* Creates a macro from a check drop.
@ -45,10 +45,10 @@ async function getOrCreateRollCheckMacro(check: Check): Promise<Macro | undefine
* Executes the roll check macro for the given check.
*/
export async function rollCheck(check: Check): Promise<void> {
const actor = getActiveActor();
const { actor, token } = getActiveActorAndToken();
if (!actor) {
return notifications.warn(getGame().i18n.localize("DS4.WarningMustControlActorToUseRollCheckMacro"));
}
return actor.rollCheck(check).catch((e) => notifications.error(e, { log: true }));
return actor.rollCheck(check, { speaker: { token } }).catch((e) => notifications.error(e, { log: true }));
}