package sociaty import ( "fmt" "go_dreamfactory/comm" "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" "google.golang.org/protobuf/proto" ) // 公会BOSS入口 func (this *apiComp) BossmainCheck(session comm.IUserSession, req *pb.SociatyBMainReq) (code pb.ErrorCode) { return } func (this *apiComp) Bossmain(session comm.IUserSession, req *pb.SociatyBMainReq) (code pb.ErrorCode, data proto.Message) { uid := session.GetUserId() ggd := this.module.configure.GetGlobalConf() if ggd == nil { code = pb.ErrorCode_ConfigNoFound return } userEx, err := this.module.ModuleUser.GetUserExpand(uid) if err != nil { this.module.Error("GetRemoteUserExpand", log.Field{Key: "uid", Value: uid}, log.Field{Key: "err", Value: err.Error()}, ) code = pb.ErrorCode_UserSessionNobeing return } rsp := &pb.SociatyBMainResp{ Ticket: userEx.SociatyTicket, } // 未参赛(恢复挑战券) if !this.module.modelSociatyBoss.IsSports(uid) { userEx.SociatyTicket = ggd.GuildBossInitialNum update := map[string]interface{}{ "sociatyTicket": userEx.SociatyTicket, } if err := this.module.ModuleUser.ChangeUserExpand(uid, update); err != nil { code = pb.ErrorCode_DBError return } } sociaty := this.module.modelSociaty.getUserSociaty(uid) if sociaty == nil { code = pb.ErrorCode_SociatyNoFound this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid}) return } // 赛季信息 dbs := this.module.modelSociatyBoss.getSociatyBossSports() if dbs == nil { code = pb.ErrorCode_SociatySportsNoinit return } rsp.EndTime = dbs.EndTime rsp.SettlementTime = dbs.SettlementTime // 个人积分 dbr := this.module.modelSociatyBoss.getChallengeRecord(uid) if dbr != nil { rsp.Total = dbr.Total rsp.HighIntegrals = dbr.Integrals } //个人排名 rsp.PersonalRanking = this.module.modelSociatyBoss.getRankingByUid( fmt.Sprintf("%s:%s", this.module.modelSociatyBoss.TableName, BOSS_PERSONAL_RANK), uid) // 公会排名 rsp.SociatyRanking = this.module.modelSociatyBoss.getRankingByUid( fmt.Sprintf("%s:%s", this.module.modelSociatyBoss.TableName, BOSS_SOCIATY_RANK), uid) if sm := this.module.modelSociaty.getMemberInfo(sociaty, uid); sm != nil { rsp.Teams = sm.Teams } if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeBossmain, rsp); err != nil { code = pb.ErrorCode_SystemError } return }