68 lines
1.7 KiB
Go
68 lines
1.7 KiB
Go
package autoBattle
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/lego/sys/event"
|
|
"go_dreamfactory/modules"
|
|
"go_dreamfactory/pb"
|
|
)
|
|
|
|
type AutoBattle struct {
|
|
modules.ModuleBase
|
|
modelAutoBattle *modelAutoBattle
|
|
api *apiComp
|
|
configure *configureComp
|
|
battle comm.IBattle
|
|
service core.IService
|
|
}
|
|
|
|
func NewModule() core.IModule {
|
|
return &AutoBattle{}
|
|
}
|
|
|
|
func (this *AutoBattle) GetType() core.M_Modules {
|
|
return comm.ModuleAutoBattle
|
|
}
|
|
|
|
func (this *AutoBattle) 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 *AutoBattle) 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)
|
|
|
|
event.RegisterGO(comm.EventUserOffline, this.EventUserOffline)
|
|
return
|
|
}
|
|
|
|
func (this *AutoBattle) OnInstallComp() {
|
|
this.ModuleBase.OnInstallComp()
|
|
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
|
|
|
|
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
|
}
|
|
|
|
// 接口信息
|
|
func (this *AutoBattle) ModifyAutoData(uid string, id string, data map[string]interface{}) (code pb.ErrorCode) {
|
|
err := this.modelAutoBattle.ChangeListByObjId(uid, id, data)
|
|
if err != nil {
|
|
code = pb.ErrorCode_DBError
|
|
}
|
|
return
|
|
}
|
|
|
|
//Event-------------------------------------------------------------------------------------------------玩家离线
|
|
func (this *AutoBattle) EventUserOffline(session comm.IUserSession) {
|
|
err := this.modelAutoBattle.RemoveUserInfo(session)
|
|
this.Debugf("EventUserOffline:%s err:%v", session.ToString(), err)
|
|
}
|