diff --git a/assets/script/game/map/HeroInfoComp.ts b/assets/script/game/map/HeroInfoComp.ts index b961c86e..923ec7d6 100644 --- a/assets/script/game/map/HeroInfoComp.ts +++ b/assets/script/game/map/HeroInfoComp.ts @@ -247,11 +247,13 @@ export class HeroInfoComp extends CCComp { * @param delta 1 下一个,-1 上一个 */ private switchHero(delta: 1 | -1) { - // 与图鉴页面排序同源:仅按品质降序 → uuid 升序 + // 与图鉴页面排序同源:按职业(HRole)升序 → uuid 升序 const sorted = [...HeroList].sort((a, b) => { - const ra = HeroInfo[a]?.rarity ?? 1; - const rb = HeroInfo[b]?.rarity ?? 1; - if (ra !== rb) return rb - ra; + const heroA = HeroInfo[a]; + const heroB = HeroInfo[b]; + const roleA = heroA?.role ?? 0; + const roleB = heroB?.role ?? 0; + if (roleA !== roleB) return roleA - roleB; return a - b; }); if (sorted.length === 0) return; diff --git a/assets/script/game/map/HerosListComp.ts b/assets/script/game/map/HerosListComp.ts index ca3b81f7..4cfd27dc 100644 --- a/assets/script/game/map/HerosListComp.ts +++ b/assets/script/game/map/HerosListComp.ts @@ -113,11 +113,13 @@ export class HerosListComp extends CCComp { this.cards_node.removeAllChildren() - // 图鉴排序:仅按品质降序 → uuid 升序(与养成进度解耦,保持展示稳定) + // 图鉴排序:按职业(HRole)升序 → uuid 升序(与养成进度解耦,保持展示稳定) const sorted = [...HeroList].sort((a, b) => { - const ra = HeroInfo[a]?.rarity ?? 1; - const rb = HeroInfo[b]?.rarity ?? 1; - if (ra !== rb) return rb - ra; + const heroA = HeroInfo[a]; + const heroB = HeroInfo[b]; + const roleA = heroA?.role ?? 0; + const roleB = heroB?.role ?? 0; + if (roleA !== roleB) return roleA - roleB; return a - b; })