From cd848f5fdcc6a0c9f7c5eb1df5f004ce1a8cb4cb Mon Sep 17 00:00:00 2001 From: lowercasedonkey <lowercasedonkey@gmail.com> Date: Mon, 9 Aug 2021 13:38:34 -0400 Subject: [PATCH] fix text sort --- src/js/slaveCostJS.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/js/slaveCostJS.js b/src/js/slaveCostJS.js index 83f460b7ed4..8eb7ea4d47c 100644 --- a/src/js/slaveCostJS.js +++ b/src/js/slaveCostJS.js @@ -2331,6 +2331,9 @@ globalThis.slaveCost = function(slave, isStartingSlave = false, followLaws = fal ])); let cheatFResultContents = App.UI.DOM.appendNewElement("div", el, costFrame()); + + App.UI.DOM.appendNewElement("div", el, "A slave's base value is modified by an additive multiplier. A slave worth ¤200 with two bonuses worth 0.1 each will be worth ¤220", "note"); + return el; /** Set up the frame that contains the info @@ -2341,12 +2344,22 @@ globalThis.slaveCost = function(slave, isStartingSlave = false, followLaws = fal el.classList.add("grid-2columns-auto"); let sortedBeautyMapKeys; - if ((criteria === "text" && direction === "descending") || (criteria === "value" && direction === "ascending")) { - sortedBeautyMapKeys = Array.from(beautyObj.map.keys()).sort((a, b) => (beautyObj.map.get(a) > beautyObj.map.get(b)) ? 1 : -1); - } else { - sortedBeautyMapKeys = Array.from(beautyObj.map.keys()).sort((a, b) => (beautyObj.map.get(a) < beautyObj.map.get(b)) ? 1 : -1); + if (criteria === "text") { + if (direction === "descending") { + sortedBeautyMapKeys = Array.from(beautyObj.map.keys()).sort((a, b) => (a > b) ? 1 : -1); + } else { + sortedBeautyMapKeys = Array.from(beautyObj.map.keys()).sort((a, b) => (a < b) ? 1 : -1); + } + } else if (criteria === "value") { + if (direction === "descending") { + sortedBeautyMapKeys = Array.from(beautyObj.map.keys()).sort((a, b) => (beautyObj.map.get(a) > beautyObj.map.get(b)) ? 1 : -1); + } else { + sortedBeautyMapKeys = Array.from(beautyObj.map.keys()).sort((a, b) => (beautyObj.map.get(a) < beautyObj.map.get(b)) ? 1 : -1); + } } + + for (const key of sortedBeautyMapKeys) { let value = beautyObj.map.get(key); value = (Math.floor(value * 10) / 10); @@ -2361,6 +2374,7 @@ globalThis.slaveCost = function(slave, isStartingSlave = false, followLaws = fal App.UI.DOM.appendNewElement("div", el, capFirstChar(key)); } + return el; } } -- GitLab