Use the Foundry util function instead of the custom one
This commit is contained in:
parent
30fee77c8e
commit
0770f32ef5
2 changed files with 2 additions and 18 deletions
|
|
@ -1,5 +1,4 @@
|
||||||
import DOTDUNGEON from "../config.mjs";
|
import DOTDUNGEON from "../config.mjs";
|
||||||
import { getPath } from "../utils.mjs";
|
|
||||||
|
|
||||||
export class GenericActorSheet extends ActorSheet {
|
export class GenericActorSheet extends ActorSheet {
|
||||||
_expanded = new Set();
|
_expanded = new Set();
|
||||||
|
|
@ -81,7 +80,7 @@ export class GenericActorSheet extends ActorSheet {
|
||||||
async _incrementValue($e) {
|
async _incrementValue($e) {
|
||||||
const target = $e.currentTarget;
|
const target = $e.currentTarget;
|
||||||
const data = target.dataset;
|
const data = target.dataset;
|
||||||
const value = getPath(data.increment, this.actor);
|
const value = getProperty(this.actor, data.increment);
|
||||||
if (typeof value != "number") {
|
if (typeof value != "number") {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
@ -91,7 +90,7 @@ export class GenericActorSheet extends ActorSheet {
|
||||||
async _decrementValue($e) {
|
async _decrementValue($e) {
|
||||||
const target = $e.currentTarget;
|
const target = $e.currentTarget;
|
||||||
const data = target.dataset;
|
const data = target.dataset;
|
||||||
const value = getPath(data.decrement, this.actor);
|
const value = getProperty(this.actor, data.decrement);
|
||||||
if (typeof value != "number") {
|
if (typeof value != "number") {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
/**
|
|
||||||
* @param {string} path
|
|
||||||
* @param {object} data
|
|
||||||
* @returns {unknown}
|
|
||||||
*/
|
|
||||||
export function getPath(path, data) {
|
|
||||||
if (!path.includes(`.`)) {
|
|
||||||
return data[path];
|
|
||||||
};
|
|
||||||
let [ key, nextPath ] = path.split(`.`, 2)
|
|
||||||
return getPath(
|
|
||||||
nextPath,
|
|
||||||
data[key]
|
|
||||||
);
|
|
||||||
};
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue