From 39c3f90240e6ac5d52c05004bf3c05529e163553 Mon Sep 17 00:00:00 2001 From: Sven Balzer <4653051+Kyuusokuna@users.noreply.github.com> Date: Sun, 7 Sep 2025 08:29:44 +0200 Subject: [PATCH] fix broken sorting for talente --- src/main.mjs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main.mjs b/src/main.mjs index 9072e0b..f05df19 100644 --- a/src/main.mjs +++ b/src/main.mjs @@ -151,6 +151,10 @@ Hooks.once("init", async function() { }); }); +function string_compare(a, b) { + return a > b ? 1 : a < b ? -1 : 0; +} + function get_targeted_actors() { const targets = []; @@ -792,7 +796,7 @@ class DSA41_CharacterData extends TypeDataModel { this.computed.parade.wert = this.computed.parade.basiswert + this.modifikator_parade + this.computed.wunden_modifiers.parade; this.computed.fernkampf.wert = this.computed.fernkampf.basiswert + this.modifikator_fernkampf; - this.kampftalente = this.parent.items.filter((x) => x.type === "Kampftalent").sort((a, b) => a.name > b.name); + this.kampftalente = this.parent.items.filter((x) => x.type === "Kampftalent").sort((a, b) => string_compare(a.name, b.name)); for(const talent of this.kampftalente) { this.computed.kampf.talente[talent.name] = {}; this.computed.kampf.talente[talent.name].attacke = (talent.system.kategorie === "fernkampf" ? this.computed.fernkampf.wert : this.computed.attacke.wert) + talent.system.attacke; @@ -900,7 +904,7 @@ class DSA41_CharacterData extends TypeDataModel { computed.trefferpunkte_display = computed.trefferpunkte.replace(/[\+\-]/, (op) => "
" + op); } - const talente = this.parent.items.filter((x) => x.type === "Talent").sort((a, b) => a.name > b.name); + const talente = this.parent.items.filter((x) => x.type === "Talent").sort((a, b) => string_compare(a.name, b.name)); this.talente = { koerperliche: talente.filter((x) => x.system.kategorie === "koerperliche"), gesellschaftliche: talente.filter((x) => x.system.kategorie === "gesellschaftliche"),