go_dreamfactory/modules/sociaty/api_cross_bossmain.go
2023-01-13 20:33:21 +08:00

78 lines
1.9 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) 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.sportsIsStarted() {
if userEx.SociatyTicket != ggd.GuildBossInitialNum {
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 && sociaty.Id == "" {
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
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
}