From a4fadaf9d9f4d2fa84a347936fc21aafb556ea3b Mon Sep 17 00:00:00 2001 From: p4535992 Date: Sun, 23 Oct 2022 14:53:20 +0200 Subject: [PATCH] version 3.3.1 --- package.json | 2 +- src/module.json | 8 ++--- src/scripts/api.ts | 4 +-- src/scripts/mountManager.ts | 8 ++--- src/scripts/tokenAttacherHelper.ts | 49 +++++++++++++++++------------- 5 files changed, 39 insertions(+), 32 deletions(-) diff --git a/package.json b/package.json index 23283b7..2657350 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "mountup", "title": "FoundryVTT Mount Up!", "description": "Allows tokens to carry or be carried by other tokens. This is completely system agnostic, and fully customizable to fit right into your game.", - "version": "3.3.0", + "version": "3.3.1", "main": "mountup.js", "scripts": { "publish": "gulp publish --update", diff --git a/src/module.json b/src/module.json index f26dfa2..689ea30 100644 --- a/src/module.json +++ b/src/module.json @@ -2,7 +2,7 @@ "id": "mountup", "title": "Mount Up!", "description": "Allows tokens to carry or be carried by other tokens. This is completely system agnostic, and fully customizable to fit right into your game.", - "version": "3.3.0", + "version": "3.3.1", "authors": [ { "name": "Brunhine" @@ -59,7 +59,7 @@ "path": "languages/ja.json" } ], - "esmodules": ["./mountup.js"], + "esmodules": ["mountup.js"], "styles": [], "compatibility": { "minimum": 10, @@ -69,8 +69,8 @@ "url": "https://github.com/p4535992/foundryvtt-mountup", "manifest": "https://github.com/p4535992/foundryvtt-mountup/releases/latest/download/module.json", "download": "https://github.com/p4535992/foundryvtt-mountup/releases/latest/download/module.zip", - "readme": "https://github.com/p4535992/foundryvtt-mountup/blob/v3.3.0/README.md", - "changelog": "https://github.com/p4535992/foundryvtt-mountup/blob/v3.3.0/changelog.md", + "readme": "https://github.com/p4535992/foundryvtt-mountup/blob/v3.3.1/README.md", + "changelog": "https://github.com/p4535992/foundryvtt-mountup/blob/v3.3.1/changelog.md", "bugs": "https://github.com/p4535992/foundryvtt-mountup/issues", "allowBugReporter": true, "manifestPlusVersion": "1.2.0", diff --git a/src/scripts/api.ts b/src/scripts/api.ts index ace26eb..18c9491 100644 --- a/src/scripts/api.ts +++ b/src/scripts/api.ts @@ -172,7 +172,7 @@ const API = { for (const key in p) { const senseOrConditionIdKey = key; const senseOrConditionValue = p[key]; - await token.actor?.unsetFlag(CONSTANTS.MODULE_NAME, senseOrConditionIdKey); + await token.document.unsetFlag(CONSTANTS.MODULE_NAME, senseOrConditionIdKey); } const attached = token.document.getFlag("token-attacher", `attached`); if (attached) { @@ -208,7 +208,7 @@ const API = { for (const key in p) { const senseOrConditionIdKey = key; const senseOrConditionValue = p[key]; - await token.actor?.unsetFlag(CONSTANTS.MODULE_NAME, senseOrConditionIdKey); + await token.document.unsetFlag(CONSTANTS.MODULE_NAME, senseOrConditionIdKey); } const attached = token.document.getFlag("token-attacher", `attached`); if (attached) { diff --git a/src/scripts/mountManager.ts b/src/scripts/mountManager.ts index a2dd560..dc925cb 100644 --- a/src/scripts/mountManager.ts +++ b/src/scripts/mountManager.ts @@ -61,7 +61,7 @@ export class MountManager { // // shrink the rider if needed // if (riderToken.w >= mountToken.w || riderToken.h >= mountToken.h) { - // const grid = canvas.scene?.grid; + // const grid = canvas.scene?.grid.size; // const newWidth = mountToken.w / 2 / grid; // const newHeight = mountToken.h / 2 / grid; // await riderToken.document.update({ @@ -180,7 +180,7 @@ export class MountManager { // if (riders.includes(riderTokenTmp.id)) { // // shrink the rider if needed // if (riderTokenTmp.w >= mountToken.w || riderTokenTmp.h >= mountToken.h) { - // const grid = canvas.scene?.grid; + // const grid = canvas.scene?.grid.size; // const newWidth = mountToken.w / 2 / grid; // const newHeight = mountToken.h / 2 / grid; // await riderTokenTmp.document.update({ @@ -212,7 +212,7 @@ export class MountManager { // MOD 4535992 REMOVED IF //if (riderToken.w < origsize.w || riderToken.h < origsize.h) { //@ts-ignore - const grid = canvas.scene?.grid; + const grid = canvas.scene?.grid.size; const newWidth = riderToken.w < origsize.w ? origsize.w : riderToken.w; const newHeight = riderToken.h < origsize.h ? origsize.h : riderToken.h; @@ -332,7 +332,7 @@ export class MountManager { // if (riders && riders.includes(riderToken.id)) { // // shrink the rider if needed // if (riderToken.w >= mountToken.w || riderToken.h >= mountToken.h) { - // const grid = canvas.scene?.grid; + // const grid = canvas.scene?.grid.size; // const newWidth = mountToken.w / 2 / grid; // const newHeight = mountToken.h / 2 / grid; // await riderToken.document.update({ diff --git a/src/scripts/tokenAttacherHelper.ts b/src/scripts/tokenAttacherHelper.ts index 5910ca5..1f70181 100644 --- a/src/scripts/tokenAttacherHelper.ts +++ b/src/scripts/tokenAttacherHelper.ts @@ -17,23 +17,23 @@ export const mountUpTA = async function (riderToken: Token, mountToken: Token) { const mount = targets[0]; const newMountCoords = { //@ts-ignore - x: mount.document.x ? mount.document.x : mount.x, + x: mount.x, //@ts-ignore - y: mount.document.y ? mount.document.y : mount.y, + y: mount.y, //@ts-ignore - w: mount.document.width ? mount.document.width : mount.w, + w: mount.w, //@ts-ignore - h: mount.document.height ? mount.document.height : mount.h, + h: mount.h, }; const newRiderCoords = { //@ts-ignore - x: riderToken.document.x ? riderToken.document.x : riderToken.x, + x: riderToken.x, //@ts-ignore - y: riderToken.document.y ? riderToken.document.y : riderToken.y, + y: riderToken.y, //@ts-ignore - w: riderToken.document.width ? riderToken.document.width : riderToken.w, + w: riderToken.w, //@ts-ignore - h: riderToken.document.height ? riderToken.document.height : riderToken.h, + h: riderToken.h, }; if (newMountCoords.x + newMountCoords.w - newRiderCoords.w < newRiderCoords.x) { @@ -49,7 +49,7 @@ export const mountUpTA = async function (riderToken: Token, mountToken: Token) { // shrink the rider if needed //@ts-ignore - const grid = canvas.scene?.grid; + const grid = canvas.scene?.grid.size; let newWidthRider = riderToken.w; let newHeightRider = riderToken.h; //@ts-ignore @@ -65,12 +65,12 @@ export const mountUpTA = async function (riderToken: Token, mountToken: Token) { newHeightRiderSize = mountToken.document.height / 2; } - await riderToken.document.update({ - x: newRiderCoords.x, - y: newRiderCoords.y, - width: newWidthRiderSize, - height: newHeightRiderSize, - }); + // await riderToken.document.update({ + // x: newRiderCoords.x, + // y: newRiderCoords.y, + // width: newWidthRiderSize, + // height: newHeightRiderSize, + // }); const loc: { x; y } = MountManager.getRiderInitialLocation(riderToken, mountToken); if (game.settings.get(CONSTANTS.MODULE_NAME, "enableAutoUpdateElevation")) { @@ -81,11 +81,15 @@ export const mountUpTA = async function (riderToken: Token, mountToken: Token) { x: loc.x, y: loc.y, elevation: mountElevation, + width: newWidthRiderSize, + height: newHeightRiderSize, }); } else { await riderToken.document.update({ x: loc.x, y: loc.y, + width: newWidthRiderSize, + height: newHeightRiderSize, }); } @@ -118,12 +122,14 @@ export const mountUpTA = async function (riderToken: Token, mountToken: Token) { await window["tokenAttacher"].setElementsLockStatus(riderToken, isLocked, true); const canMoveConstrained = game.settings.get(CONSTANTS.MODULE_NAME, "enableCanMoveConstrained") || true; - await window["tokenAttacher"].setElementsMoveConstrainedStatus(riderToken, canMoveConstrained, true); - + // await window["tokenAttacher"].setElementsMoveConstrainedStatus(riderToken, canMoveConstrained, true); + await window["tokenAttacher"].setElementsMoveConstrainedStatus(riderToken, canMoveConstrained, true, { + type: window["tokenAttacher"].CONSTRAINED_TYPE.TOKEN_CONSTRAINED, + }); // Manage active effect - if (game.settings.get(CONSTANTS.MODULE_NAME, "enableActiveEffect")) { - await manageAEOnMountUp(riderToken, mountToken); - } + // if (game.settings.get(CONSTANTS.MODULE_NAME, "enableActiveEffect")) { + // await manageAEOnMountUp(riderToken, mountToken); + // } } }; @@ -257,7 +263,7 @@ export const detachAllFromTokenTA = async function (mountToken: Token) { // }; // ChatMessage.create(chatData); }; - +/* export const moveToken = async function (riderToken: Token, mountToken: Token) { if (!riderToken || !mountToken) { return; @@ -306,3 +312,4 @@ export const moveTokens = async function (riderTokens: Token[], mountToken: Toke } } }; +*/