feat: capture in-game battle damage statistics & add battle_report API endpoints

This commit is contained in:
CAtlas0784 committed 2026-10-17 13:08:13 +07:00
1 parent 5c4d0d4149
commit 365e66ffe0
5 files changed
+415

No files matched your search

+17
View File
@@ -113,6 +113,23 @@ func init() {
rsp.EndStatus = req.EndStatus
rsp.BattleId = req.BattleId
rsp.StageId = req.StageId
if req.Stt != nil {
statusStr := "WIN"
switch req.EndStatus {
case goproto.BattleEndStatus_BATTLE_END_LOSE:
statusStr = "LOSE"
case goproto.BattleEndStatus_BATTLE_END_QUIT:
statusStr = "QUIT"
}
report := common.BattleReportFromStatistics(req.Stt, req.BattleId, req.StageId, statusStr)
if err := common.SaveBattleReport(report); err != nil {
Log(fmt.Sprintf("[DAMAGE_ANALYST] Failed to save battle report: %v", err))
} else {
Log(fmt.Sprintf("[DAMAGE_ANALYST] Battle report captured: BattleID=%d Dmg=%.1f Cycles=%d Turns=%d Status=%s",
req.BattleId, report.TeamTotalDamage, report.RoundCnt, report.TotalBattleTurns, statusStr))
}
}
return nil
})
+12
View File
@@ -1,6 +1,9 @@
package gameserver
import (
"fmt"
"gac-hkrpg-go/internal/common"
goproto "gac-hkrpg-go/protocol/proto"
)
@@ -33,6 +36,15 @@ func init() {
handle("QuitBattle", func(s *Session, req *goproto.QuitBattleCsReq, rsp *goproto.QuitBattleScRsp) error {
rsp.Retcode = 0
if req.Stt != nil {
report := common.BattleReportFromStatistics(req.Stt, 0, 0, "QUIT")
if err := common.SaveBattleReport(report); err != nil {
Log(fmt.Sprintf("[DAMAGE_ANALYST] Failed to save quit battle report: %v", err))
} else {
Log(fmt.Sprintf("[DAMAGE_ANALYST] Quit battle report captured: Dmg=%.1f Cycles=%d Turns=%d",
report.TeamTotalDamage, report.RoundCnt, report.TotalBattleTurns))
}
}
return nil
})