36 lines
837 B
Go
36 lines
837 B
Go
package parkour
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
)
|
|
|
|
//参数校验
|
|
func (this *apiComp) AvoidCheck(session comm.IUserSession, req *pb.ParkourAvoidReq) (errdata *pb.ErrorData) {
|
|
return
|
|
}
|
|
|
|
///游戏
|
|
func (this *apiComp) Avoid(session comm.IUserSession, req *pb.ParkourAvoidReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
ok bool
|
|
)
|
|
if errdata = this.AvoidCheck(session, req); errdata != nil {
|
|
return
|
|
}
|
|
this.module.lock.RLock()
|
|
_, ok = this.module.battles[req.Battleid]
|
|
this.module.lock.RUnlock()
|
|
if ok {
|
|
go this.module.avoid(req.Battleid, session.GetUserId(), req.Distance)
|
|
} else {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
|
}
|
|
return
|
|
}
|
|
session.SendMsg(string(this.module.GetType()), "avoid", &pb.ParkourAvoidResp{})
|
|
return
|
|
}
|