go_dreamfactory/modules/hunting/module.go
2022-09-13 18:03:55 +08:00

61 lines
1.5 KiB
Go

package hunting
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
)
type Hunting struct {
modules.ModuleBase
modelHunting *modelHunting
api *apiComp
configure *configureComp
modulerank *ModelRank
battle comm.IBattle
service core.IService
}
func NewModule() core.IModule {
return &Hunting{}
}
func (this *Hunting) GetType() core.M_Modules {
return comm.ModuleHunting
}
func (this *Hunting) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
err = this.ModuleBase.Init(service, module, options)
this.service = service
return
}
func (this *Hunting) Start() (err error) {
err = this.ModuleBase.Start()
var module core.IModule
if module, err = this.service.GetModule(comm.ModuleBattle); err != nil {
return
}
this.battle = module.(comm.IBattle)
return
}
func (this *Hunting) OnInstallComp() {
this.ModuleBase.OnInstallComp()
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
this.modelHunting = this.RegisterComp(new(modelHunting)).(*modelHunting)
this.modulerank = this.RegisterComp(new(ModelRank)).(*ModelRank)
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
}
// 接口信息
func (this *Hunting) ModifyHuntingData(uid string, data map[string]interface{}) (code pb.ErrorCode) {
err := this.modelHunting.modifyHuntingDataByObjId(uid, data)
if err != nil {
code = pb.ErrorCode_DBError
}
return
}