73 lines
1.7 KiB
Go
73 lines
1.7 KiB
Go
package mainline
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/base"
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/modules"
|
|
"go_dreamfactory/pb"
|
|
"sort"
|
|
)
|
|
|
|
type Mainline struct {
|
|
modules.ModuleBase
|
|
modelMainline *ModelMainline
|
|
service base.IRPCXService
|
|
api *apiComp
|
|
configure *configureComp
|
|
battle comm.IBattle
|
|
}
|
|
|
|
func NewModule() core.IModule {
|
|
return &Mainline{}
|
|
}
|
|
|
|
func (this *Mainline) GetType() core.M_Modules {
|
|
return comm.ModuleMainline
|
|
}
|
|
|
|
func (this *Mainline) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
|
|
err = this.ModuleBase.Init(service, module, options)
|
|
|
|
return
|
|
}
|
|
|
|
func (this *Mainline) OnInstallComp() {
|
|
this.ModuleBase.OnInstallComp()
|
|
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
|
|
this.modelMainline = this.RegisterComp(new(ModelMainline)).(*ModelMainline)
|
|
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
|
}
|
|
|
|
// 接口信息 给其他模块调用 用来修改主线关卡信息
|
|
func (this *Mainline) ModifyMainlineData(uid string, objId string, data map[string]interface{}) (code pb.ErrorCode) {
|
|
err := this.modelMainline.modifyMainlineData(uid, objId, data)
|
|
if err != nil {
|
|
code = pb.ErrorCode_DBError
|
|
}
|
|
return
|
|
}
|
|
|
|
func (this *Mainline) GetUsermainLineData(uid string) (mainlineId int32) {
|
|
|
|
_szData, err := this.modelMainline.getMainlineList(uid)
|
|
if err == nil {
|
|
sort.SliceStable(_szData, func(i, j int) bool { // 排序
|
|
return _szData[i].ChapterId > _szData[j].ChapterId
|
|
})
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
func (this *Mainline) Start() (err error) {
|
|
err = this.ModuleBase.Start()
|
|
var module core.IModule
|
|
if module, err = this.service.GetModule(comm.ModuleChat); err != nil {
|
|
return
|
|
}
|
|
|
|
this.battle = module.(comm.IBattle)
|
|
return
|
|
}
|