You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
2.1 KiB
Go

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() {
}
// Damage 伤害记录
func (p *PvP) Damage(s *session.Session, msg *pbStat.StatPvPDamage) error {
_, err := p.svcCtx.UserCenterRpc.StatPvpDamage(p.svcCtx.Ctx, &usercenter.StatPvPDamageReq{
Uid: msg.Uid,
TargetUid: msg.TargetUid,
Damage: msg.Damage,
})
if err != nil {
return err
}
return nil
}
// KillUnit 击杀单位
func (p *PvP) KillUnit(s *session.Session, msg *pbStat.StatPvPKillUnit) error {
_, err := p.svcCtx.UserCenterRpc.StatPvpKillUnit(p.svcCtx.Ctx, &usercenter.StatPvPKillUnitReq{
Uid: msg.Uid,
TargetUid: msg.TargetUid,
Attacker: msg.Attacker,
Victim: msg.Victim,
})
if err != nil {
return err
}
return nil
}
// 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 {
_, err := p.svcCtx.UserCenterRpc.StatPvpReport(p.svcCtx.Ctx, &usercenter.StatPvPReportReq{
WinCamp: msg.WinCamp,
GeneralUid: msg.GeneralUid,
WinUids: msg.WinUids,
LostUids: msg.LostUids,
})
if err != nil {
return err
}
return nil
}