Skip to content

Commit

Permalink
Merge branch 'feature/speed-not-found-error' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
caewok committed Apr 5, 2024
2 parents 95d21be + 930a81b commit 1a54c23
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.8.11
Catch when a segment color is not defined, to avoid throwing an error.


# 0.8.10
## New features
Add indicator of past combat movement in the ruler.
Expand Down
8 changes: 5 additions & 3 deletions scripts/const.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,13 @@ SPEED.maximumCategoryDistance = function(token, speedCategory, tokenSpeed) {
/**
* Given a token, retrieve its base speed.
* @param {Token} token Token whose speed is required
* @returns {number} Distance, in grid units
* @returns {number|null} Distance, in grid units. Null if no speed provided for that category.
* (Null will disable speed highlighting.)
*/
SPEED.tokenSpeed = function(token) {
const speedAttribute = SPEED.ATTRIBUTES[token.movementType] ?? SPEED.ATTRIBUTES.WALK;
return Number(foundry.utils.getProperty(token, speedAttribute));
const speed = foundry.utils.getProperty(token, SPEED.ATTRIBUTES[token.movementType]);
if ( speed === null ) return null;
return Number(speed);
};

// Avoid testing for the system id each time.
Expand Down
3 changes: 2 additions & 1 deletion scripts/segments.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,8 @@ export function _highlightMeasurementSegment(wrapped, segment) {
const token = this._getMovementToken();
const doSpeedHighlighting = token
// && this.user === game.user
&& Settings.get(Settings.KEYS.TOKEN_RULER.SPEED_HIGHLIGHTING);
&& Settings.get(Settings.KEYS.TOKEN_RULER.SPEED_HIGHLIGHTING)
&& segment.speed?.color;

// Highlight each split in turn, changing highlight color each time.
if ( doSpeedHighlighting ) this.color = segment.speed.color;
Expand Down

0 comments on commit 1a54c23

Please sign in to comment.