go_dreamfactory/modules/parkour/api_shot.go
2023-06-06 09:56:12 +08:00

36 lines
832 B
Go

package parkour
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
)
//参数校验
func (this *apiComp) ShotCheck(session comm.IUserSession, req *pb.ParkourShotReq) (errdata *pb.ErrorData) {
return
}
///匹配请求
func (this *apiComp) Shot(session comm.IUserSession, req *pb.ParkourShotReq) (errdata *pb.ErrorData) {
var (
ok bool
)
if code = this.ShotCheck(session, req); code != pb.ErrorCode_Success {
return
}
this.module.lock.RLock()
_, ok = this.module.battles[req.Battleid]
this.module.lock.RUnlock()
if ok {
go this.module.shot(req.Battleid, session.GetUserId())
} else {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ReqParameterError,
Title: pb.ErrorCode_ReqParameterError.ToString(),
}
return
}
session.SendMsg(string(this.module.GetType()), "shot", &pb.ParkourShotResp{})
return
}