Fix duality roll (#436)

* allow /dr and [[/dr]] to be rolled without selection

* fix weird ternary

* Fixed so trait modifier comes along correctly

---------

Co-authored-by: psitacus <walther.johnson@ucalgary.ca>
Co-authored-by: WBHarry <williambjrklund@gmail.com>
This commit is contained in:
Psitacus 2025-07-27 15:26:55 -06:00 committed by GitHub
parent ff7927896a
commit f55698af02
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 23 additions and 13 deletions

View file

@ -31,21 +31,24 @@ export function rollCommandToJSON(text) {
return Object.keys(result).length > 0 ? result : null;
}
export const getCommandTarget = () => {
export const getCommandTarget = (options = {}) => {
const { allowNull = false } = options;
let target = game.canvas.tokens.controlled.length > 0 ? game.canvas.tokens.controlled[0].actor : null;
if (!game.user.isGM) {
target = game.user.character;
if (!target) {
if (!target && !allowNull) {
ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.noAssignedPlayerCharacter'));
return null;
}
}
if (!target) {
if (!target && !allowNull) {
ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.noSelectedToken'));
return null;
}
if (target.type !== 'character') {
ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.onlyUseableByPC'));
if (target && target.type !== 'character') {
if (!allowNull) {
ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.onlyUseableByPC'));
}
return null;
}