package statistics import ( "dcg/app/user_center/usercenter" "dcg/game/manager" pbGameZhg "dcg/game/pb/game/zhg" "dcg/game/svc" "git.noahlan.cn/northlan/ngs/component" "git.noahlan.cn/northlan/ngs/session" ) type PvP struct { component.Base svcCtx *svc.ServiceContext } func NewStatisticsPvP(svcCtx *svc.ServiceContext) *PvP { return &PvP{ svcCtx: svcCtx, } } func (p *PvP) CMD() string { return "statistics" } func (p *PvP) Prefix() string { return "pvp" } func (p *PvP) Init() { } func (p *PvP) Shutdown() { } // Kill 击杀玩家 func (p *PvP) Kill(s *session.Session, msg *pbGameZhg.StatPvPKill) error { _, err := p.svcCtx.UserCenterRpc.StatPvpKill(p.svcCtx.Ctx, &usercenter.StatPvPKillReq{ Uid: msg.Uid, TargetUid: msg.TargetUid, IsGeneral: msg.IsGeneral, }) if err != nil { return err } return nil } // First 一血 func (p *PvP) First(s *session.Session, msg *pbGameZhg.StatPvPFirstBlood) error { _, err := p.svcCtx.UserCenterRpc.StatPvpFirstBlood(p.svcCtx.Ctx, &usercenter.StatPvPFirstBloodReq{ Uid: msg.Uid, Type: msg.Type, }) if err != nil { return err } return nil } // Report 战报 func (p *PvP) Report(s *session.Session, msg *pbGameZhg.StatPvPReportReq) error { winItems := make([]*usercenter.StatPvPReportReq_Item, 0, len(msg.WinItems)) lostItems := make([]*usercenter.StatPvPReportReq_Item, 0, len(msg.LostItems)) for _, item := range msg.WinItems { winItems = append(winItems, &usercenter.StatPvPReportReq_Item{ Uid: item.Uid, Uname: item.Uname, Position: item.Position, Damage: item.Damage, DeDamage: item.DeDamage, KillUnit: item.KillUnit, DeKillUnit: item.DeKillUnit, }) } for _, item := range msg.LostItems { lostItems = append(lostItems, &usercenter.StatPvPReportReq_Item{ Uid: item.Uid, Uname: item.Uname, Position: item.Position, Damage: item.Damage, DeDamage: item.DeDamage, KillUnit: item.KillUnit, DeKillUnit: item.DeKillUnit, }) } // 战局ID resp, err := p.svcCtx.UserCenterRpc.StatPvpReport(p.svcCtx.Ctx, &usercenter.StatPvPReportReq{ WinCamp: msg.WinCamp, BattleId: manager.GameManager.BattleIdBySession(s), WinItems: winItems, LostItems: lostItems, }) if err != nil { return err } winItemsResp := make([]*pbGameZhg.StatPvPReportResp_Item, 0, len(resp.WinItems)) lostItemsResp := make([]*pbGameZhg.StatPvPReportResp_Item, 0, len(resp.LostItems)) for _, item := range resp.WinItems { winItemsResp = append(winItemsResp, &pbGameZhg.StatPvPReportResp_Item{ Uid: item.Uid, Uname: item.Uname, Position: item.Position, ReturnsIntegral: item.ReturnsIntegral, RewardPoolIntegral: item.RewardPoolIntegral, GeneralIntegral: item.GeneralIntegral, NobilityIntegral: item.NobilityIntegral, BattleIntegral: item.BattleIntegral, TotalIntegral: item.TotalIntegral, }) } for _, item := range resp.LostItems { lostItemsResp = append(lostItemsResp, &pbGameZhg.StatPvPReportResp_Item{ Uid: item.Uid, Uname: item.Uname, Position: item.Position, ReturnsIntegral: item.ReturnsIntegral, RewardPoolIntegral: item.RewardPoolIntegral, GeneralIntegral: item.GeneralIntegral, NobilityIntegral: item.NobilityIntegral, BattleIntegral: item.BattleIntegral, TotalIntegral: item.TotalIntegral, }) } return s.Response(&pbGameZhg.StatPvPReportResp{ WinItems: winItemsResp, LostItems: lostItemsResp, }) }