moo-man / WFRP4e-FoundryVTT

The premiere system for running grim and perilous games of Warhammer Fantasy Role-play in the Foundry VTT environment.
Apache License 2.0
87 stars 51 forks source link

[Up In Arms] Using Up in arms Critical Hit Modifiers throws exception #2072

Closed moo-man closed 2 months ago

moo-man commented 2 months ago

I think this only happens if roll is >100

caught (in promise) TypeError: undefined. Cannot read properties of undefined (reading 'contents') [Detected 1 package: system:wfrp4e] at WFRP_Tables._maxRange (wfrp4e.js:304:26) at WFRP_Tables.rollTable (wfrp4e.js:218:26) at async WFRP_Tables.formatChatRoll (wfrp4e.js:509:18) at async WFRP_Utility.handleTableClick (wfrp4e.js:7508:16)
From: steven.evans
foundry: 11.315
wfrp4e: 7.2.0
wfrp4e-core: 5.0.5
wfrp4e-starter-set: 5.0.3
wfrp4e-up-in-arms: 5.0.1
Active Modules: filepicker-plus, lib-wrapper, module-credits, socketlib

moo-man commented 2 months ago

image Cannot reproduce this, so I'll need more details on reproduction steps

StevenEvans1966 commented 2 months ago

Try using the crit tables from Up in Arms

moo-man commented 2 months ago

That's what the screenshot is showing

Forien commented 2 months ago

I got the error on fresh install of wfrp4e, but on v12.257...

Chat command I used:

/table critarm +130
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'contents')
    at WFRP_Tables._maxRange (wfrp4e.js:304:26)
    at WFRP_Tables.rollTable (wfrp4e.js:218:26)
    at async WFRP_Tables.formatChatRoll (wfrp4e.js:509:18)
    at async WFRP_Utility.handleTableClick (wfrp4e.js:7517:16)

Issue probably is that WFRP_Tables._maxRange expects table argument as instance, while it gets passed tablekey instead:

static _maxRange(table)
{
    return table.results.contents.reduce((max, result) => result.range[0] > max ? result.range[0] : max, Number.MIN_SAFE_INTEGER)
}
/** in WFRP_Tables.rollTable */
if (this._isAboveMax(table, rollValue))
{
    rollValue = this._maxRange(tableKey);
}

The separate issue is why system thinks that roll of 107 is above the max for a critarm table? 🤔


Fresh install, fresh world. Enabled all UiA rules fvtt 12.327 wfrp4e 7.2.1 core 5.0.6 uia 5.0.2

Forien commented 2 months ago

Okay, I had UiA Crits turned on, but used normal tables, which is why all rolls above 100 fired an error.

After changing tables to UiA, error only appears if roll is beyond max value, so for example:

/table critarm +500
StevenEvans1966 commented 2 months ago

Has this been fixed?

Forien commented 2 months ago

Has this been fixed?

If it was, the issue would be closed. Also there was no update released after 7.2.1. So no, it hasn't been fixed yet.