70 lines
1.9 KiB
Go
70 lines
1.9 KiB
Go
package sociaty
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
"go_dreamfactory/utils"
|
|
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
func (this *apiComp) MineCheck(session comm.IUserSession, req *pb.SociatyMineReq) (code pb.ErrorCode) {
|
|
return
|
|
}
|
|
|
|
func (this *apiComp) Mine(session comm.IUserSession, req *pb.SociatyMineReq) (code pb.ErrorCode, data proto.Message) {
|
|
uid := session.GetUserId()
|
|
userEx, err := this.module.ModuleUser.GetRemoteUserExpand(uid)
|
|
if err != nil {
|
|
this.module.Errorf("GetRemoteUserExpand uid: err:%v", uid, err)
|
|
code = pb.ErrorCode_UserSessionNobeing
|
|
return
|
|
}
|
|
|
|
rsp := &pb.SociatyMineResp{}
|
|
|
|
// 已加入公会
|
|
if userEx.SociatyId != "" {
|
|
sociaty := this.module.modelSociaty.getUserSociaty(uid)
|
|
if sociaty.Id == "" {
|
|
code = pb.ErrorCode_SociatyNoFound
|
|
this.module.Errorf("sociatyId: %s no found", userEx.SociatyId)
|
|
return
|
|
}
|
|
|
|
//验证是否解散
|
|
if this.module.modelSociaty.isDismiss(sociaty) {
|
|
code = pb.ErrorCode_SociatyDismissed
|
|
return
|
|
}
|
|
|
|
// 初始玩家公会任务
|
|
sociatyTask := this.module.modelSociatyTask.getUserTask(uid, sociaty.Id)
|
|
if sociatyTask.SociatyId != "" {
|
|
if utils.IsFirstTody(sociatyTask.LastUpdateTime) {
|
|
if err := this.module.modelSociatyTask.deleTask(sociaty.Id, uid); err == nil {
|
|
if err = this.module.modelSociatyTask.initSociatyTask(uid, sociaty.Id); err != nil {
|
|
this.module.Errorf("初始化玩家攻击任务失败 err:%v", err)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 获取会长
|
|
master := this.module.modelSociaty.getMasterInfo(sociaty)
|
|
if master != nil {
|
|
if err := this.module.modelSociaty.extendJob(master.Uid, sociaty); err == nil {
|
|
// 获取新的会长
|
|
master = this.module.modelSociaty.getMasterInfo(sociaty)
|
|
}
|
|
}
|
|
rsp.Sociaty = sociaty
|
|
rsp.Master = master
|
|
}
|
|
|
|
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeMine, rsp); err != nil {
|
|
code = pb.ErrorCode_SystemError
|
|
}
|
|
return
|
|
}
|