From 626829e989e91c1a3da2a417d05d6eaa6c1e71de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=B6gele?= Date: Wed, 28 Sep 2022 08:07:02 +0200 Subject: [PATCH] v10 compat: migrate to new data paths --- js/foundry_imports.js | 12 ++++++------ js/systems.js | 20 ++++++++++---------- js/util.js | 14 +++++++------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/js/foundry_imports.js b/js/foundry_imports.js index 869c707..2dbea9f 100644 --- a/js/foundry_imports.js +++ b/js/foundry_imports.js @@ -77,11 +77,11 @@ async function animateEntities(entities, draggedEntity, draggedRays, wasPaused) const origin = [firstWaypoint.x + entityOffset.x, firstWaypoint.y + entityOffset.y]; let dx, dy; if (canvas.grid.type === CONST.GRID_TYPES.GRIDLESS) { - dx = entity.data.x - origin[0]; - dy = entity.data.y - origin[1]; + dx = entity.x - origin[0]; + dy = entity.y - origin[1]; } else { - dx = entity.data.x - origin[0]; - dy = entity.data.y - origin[1]; + dx = entity.x - origin[0]; + dy = entity.y - origin[1]; } return {entity, rays: offsetRays, dx, dy}; @@ -131,7 +131,7 @@ async function animateEntities(entities, draggedEntity, draggedRays, wasPaused) } function calculateEntityOffset(entityA, entityB) { - return {x: entityA.data.x - entityB.data.x, y: entityA.data.y - entityB.data.y}; + return {x: entityA.x - entityB.x, y: entityA.y - entityB.y}; } function applyOffsetToRay(ray, offset) { @@ -388,7 +388,7 @@ export function highlightMeasurementNative( tokenShape = [{x: 0, y: 0}], alpha = 1, ) { - const spacer = canvas.scene.data.gridType === CONST.GRID_TYPES.SQUARE ? 1.41 : 1; + const spacer = canvas.scene.gridType === CONST.GRID_TYPES.SQUARE ? 1.41 : 1; const nMax = Math.max( Math.floor(ray.distance / (spacer * Math.min(canvas.grid.w, canvas.grid.h))), 1, diff --git a/js/systems.js b/js/systems.js index 63fc4e3..d3e518c 100644 --- a/js/systems.js +++ b/js/systems.js @@ -1,26 +1,26 @@ export function getDefaultSpeedAttribute() { switch (game.system.id) { case "CoC7": - return "actor.data.data.attribs.mov.value"; + return "actor.system.attribs.mov.value"; case "dcc": - return "actor.data.data.attributes.speed.value"; + return "actor.system.attributes.speed.value"; case "dnd4e": - return "actor.data.data.movement.walk.value"; + return "actor.system.movement.walk.value"; case "dnd5e": - return "actor.data.data.attributes.movement.walk"; + return "actor.system.attributes.movement.walk"; case "lancer": - return "actor.data.data.derived.speed"; + return "actor.system.derived.speed"; case "pf1": case "D35E": - return "actor.data.data.attributes.speed.land.total"; + return "actor.system.attributes.speed.land.total"; case "sfrpg": - return "actor.data.data.attributes.speed.value"; + return "actor.system.attributes.speed.value"; case "shadowrun5e": - return "actor.data.data.movement.walk.value"; + return "actor.system.movement.walk.value"; case "swade": - return "actor.data.data.stats.speed.adjusted"; + return "actor.system.stats.speed.adjusted"; case "ds4": - return "actor.data.data.combatValues.movement.total"; + return "actor.system.combatValues.movement.total"; case "splittermond": return "actor.derivedValues.speed.value"; } diff --git a/js/util.js b/js/util.js index 975209a..00e3eca 100644 --- a/js/util.js +++ b/js/util.js @@ -28,8 +28,8 @@ export function sum(arr) { export function buildSnapPointTokenData(token) { const tokenData = { - width: token.data.width, - height: token.data.height, + width: token.document.width, + height: token.document.height, }; if (isModuleActive("hex-size-support")) { @@ -158,9 +158,9 @@ export function getTokenShape(token) { } export function getTokenShapeForTokenData(tokenData, scene = canvas.scene) { - if (scene.data.gridType === CONST.GRID_TYPES.GRIDLESS) { + if (scene.grid.type === CONST.GRID_TYPES.GRIDLESS) { return [{x: 0, y: 0}]; - } else if (scene.data.gridType === CONST.GRID_TYPES.SQUARE) { + } else if (scene.grid.type === CONST.GRID_TYPES.SQUARE) { const topOffset = -Math.floor(tokenData.height / 2); const leftOffset = -Math.floor(tokenData.width / 2); const shape = []; @@ -211,12 +211,12 @@ export function getTokenShapeForTokenData(tokenData, scene = canvas.scene) { export function getTokenSize(token) { let w, h; - const hexSizeSupportBorderSize = token.data.flags["hex-size-support"]?.borderSize; + const hexSizeSupportBorderSize = token.document.flags["hex-size-support"]?.borderSize; if (hexSizeSupportBorderSize > 0) { w = h = hexSizeSupportBorderSize; } else { - w = token.data.width; - h = token.data.height; + w = token.document.width; + h = token.document.height; } return {w, h}; }