106 lines
2.7 KiB
Go
106 lines
2.7 KiB
Go
package sociaty
|
|
|
|
import (
|
|
"fmt"
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/sys/log"
|
|
"go_dreamfactory/pb"
|
|
)
|
|
|
|
// 公会BOSS入口
|
|
|
|
func (this *apiComp) BossmainCheck(session comm.IUserSession, req *pb.SociatyBMainReq) (errdata *pb.ErrorData) {
|
|
return
|
|
}
|
|
|
|
func (this *apiComp) Bossmain(session comm.IUserSession, req *pb.SociatyBMainReq) (errdata *pb.ErrorData) {
|
|
uid := session.GetUserId()
|
|
|
|
ggd := this.module.ModuleTools.GetGlobalConf()
|
|
if ggd == nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ConfigNoFound,
|
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
|
}
|
|
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()},
|
|
)
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_UserSessionNobeing,
|
|
Title: pb.ErrorCode_UserSessionNobeing.ToString(),
|
|
}
|
|
return
|
|
}
|
|
|
|
rsp := &pb.SociatyBMainResp{
|
|
Ticket: userEx.SociatyTicket,
|
|
}
|
|
|
|
// 未参赛(恢复挑战券)
|
|
if !this.module.modelSociatyBoss.IsInSports(uid) {
|
|
userEx.SociatyTicket = ggd.GuildBossInitialNum
|
|
update := map[string]interface{}{
|
|
"sociatyTicket": userEx.SociatyTicket,
|
|
}
|
|
if err := this.module.ModuleUser.ChangeUserExpand(uid, update); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
rsp.Ticket = userEx.SociatyTicket
|
|
}
|
|
|
|
sociaty := this.module.modelSociaty.getUserSociaty(uid)
|
|
if sociaty == nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_SociatyNoFound,
|
|
Title: pb.ErrorCode_SociatyNoFound.ToString(),
|
|
}
|
|
|
|
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
|
|
return
|
|
}
|
|
|
|
// 赛季信息
|
|
dbs := this.module.modelSociatyBoss.getSociatyBossSports()
|
|
if dbs == nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_SociatySportsNoinit,
|
|
Title: pb.ErrorCode_SociatySportsNoinit.ToString(),
|
|
}
|
|
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.getRankingByMember(
|
|
fmt.Sprintf("%s:%s", this.module.modelSociatyBoss.TableName, BOSS_PERSONAL_RANK), uid)
|
|
|
|
// 公会排名
|
|
rsp.SociatyRanking = this.module.modelSociatyBoss.getRankingByMember(
|
|
fmt.Sprintf("%s:%s", this.module.modelSociatyBoss.TableName, BOSS_SOCIATY_RANK), sociaty.Id)
|
|
|
|
if sm := this.module.modelSociaty.getMemberInfo(sociaty, uid); sm != nil {
|
|
rsp.Teams = sm.Teams
|
|
}
|
|
|
|
session.SendMsg(string(this.module.GetType()), SociatySubTypeBossmain, rsp)
|
|
return
|
|
}
|