66 lines
1.6 KiB
Go
66 lines
1.6 KiB
Go
package sociaty
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/sys/log"
|
|
"go_dreamfactory/pb"
|
|
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
// 公会BOSS 积分奖励领取
|
|
|
|
func (this *apiComp) BreceiveCheck(session comm.IUserSession, req *pb.SociatyBReceiveReq) (code pb.ErrorCode) {
|
|
if req.TaskId <= 0 {
|
|
code = pb.ErrorCode_ReqParameterError
|
|
}
|
|
return
|
|
}
|
|
|
|
func (this *apiComp) Breceive(session comm.IUserSession, req *pb.SociatyBReceiveReq) (code pb.ErrorCode, data proto.Message) {
|
|
if code = this.BreceiveCheck(session, req); code != pb.ErrorCode_Success {
|
|
return
|
|
}
|
|
uid := session.GetUserId()
|
|
sociaty := this.module.modelSociaty.getUserSociaty(uid)
|
|
if sociaty == nil {
|
|
code = pb.ErrorCode_SociatyNoFound
|
|
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
|
|
return
|
|
}
|
|
|
|
taskConf := this.module.configure.getBossTask(req.TaskId)
|
|
if taskConf == nil {
|
|
code = pb.ErrorCode_ConfigNoFound
|
|
return
|
|
}
|
|
|
|
dbr := this.module.modelSociatyBoss.getChallengeRecord(uid)
|
|
var taskId int32
|
|
for _, task := range dbr.Tasks {
|
|
if task.TaskId == req.TaskId {
|
|
taskId = task.TaskId
|
|
if task.Status == 2 { //已领取
|
|
code = pb.ErrorCode_SociatyTaskReceived
|
|
return
|
|
} else if taskId == 0 { //未完成
|
|
code = pb.ErrorCode_SociatyTaskNoFinished
|
|
return
|
|
}
|
|
break
|
|
}
|
|
}
|
|
|
|
//更新任务状态
|
|
|
|
|
|
rsp := &pb.SociatyBReceiveResp{
|
|
SociatyId: sociaty.Id,
|
|
TaskId: req.TaskId,
|
|
}
|
|
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeBreceive, rsp); err != nil {
|
|
code = pb.ErrorCode_SystemError
|
|
}
|
|
return
|
|
}
|