|
|
|
package statistics
|
|
|
|
|
|
|
|
import (
|
|
|
|
"dcg/app/user_center/usercenter"
|
|
|
|
pbStat "dcg/game/pb/stat"
|
|
|
|
"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 *pbStat.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 *pbStat.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 *pbStat.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,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
_, 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
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|