fix: 修复换楼后队友战绩分析消息不更新的问题#21
Open
kisstt18 wants to merge 5 commits into
Open
Conversation
当队友在选人阶段交换楼层(trade/swap)后,analyzeTeamPower 功能发送 的聊天消息不会更新,导致楼层与 KDA/胜率数据对应错误。 新增 CHAMP_SELECT 的 Update 事件监听,换楼后检测 myTeam 签名变化, 自动重新拉取数据并发送消息。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
原来的方案用 myTeam 签名(puuid:cellId)检测换楼,但实际换楼时 myTeam 顺序可能不会在 CHAMP_SELECT Update 中立即变化。改为监听 trades 字段的序列化快照,trades 变化即说明发生了换楼操作。 同时新增 statsByPuuid 缓存,换楼后直接从缓存按新 myTeam 顺序重建 消息发送,无需重复请求 SGP 接口。
- 新增 getPhaseLabel 函数,将 timer.phase 映射为中文阶段名 - 新增 sendTeamStatsMessage 统一消息构造与发送逻辑 - analyzeTeammates 和 resendAnalyzeMessageFromCache 共用同一发送函数 - 消息顶部增加双横线分隔 + 阶段标记,尾部保留 Sona 签名 - 换楼阶段标记为"英雄换楼阶段",与普通阶段区分
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题描述
当队友在选人阶段交换楼层(trade/swap)后,
analyzeTeamPower功能发送的聊天消息("队友卡池一览")不会更新,导致楼层与 KDA/胜率数据对应错误。例如:原本4楼的我与3楼队友换楼后,聊天框里3楼仍然显示我的数据,4楼显示队友的数据——数据"交换"了但实际上楼层对应错误。
根本原因
analyzeTeamPower只在GameflowPhase为ChampSelect时触发一次analyzeTeammates(),之后不再监听换楼事件。而champSelectAssist(头像特效)已有换楼处理(onChampSelectUpdate),analyzeTeamPower缺少同样的监听。修复内容
在
updateAnalyzeTeamPower中新增CHAMP_SELECTsession 的 Update 事件监听:getTeamDisplaySignature()比较 myTeam 中 puuid:cellId 的映射签名analyzeTeammates()重新拉取数据并发送聊天消息