Compare commits
2 commits
f4585f4254
...
6f9b98ffc2
Author | SHA1 | Date | |
---|---|---|---|
6f9b98ffc2 | |||
978301eab1 |
3 changed files with 15 additions and 6 deletions
6
.vscode/launch.json
vendored
6
.vscode/launch.json
vendored
|
@ -5,12 +5,14 @@
|
|||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "pwa-chrome",
|
||||
"type": "chrome",
|
||||
"request": "launch",
|
||||
"runtimeExecutable": "/usr/bin/chromium",
|
||||
"name": "Launch Chrome against localhost",
|
||||
"url": "http://localhost:30000/game",
|
||||
"webRoot": "${workspaceFolder}/dist"
|
||||
"pathMapping": {
|
||||
"/systems/ds4": "${workspaceFolder}/dist"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
|
||||
import { DS4 } from "../../config";
|
||||
import { createCheckRoll } from "../../dice/check-factory";
|
||||
import { mathEvaluator } from "../../expression-evaluation/evaluator";
|
||||
import { Evaluator } from "../../expression-evaluation/evaluator";
|
||||
import { Validator } from "../../expression-evaluation/validator";
|
||||
import { logger } from "../../utils/logger";
|
||||
import { getGame } from "../../utils/utils";
|
||||
import { DS4ActiveEffect } from "../active-effect";
|
||||
|
@ -59,7 +60,7 @@ export class DS4Actor extends Actor {
|
|||
}
|
||||
|
||||
/**
|
||||
* The effects that should be applioed to this actor.
|
||||
* The effects that should be applied to this actor.
|
||||
* @type {import("../active-effect").DS4ActiveEffect[]}
|
||||
* @protected
|
||||
*/
|
||||
|
@ -90,7 +91,7 @@ export class DS4Actor extends Actor {
|
|||
if (condition !== undefined && condition !== "") {
|
||||
try {
|
||||
const replacedCondition = DS4Actor.replaceFormulaData(condition, { item, actor: this, effect });
|
||||
return replacedCondition !== undefined ? Boolean(mathEvaluator.evaluate(replacedCondition)) : false;
|
||||
return replacedCondition !== undefined ? Boolean(DS4Actor.evaluator.evaluate(replacedCondition)) : false;
|
||||
} catch (error) {
|
||||
logger.warn(error);
|
||||
return false;
|
||||
|
@ -520,6 +521,12 @@ export class DS4Actor extends Actor {
|
|||
rejectClose: false,
|
||||
});
|
||||
}
|
||||
|
||||
static evaluator = new Evaluator({
|
||||
context: Math,
|
||||
predicate: (identifier) =>
|
||||
Validator.defaultPredicate(identifier) || ["includes", "toLowerCase", "toUpperCase"].includes(identifier),
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,7 +19,7 @@ export class Evaluator<Context extends object> {
|
|||
get: (t, k) => (k === Symbol.unscopables ? undefined : t[k as keyof typeof t]),
|
||||
});
|
||||
actualPredicate = (identifier: string) =>
|
||||
predicate(identifier) || Object.getOwnPropertyNames(Math).includes(identifier);
|
||||
predicate(identifier) || Object.getOwnPropertyNames(context).includes(identifier);
|
||||
}
|
||||
this.validator = new Validator(actualPredicate);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue