一些修复和优化

This commit is contained in:
FloatGaming
2026-07-20 02:22:51 +08:00
parent 818fc9a02f
commit 0a0872c4f4
49 changed files with 2008 additions and 262 deletions
+24 -3
View File
@@ -94,6 +94,9 @@ public class newTeamSelector : MonoBehaviour
return;
}
// 构建卡片前先确保成长账本已完成加载与镜像同步,消除"账本未初始化就读等级"的时序竞争。
AllyHeroDeployLedger.EnsureInstance().InitializeIfNeeded();
// Clear existing
for (int i = container.childCount - 1; i >= 0; i--)
{
@@ -449,7 +452,7 @@ public class newTeamSelector : MonoBehaviour
return null;
AllyHero_SO hero = FindHeroById(heroId);
return hero != null ? GetRatingFromSO(hero) : null;
return hero != null ? GetRatingFromLedger(hero) : null;
}
private IEnumerator RefreshSkillsGradually()
@@ -519,8 +522,26 @@ public class newTeamSelector : MonoBehaviour
}
}
private string GetRatingFromSO(AllyHero_SO so)
// 等级评级改从持久化账本(AllyHeroDeployLedger)取真值,而非 SO 上被打包烘焙的镜像字段。
// 修复:客户端更新后 SO 镜像为出厂 0 值,若账本尚未回写 SO 就构建卡片,会显示过期等级,
// 且需玩家重新给一次经验才同步。这里直接读账本(getter 内部会保证 InitializeIfNeeded),从根源消除不一致。
private string GetRatingFromLedger(AllyHero_SO so)
{
return so != null ? so.GetDisplayLevelRatingKey() : "C";
if (so == null)
{
return "C";
}
if (so.ally_heroID <= 0)
{
// 无有效 heroID 无法查账本,退回 SO 自身判级,保持原行为。
return so.GetDisplayLevelRatingKey();
}
AllyHeroDeployLedger ledger = AllyHeroDeployLedger.EnsureInstance();
int currentExp = ledger.GetCurrentExp(so.ally_heroID);
int unlockedTier = ledger.GetUnlockedTierIndex(so.ally_heroID);
bool levelLocked = ledger.IsLevelLockEnabled(so.ally_heroID);
return so.GetDisplayLevelRatingKeyFromGrowth(currentExp, unlockedTier, levelLocked);
}
}