From f64ac04d9e452d9059e3bdbfd9cf775d7e6ed3d3 Mon Sep 17 00:00:00 2001 From: David Burhans Date: Mon, 15 Jun 2020 22:22:41 -0500 Subject: [PATCH] Statistics screen will now sort pinned shapes above non-pinned shapes --- src/js/game/hud/parts/statistics.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/js/game/hud/parts/statistics.js b/src/js/game/hud/parts/statistics.js index fc19b3fd..0452d7e5 100644 --- a/src/js/game/hud/parts/statistics.js +++ b/src/js/game/hud/parts/statistics.js @@ -175,7 +175,15 @@ export class HUDStatistics extends BaseHUDPart { } } - entries.sort((a, b) => b[1] - a[1]); + // Reach into the Hud to get the object that tracks which parts are pinned + const { pinnedShapes } = this.root.hud.parts; + entries.sort((a, b) => { + // do a sort calculation based on if the shapes are pinned + const pinSort = + Number(pinnedShapes.isShapePinned(b[0])) - Number(pinnedShapes.isShapePinned(a[0])); + // if the pinning of shapes is not equal, sort on that, otherwise, sort on the rates + return pinSort !== 0 ? pinSort : b[1] - a[1]; + }); let rendered = new Set();