Skip to content

Fixed ammoRange related errors #1841

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions modules/item/item-wfrp4e.js
Original file line number Diff line number Diff line change
Expand Up @@ -1207,14 +1207,19 @@ export default class ItemWfrp4e extends Item {
value *= 2;
else // If the range modification is a formula (supports +X -X /X *X)
{
try // Works for + and -
{
ammoValue = (0, eval)(ammoValue);
value = Math.floor((0, eval)(value + ammoValue));
}
catch // if *X and /X
{ // eval (50 + "/5") = eval(50/5) = 10
value = Math.floor((0, eval)(value + ammoRange));
try {
try // Works for + and -
{
ammoValue = (0, eval)(ammoValue);
value = Math.floor((0, eval)(value + ammoValue));
}
catch // if *X and /X
{ // eval (50 + "/5") = eval(50/5) = 10
value = Math.floor((0, eval)(value + ammoValue));
}
} catch (error) {
ui.notifications.error(game.i18n.format("ERROR.AMMO_MODS", {type}));
console.error(error, {value, type, item: this, ammo: this.ammo});
}
}
return value
Expand Down
1 change: 1 addition & 0 deletions static/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1373,6 +1373,7 @@
"APPLYREQUESTOWNER": "Apply Effect command sent to owner",
"EFFECT.Applied" : "{name} applied to",
"ERROR.EFFECT": "Error when running effect {effect}, please see the console (F12)",
"ERROR.AMMO_MODS": "Ammunition '{type}' value could not be resolved, aborting. Check console (F12) for details`",
"SinReduced": "Sin reduced by 1",
"TargetingCancelled": "Targeting canceled: Already opposing a test",
"ERROR.Property": "WFRP4e Rolls must specify the item property",
Expand Down