|
|
|
package statistics
|
|
|
|
|
|
|
|
import (
|
|
|
|
"dcg/app/user_center/usercenter"
|
|
|
|
pbGameZhg "dcg/game/pb/game/zhg"
|
|
|
|
"dcg/game/svc"
|
|
|
|
"git.noahlan.cn/northlan/ngs/component"
|
|
|
|
"git.noahlan.cn/northlan/ngs/session"
|
|
|
|
"git.noahlan.cn/northlan/ntools-go/logger"
|
|
|
|
)
|
|
|
|
|
|
|
|
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.StatPvPReport) 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,
|
|
|
|
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,
|
|
|
|
Damage: item.Damage,
|
|
|
|
DeDamage: item.DeDamage,
|
|
|
|
KillUnit: item.KillUnit,
|
|
|
|
DeKillUnit: item.DeKillUnit,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
logger.SLog.Info("接收客户端战报", msg)
|
|
|
|
resp, err := p.svcCtx.UserCenterRpc.StatPvpReport(p.svcCtx.Ctx, &usercenter.StatPvPReportReq{
|
|
|
|
WinCamp: msg.WinCamp,
|
|
|
|
GeneralUid: msg.GeneralUid,
|
|
|
|
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,
|
|
|
|
AddonIntegral: item.AddonIntegral,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
for _, item := range resp.LostItems {
|
|
|
|
lostItemsResp = append(lostItemsResp, &pbGameZhg.StatPvPReportResp_Item{
|
|
|
|
Uid: item.Uid,
|
|
|
|
AddonIntegral: item.AddonIntegral,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
return s.Response(&pbGameZhg.StatPvPReportResp{
|
|
|
|
WinItems: winItemsResp,
|
|
|
|
LostItems: lostItemsResp,
|
|
|
|
})
|
|
|
|
}
|