117 lines
2.7 KiB
Go
117 lines
2.7 KiB
Go
package expedition
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/modules"
|
|
"go_dreamfactory/pb"
|
|
)
|
|
|
|
/*
|
|
公会远征
|
|
*/
|
|
|
|
func NewModule() core.IModule {
|
|
m := new(Expedition)
|
|
return m
|
|
}
|
|
|
|
type Expedition struct {
|
|
modules.ModuleBase
|
|
service comm.IService
|
|
sociaty comm.ISociaty
|
|
mail comm.Imail
|
|
api *apiComp
|
|
model *ModelExpedition
|
|
configure *MCompConfigure
|
|
}
|
|
|
|
// 模块名
|
|
func (this *Expedition) GetType() core.M_Modules {
|
|
return comm.ModuleExpedition
|
|
}
|
|
|
|
// 模块初始化接口 注册用户创建角色事件
|
|
func (this *Expedition) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
|
|
if err = this.ModuleBase.Init(service, module, options); err != nil {
|
|
return
|
|
}
|
|
this.service = service.(comm.IService)
|
|
return
|
|
}
|
|
func (this *Expedition) Start() (err error) {
|
|
if err = this.ModuleBase.Start(); err != nil {
|
|
return
|
|
}
|
|
var module core.IModule
|
|
if module, err = this.service.GetModule(comm.ModuleSociaty); err != nil {
|
|
return
|
|
}
|
|
this.sociaty = module.(comm.ISociaty)
|
|
if module, err = this.service.GetModule(comm.ModuleMail); err != nil {
|
|
return
|
|
}
|
|
this.mail = module.(comm.Imail)
|
|
return
|
|
}
|
|
|
|
// 装备组件
|
|
func (this *Expedition) OnInstallComp() {
|
|
this.ModuleBase.OnInstallComp()
|
|
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
|
|
this.configure = this.RegisterComp(new(MCompConfigure)).(*MCompConfigure)
|
|
this.model = this.RegisterComp(new(ModelExpedition)).(*ModelExpedition)
|
|
}
|
|
|
|
// 红点
|
|
// 红点需求
|
|
func (this *Expedition) Reddot(session comm.IUserSession, rid map[comm.ReddotType]struct{}) (items map[comm.ReddotType]*pb.ReddotItem) {
|
|
var (
|
|
selfrid []comm.ReddotType = []comm.ReddotType{comm.Reddot15400}
|
|
model *guildgveModel
|
|
user *pb.DBUserExpand
|
|
info *pb.DBExpedition
|
|
member *pb.DBExpeditionMember
|
|
err error
|
|
ok bool
|
|
)
|
|
items = make(map[comm.ReddotType]*pb.ReddotItem)
|
|
for _, v := range selfrid {
|
|
if _, ok = rid[v]; ok {
|
|
break
|
|
}
|
|
}
|
|
|
|
if !ok {
|
|
return
|
|
}
|
|
for _, v := range selfrid {
|
|
if _, ok = rid[v]; ok {
|
|
switch v {
|
|
case comm.Reddot15400:
|
|
state := getSysDayTimeState()
|
|
if state == 1 {
|
|
if user, err = this.GetUserExpandForSession(session); user.SociatyId != "" {
|
|
if model, err = this.model.guildgveModel(); err != nil {
|
|
this.Errorln(err)
|
|
return
|
|
}
|
|
if info, err = model.getInfo(user.SociatyId); err != nil {
|
|
this.Errorln(err)
|
|
return
|
|
}
|
|
if member, ok = info.Boos[info.Indexboos].Members[session.GetUserId()]; !ok || member.State == 0 {
|
|
items[comm.Reddot17] = &pb.ReddotItem{
|
|
Rid: int32(comm.Reddot17),
|
|
Activated: true,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
break
|
|
}
|
|
}
|
|
}
|
|
return
|
|
}
|