Skip to content

Commit

Permalink
🐛 fix|MovePenalty|Error in sf2e
Browse files Browse the repository at this point in the history
Starfinder requires that context parameter be an object, so pass it a blank object.

Fix for initializing token failing if TerrainMapper is not present.
  • Loading branch information
caewok committed Sep 17, 2024
1 parent 5febb1f commit 151b7f7
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions scripts/measurement/MovePenalty.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export class MovePenalty {
* @returns {object}
*/
static _constructTokenClone(token) {
const actor = new CONFIG.Actor.documentClass(token.actor.toObject());
const actor = new CONFIG.Actor.documentClass(token.actor.toObject(), {});
const document = new CONFIG.Token.documentClass(token.document.toObject());
const tClone = { document, actor, _original: token };

Expand Down Expand Up @@ -495,11 +495,13 @@ export class MovePenalty {
*/
#initializeTokenClone() {
const tClone = this.#localTokenClone;
const Terrain = CONFIG.terrainmapper.Terrain;
const tokenTerrains = Terrain.allOnToken(tClone);
if ( tokenTerrains.length ) {
CONFIG.terrainmapper.Terrain.removeFromTokenLocally(tClone, tokenTerrains, { refresh: false });
tClone.actor._initialize(); // This is slow
const Terrain = CONFIG.terrainmapper?.Terrain;
if ( Terrain ) {
const tokenTerrains = Terrain.allOnToken(tClone);
if ( tokenTerrains.length ) {
CONFIG.terrainmapper.Terrain.removeFromTokenLocally(tClone, tokenTerrains, { refresh: false });
tClone.actor._initialize(); // This is slow
}
}
return tClone;
}
Expand Down

0 comments on commit 151b7f7

Please sign in to comment.