73 lines
1.8 KiB
Go
73 lines
1.8 KiB
Go
package sociaty
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/sys/log"
|
|
"go_dreamfactory/pb"
|
|
)
|
|
|
|
// 设置阵容
|
|
func (this *apiComp) FormationCheck(session comm.IUserSession, req *pb.SociatyBFormationReq) (errdata *pb.ErrorData) {
|
|
return
|
|
}
|
|
|
|
func (this *apiComp) Formation(session comm.IUserSession, req *pb.SociatyBFormationReq) (errdata *pb.ErrorData) {
|
|
if code = this.FormationCheck(session, req); code != pb.ErrorCode_Success {
|
|
return
|
|
}
|
|
data = &pb.ErrorData{}
|
|
uid := session.GetUserId()
|
|
user := this.module.ModuleUser.GetUser(uid)
|
|
if user == nil {
|
|
this.module.Error("GetRemoteUser",
|
|
log.Field{Key: "uid", Value: uid},
|
|
)
|
|
code = pb.ErrorCode_UserSessionNobeing
|
|
return
|
|
}
|
|
|
|
ggd := this.module.ModuleTools.GetGlobalConf()
|
|
if ggd == nil {
|
|
code = pb.ErrorCode_ConfigNoFound
|
|
data.Title = code.ToString()
|
|
return
|
|
}
|
|
|
|
//检验第二队或第三队是否达到解锁条件
|
|
if _, ok := req.Teams[2]; ok {
|
|
if user.Lv < ggd.GuildBossTroop2 {
|
|
code = pb.ErrorCode_SociatyTeamUnlock
|
|
data.Title = code.ToString()
|
|
return
|
|
}
|
|
}
|
|
if _, ok := req.Teams[3]; ok {
|
|
if user.Lv < ggd.GuildBossTroop3 {
|
|
code = pb.ErrorCode_SociatyTeamUnlock
|
|
return
|
|
}
|
|
}
|
|
|
|
sociaty := this.module.modelSociaty.getUserSociaty(uid)
|
|
if sociaty == nil {
|
|
code = pb.ErrorCode_SociatyNoFound
|
|
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
|
|
return
|
|
}
|
|
|
|
if err := this.module.modelSociatyBoss.setFormation(sociaty, uid, req.Teams); err != nil {
|
|
this.module.Error("设置阵容", log.Field{Key: "uid", Value: uid})
|
|
code = pb.ErrorCode_DBError
|
|
return
|
|
}
|
|
|
|
rsp := &pb.SociatyBFormationResp{
|
|
SociatyId: sociaty.Id,
|
|
}
|
|
|
|
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeFormation, rsp); err != nil {
|
|
code = pb.ErrorCode_SystemError
|
|
}
|
|
return
|
|
}
|