package sociaty import ( "go_dreamfactory/comm" "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" ) // 设置阵容 func (this *apiComp) FormationCheck(session comm.IUserSession, req *pb.SociatyBFormationReq) (code pb.ErrorCode) { return } func (this *apiComp) Formation(session comm.IUserSession, req *pb.SociatyBFormationReq) (code pb.ErrorCode, data *pb.ErrorData) { if code = this.FormationCheck(session, req); code != pb.ErrorCode_Success { return } 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 return } //检验第二队或第三队是否达到解锁条件 if _, ok := req.Teams[2]; ok { if user.Lv < ggd.GuildBossTroop2 { code = pb.ErrorCode_SociatyTeamUnlock 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 }