Skip to content

Commit

Permalink
version 3.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
p4535992 committed Oct 23, 2022
1 parent 3f79024 commit a4fadaf
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 32 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions src/module.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -59,7 +59,7 @@
"path": "languages/ja.json"
}
],
"esmodules": ["./mountup.js"],
"esmodules": ["mountup.js"],
"styles": [],
"compatibility": {
"minimum": 10,
Expand All @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions src/scripts/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ const API = {
for (const key in p) {
const senseOrConditionIdKey = key;
const senseOrConditionValue = <any>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) {
Expand Down Expand Up @@ -208,7 +208,7 @@ const API = {
for (const key in p) {
const senseOrConditionIdKey = key;
const senseOrConditionValue = <any>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) {
Expand Down
8 changes: 4 additions & 4 deletions src/scripts/mountManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class MountManager {

// // shrink the rider if needed
// if (riderToken.w >= mountToken.w || riderToken.h >= mountToken.h) {
// const grid = <number>canvas.scene?.grid;
// const grid = <number>canvas.scene?.grid.size;
// const newWidth = mountToken.w / 2 / grid;
// const newHeight = mountToken.h / 2 / grid;
// await riderToken.document.update({
Expand Down Expand Up @@ -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 = <number>canvas.scene?.grid;
// const grid = <number>canvas.scene?.grid.size;
// const newWidth = mountToken.w / 2 / grid;
// const newHeight = mountToken.h / 2 / grid;
// await riderTokenTmp.document.update({
Expand Down Expand Up @@ -212,7 +212,7 @@ export class MountManager {
// MOD 4535992 REMOVED IF
//if (riderToken.w < origsize.w || riderToken.h < origsize.h) {
//@ts-ignore
const grid = <number>canvas.scene?.grid;
const grid = <number>canvas.scene?.grid.size;
const newWidth = riderToken.w < origsize.w ? origsize.w : riderToken.w;
const newHeight = riderToken.h < origsize.h ? origsize.h : riderToken.h;

Expand Down Expand Up @@ -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 = <number>canvas.scene?.grid;
// const grid = <number>canvas.scene?.grid.size;
// const newWidth = mountToken.w / 2 / grid;
// const newHeight = mountToken.h / 2 / grid;
// await riderToken.document.update({
Expand Down
49 changes: 28 additions & 21 deletions src/scripts/tokenAttacherHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ export const mountUpTA = async function (riderToken: Token, mountToken: Token) {
const mount = <Token>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) {
Expand All @@ -49,7 +49,7 @@ export const mountUpTA = async function (riderToken: Token, mountToken: Token) {

// shrink the rider if needed
//@ts-ignore
const grid = <number>canvas.scene?.grid;
const grid = <number>canvas.scene?.grid.size;
let newWidthRider = riderToken.w;
let newHeightRider = riderToken.h;
//@ts-ignore
Expand All @@ -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")) {
Expand All @@ -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,
});
}

Expand Down Expand Up @@ -118,12 +122,14 @@ export const mountUpTA = async function (riderToken: Token, mountToken: Token) {
await window["tokenAttacher"].setElementsLockStatus(riderToken, isLocked, true);
const canMoveConstrained =
<boolean>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);
// }
}
};

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -306,3 +312,4 @@ export const moveTokens = async function (riderTokens: Token[], mountToken: Toke
}
}
};
*/

0 comments on commit a4fadaf

Please sign in to comment.