fvtt-fria-ligan / forbidden-lands-foundry-vtt

This is a Forbidden Lands game System for the Foundry Virtual Tabletop. Made by @Perfectro, @patrys and @aMediocreDad. Maintained by @aMediocreDad
https://foundryvtt.com/packages/forbidden-lands/
Other
40 stars 44 forks source link

Inability to create a standard roll due to overridden method in the Actor document class #410

Open krbz999 opened 2 months ago

krbz999 commented 2 months ago

Describe the bug

I was expecting to be able to use an actor's roll data for creating a roll by writing a standard macro such as this:

const rollData = actor.getRollData();
const formula = "(@attribute.agility.value)d6";
const speaker = ChatMessage.implementation.getSpeaker({actor: actor});
return new Roll(formula, rollData).toMessage({speaker});

but it seems that getRollData is overridden in the actor document class to return something unrelated to rolls.

The workaround is to use const rollData = actor.system;.

Code here: https://github.com/fvtt-fria-ligan/forbidden-lands-foundry-vtt/blob/main/src/actor/actor-document.js#L41

Reproduction

Use the above sample macro.

System Info

n/a

Logs

No response

Validations

aMediocreDad commented 2 months ago

Yeah this is an old choice that was made in ignorance. Not so much a bug as incorrect override of the API. Changing it requires a bit of work.