Sorting fixes

This commit is contained in:
Tom committed 2021-05-08 03:51:47 -04:00
1 parent 67d3562659
commit 41c28c21df
4 files changed
+10 -27

No files matched your search

+6 -23
View File
@@ -75,17 +75,6 @@ export default function UpdateBuildings() {
o.id = Game.Objects[k].id;
return o;
});
arr.sort((a, b) =>
ColoursOrdering.indexOf(a.color) > // eslint-disable-line no-nested-ternary
ColoursOrdering.indexOf(b.color)
? 1
: ColoursOrdering.indexOf(a.color) < ColoursOrdering.indexOf(b.color) // eslint-disable-line no-nested-ternary
? -1
: a.pp < b.pp
? -1
: 0,
);
} else if (CMOptions.SortBuildings === 2) {
arr = Object.keys(target).map((k) => {
const o = target[k];
@@ -93,19 +82,13 @@ export default function UpdateBuildings() {
o.id = Game.Objects[k].id;
return o;
});
arr.sort((a, b) =>
ColoursOrdering.indexOf(a.color) > // eslint-disable-line no-nested-ternary
ColoursOrdering.indexOf(b.color)
? 1
: ColoursOrdering.indexOf(a.color) < ColoursOrdering.indexOf(b.color) // eslint-disable-line no-nested-ternary
? -1
: a.pp < b.pp
? -1
: 0,
);
}
// Sort by pp colour group, then by pp.
arr.sort((a, b) =>
ColoursOrdering.indexOf(a.color) === ColoursOrdering.indexOf(b.color)
? a.pp - b.pp
: ColoursOrdering.indexOf(a.color) - ColoursOrdering.indexOf(b.color)
);
for (let x = 0; x < arr.length; x++) {
Game.Objects[arr[x].name].l.style.gridRow = `${x + 2}/${x + 2}`;
}
+2 -2
View File
@@ -77,9 +77,9 @@ export default function UpdateUpgrades() {
}
if (CMOptions.SortUpgrades) {
// Sort by pp group, then by pp. Put gray upgrades last.
// Sort by pp colour group, then by pp.
arr.sort((a, b) =>
ColoursOrdering.indexOf(a.color) == ColoursOrdering.indexOf(b.color)
ColoursOrdering.indexOf(a.color) === ColoursOrdering.indexOf(b.color)
? a.pp - b.pp
: ColoursOrdering.indexOf(a.color) - ColoursOrdering.indexOf(b.color)
);