refactor(map): 优化英雄列表排序和英雄等级展示逻辑
1. 新增英雄列表按pool_lv升序排序的逻辑 2. 从cardData中获取英雄等级替代直接读取HeroInfo,优化数据读取方式
This commit is contained in:
@@ -678,9 +678,8 @@ export class CardComp extends CCComp {
|
||||
}
|
||||
|
||||
if(this.card_type===CardType.Hero){
|
||||
// 英雄卡:显示英雄名 + AP/HP
|
||||
const hero = HeroInfo[this.card_uuid];
|
||||
const heroLv = Math.max(1, hero?.lv);
|
||||
const heroLv = Math.max(1, this.cardData.hero_lv ?? hero?.lv ?? 1);
|
||||
this.setLabel(this.name_node, `${hero?.name || ""}`);
|
||||
if (this.lvl_node) {
|
||||
this.lvl_node.string = `Lv.${heroLv}`;
|
||||
|
||||
@@ -115,7 +115,11 @@ export class HerosListComp extends CCComp {
|
||||
|
||||
this.cards_node.removeAllChildren()
|
||||
|
||||
for (const uuid of HeroList) {
|
||||
const sorted = [...HeroList].sort((a, b) => {
|
||||
return (HeroInfo[a]?.pool_lv ?? 1) - (HeroInfo[b]?.pool_lv ?? 1);
|
||||
});
|
||||
|
||||
for (const uuid of sorted) {
|
||||
const hero = HeroInfo[uuid]
|
||||
if (!hero) continue
|
||||
|
||||
|
||||
Reference in New Issue
Block a user