mirror of
https://github.com/RoY7x/worldbuilding.git
synced 2025-07-13 01:41:56 -04:00
Tidy the worldbuilding system for 0.40 release
This commit is contained in:
parent
d641ff96b0
commit
6bf056b3d4
9 changed files with 72 additions and 184 deletions
|
@ -181,7 +181,7 @@ export class EntitySheetHelper {
|
|||
const label = button.closest(".attribute").querySelector(".attribute-label")?.value;
|
||||
const chatLabel = label ?? button.parentElement.querySelector(".attribute-key").value;
|
||||
const shorthand = game.settings.get("worldbuilding", "macroShorthand");
|
||||
const rollData = this.actor.getRollData();
|
||||
const rollData = this.object.getRollData();
|
||||
let formula = button.closest(".attribute").querySelector(".attribute-value")?.value;
|
||||
|
||||
// If there's a formula, attempt to roll it.
|
||||
|
@ -527,18 +527,14 @@ export class EntitySheetHelper {
|
|||
if ( typeof formula != "string" || depth < 1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Replace attributes with their numeric equivalents.
|
||||
let dataRgx = new RegExp(/@([a-z.0-9_\-]+)/gi);
|
||||
let rollFormula = formula.replace(dataRgx, (match, term) => {
|
||||
// Replace matches with the value, or the missing value.
|
||||
let value = getProperty(data, term);
|
||||
value = value ? String(value).trim() : (missing != null ? missing : `@${term}`);
|
||||
// If there's still an attribute in the returned string, nest it in parentheses so that it's evaluated first in the roll.
|
||||
value = value && value.includes('@') ? `(${value})` : value;
|
||||
return value;
|
||||
if ( value === null ) return "0";
|
||||
if ( String(value).includes('@') ) return value;
|
||||
else return `@${term}`;
|
||||
});
|
||||
|
||||
return rollFormula;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue