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